11/*
2- * Copyright 2005-2010 the original author or authors.
2+ * Copyright 2005-2012 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
77 *
8- * http://www.apache.org/licenses/LICENSE-2.0
8+ * http://www.apache.org/licenses/LICENSE-2.0
99 *
1010 * Unless required by applicable law or agreed to in writing, software
1111 * distributed under the License is distributed on an "AS IS" BASIS,
1616
1717package org .springframework .ws .soap .security .wss4j ;
1818
19- import java .io .IOException ;
20- import java .security .cert .X509Certificate ;
19+ import java .util .List ;
2120import java .util .Properties ;
22- import java .util .Vector ;
23- import javax .security .auth .callback .Callback ;
24- import javax .security .auth .callback .CallbackHandler ;
25- import javax .security .auth .callback .UnsupportedCallbackException ;
2621
27- import org .apache .ws .security .WSConstants ;
28- import org .apache .ws .security .WSPasswordCallback ;
22+ import org .springframework .ws .context .MessageContext ;
23+
24+ import org .apache .ws .security .WSSecurityEngineResult ;
2925import org .apache .ws .security .WSSecurityException ;
3026import org .apache .ws .security .components .crypto .Crypto ;
3127import org .apache .ws .security .handler .RequestData ;
3228import org .apache .ws .security .handler .WSHandler ;
3329import org .apache .ws .security .handler .WSHandlerConstants ;
34- import org .apache .ws .security .message .token .Timestamp ;
3530import org .w3c .dom .Document ;
3631
37- import org .springframework .ws .context .MessageContext ;
38-
3932/**
4033 * @author Tareq Abed Rabbo
4134 * @author Arjen Poutsma
@@ -46,8 +39,6 @@ class Wss4jHandler extends WSHandler {
4639 /** Keys are constants from {@link WSHandlerConstants}; values are strings. */
4740 private Properties options = new Properties ();
4841
49- private CallbackHandler securementCallbackHandler ;
50-
5142 private String securementPassword ;
5243
5344 private Crypto securementEncryptionCrypto ;
@@ -61,12 +52,7 @@ class Wss4jHandler extends WSHandler {
6152 }
6253
6354 @ Override
64- protected boolean checkReceiverResults (Vector wsResult , Vector actions ) {
65- return super .checkReceiverResults (wsResult , actions );
66- }
67-
68- @ Override
69- protected boolean checkReceiverResultsAnyOrder (Vector wsResult , Vector actions ) {
55+ protected boolean checkReceiverResultsAnyOrder (List <WSSecurityEngineResult > wsResult , List <Integer > actions ) {
7056 return super .checkReceiverResultsAnyOrder (wsResult , actions );
7157 }
7258
@@ -83,10 +69,6 @@ public Object getOption(String key) {
8369 return options .getProperty (key );
8470 }
8571
86- void setSecurementCallbackHandler (CallbackHandler securementCallbackHandler ) {
87- this .securementCallbackHandler = securementCallbackHandler ;
88- }
89-
9072 void setSecurementPassword (String securementPassword ) {
9173 this .securementPassword = securementPassword ;
9274 }
@@ -99,48 +81,6 @@ void setSecurementSignatureCrypto(Crypto securementSignatureCrypto) {
9981 this .securementSignatureCrypto = securementSignatureCrypto ;
10082 }
10183
102- /** Gets the password first from securementCallbackHandler, then from securementPassword if not found. */
103- @ Override
104- public WSPasswordCallback getPassword (String username ,
105- int doAction ,
106- String clsProp ,
107- String refProp ,
108- RequestData reqData ) {
109- WSPasswordCallback callback ;
110- if (securementCallbackHandler != null ) {
111- int reason = 0 ;
112-
113- switch (doAction ) {
114- case WSConstants .UT :
115- case WSConstants .UT_SIGN :
116- reason = WSPasswordCallback .USERNAME_TOKEN ;
117- break ;
118- case WSConstants .SIGN :
119- reason = WSPasswordCallback .SIGNATURE ;
120- break ;
121- case WSConstants .ENCR :
122- reason = WSPasswordCallback .KEY_NAME ;
123- break ;
124- }
125- callback = new WSPasswordCallback (username , reason );
126- Callback [] callbacks = new Callback []{callback };
127- try {
128- securementCallbackHandler .handle (callbacks );
129- }
130- catch (UnsupportedCallbackException ex ) {
131- throw new Wss4jSecuritySecurementException (ex .getMessage (), ex );
132- }
133- catch (IOException ex ) {
134- throw new Wss4jSecuritySecurementException (ex .getMessage (), ex );
135- }
136- }
137- else {
138- callback = new WSPasswordCallback (username , WSPasswordCallback .UNKNOWN );
139- callback .setPassword (securementPassword );
140- }
141- return callback ;
142- }
143-
14484 @ Override
14585 public String getPassword (Object msgContext ) {
14686 return securementPassword ;
@@ -172,18 +112,11 @@ public void setProperty(Object msgContext, String key, Object value) {
172112 }
173113
174114 @ Override
175- protected void doSenderAction (int doAction , Document doc , RequestData reqData , Vector actions , boolean isRequest )
176- throws WSSecurityException {
115+ protected void doSenderAction (int doAction ,
116+ Document doc ,
117+ RequestData reqData ,
118+ List <Integer > actions ,
119+ boolean isRequest ) throws WSSecurityException {
177120 super .doSenderAction (doAction , doc , reqData , actions , isRequest );
178121 }
179-
180- @ Override
181- protected boolean verifyTimestamp (Timestamp timestamp , int timeToLive ) throws WSSecurityException {
182- return super .verifyTimestamp (timestamp , timeToLive );
183- }
184-
185- @ Override
186- protected boolean verifyTrust (X509Certificate cert , RequestData reqData ) throws WSSecurityException {
187- return super .verifyTrust (cert , reqData );
188- }
189122}
0 commit comments