Skip to content

Commit 1f15b8c

Browse files
committed
SWS-711 - Upgrade to wss4j 1.6
1 parent d567c3a commit 1f15b8c

12 files changed

+141
-349
lines changed

parent/pom.xml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -526,15 +526,11 @@
526526
<dependency>
527527
<groupId>org.apache.ws.security</groupId>
528528
<artifactId>wss4j</artifactId>
529-
<version>1.5.8</version>
529+
<version>1.6.5</version>
530530
<exclusions>
531531
<exclusion>
532-
<groupId>axis</groupId>
533-
<artifactId>axis</artifactId>
534-
</exclusion>
535-
<exclusion>
536-
<groupId>axis</groupId>
537-
<artifactId>axis-ant</artifactId>
532+
<groupId>xalan</groupId>
533+
<artifactId>xalan</artifactId>
538534
</exclusion>
539535
<exclusion>
540536
<groupId>xerces</groupId>
@@ -544,10 +540,6 @@
544540
<groupId>xml-apis</groupId>
545541
<artifactId>xml-apis</artifactId>
546542
</exclusion>
547-
<exclusion>
548-
<groupId>junit</groupId>
549-
<artifactId>junit</artifactId>
550-
</exclusion>
551543
</exclusions>
552544
</dependency>
553545
<!-- Spring Security -->

security/src/main/java/org/springframework/ws/soap/security/support/KeyStoreUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2008 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,
@@ -68,7 +68,7 @@ public static KeyStore loadDefaultKeyStore() throws GeneralSecurityException, IO
6868
factoryBean.setPassword(password);
6969
factoryBean.setType(type);
7070
factoryBean.afterPropertiesSet();
71-
return (KeyStore) factoryBean.getObject();
71+
return factoryBean.getObject();
7272
}
7373

7474
/**
@@ -117,7 +117,7 @@ public static KeyStore loadDefaultTrustStore() throws GeneralSecurityException,
117117
factoryBean.setPassword(password);
118118
factoryBean.setType(type);
119119
factoryBean.afterPropertiesSet();
120-
return (KeyStore) factoryBean.getObject();
120+
return factoryBean.getObject();
121121
}
122122

123123
}
Lines changed: 12 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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,
@@ -16,26 +16,19 @@
1616

1717
package org.springframework.ws.soap.security.wss4j;
1818

19-
import java.io.IOException;
20-
import java.security.cert.X509Certificate;
19+
import java.util.List;
2120
import 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;
2925
import org.apache.ws.security.WSSecurityException;
3026
import org.apache.ws.security.components.crypto.Crypto;
3127
import org.apache.ws.security.handler.RequestData;
3228
import org.apache.ws.security.handler.WSHandler;
3329
import org.apache.ws.security.handler.WSHandlerConstants;
34-
import org.apache.ws.security.message.token.Timestamp;
3530
import 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

Comments
 (0)