You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by co...@apache.org on 2008/09/24 15:59:06 UTC
svn commit: r698575 [1/2] - in /webservices/wss4j/trunk: ./
interop/org/apache/ws/axis/oasis/ interop/org/apache/ws/axis/oasis/ping/
src/org/apache/ws/security/ src/org/apache/ws/security/action/
src/org/apache/ws/security/handler/ src/org/apache/ws/se...
Author: coheigea
Date: Wed Sep 24 06:59:05 2008
New Revision: 698575
URL: http://svn.apache.org/viewvc?rev=698575&view=rev
Log:
[WSS-133] - Cleanup of misspellings, indentation etc.
- Applied most of Glen's patch (thanks!) for a bunch of spelling mistakes in method names.
I also added back in the old methods with @deprecated for backwards compatibility.
- Removed tabs from WSHandler and reindented it.
- Removed a load of source and test dependencies on deprecated methods
- Removed some unnecessary test println's
- Removed sandbox tests from "ant test" run, as they are broken.
Modified:
webservices/wss4j/trunk/build.xml
webservices/wss4j/trunk/interop/org/apache/ws/axis/oasis/PWCallback1.java
webservices/wss4j/trunk/interop/org/apache/ws/axis/oasis/ping/PingBindingImpl.java
webservices/wss4j/trunk/src/org/apache/ws/security/SOAP11Constants.java
webservices/wss4j/trunk/src/org/apache/ws/security/SOAP12Constants.java
webservices/wss4j/trunk/src/org/apache/ws/security/SOAPConstants.java
webservices/wss4j/trunk/src/org/apache/ws/security/WSPasswordCallback.java
webservices/wss4j/trunk/src/org/apache/ws/security/action/UsernameTokenAction.java
webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/EnvelopeIdResolver.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSBaseMessage.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSEncryptBody.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDerivedKeyBase.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java
webservices/wss4j/trunk/src/org/apache/ws/security/processor/DerivedKeyTokenProcessor.java
webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java
webservices/wss4j/trunk/src/org/apache/ws/security/transform/STRTransform.java
webservices/wss4j/trunk/src/org/apache/ws/security/util/WSSecurityUtil.java
webservices/wss4j/trunk/test/wssec/TestWSSecurityGetPassword.java
webservices/wss4j/trunk/test/wssec/TestWSSecurityNew5.java
webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSCT.java
webservices/wss4j/trunk/test/wssec/TestWSSecurityNewST1.java
webservices/wss4j/trunk/test/wssec/TestWSSecurityX509v1.java
webservices/wss4j/trunk/xdocs/axis.xml
Modified: webservices/wss4j/trunk/build.xml
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/build.xml?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/build.xml (original)
+++ webservices/wss4j/trunk/build.xml Wed Sep 24 06:59:05 2008
@@ -430,7 +430,7 @@
</java>
</target>
- <target name="allTests" depends="sandboxTests, interopTests">
+ <target name="allTests" depends="interopTests">
</target>
<target name="interopTests" depends="init">
Modified: webservices/wss4j/trunk/interop/org/apache/ws/axis/oasis/PWCallback1.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/interop/org/apache/ws/axis/oasis/PWCallback1.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/interop/org/apache/ws/axis/oasis/PWCallback1.java (original)
+++ webservices/wss4j/trunk/interop/org/apache/ws/axis/oasis/PWCallback1.java Wed Sep 24 06:59:05 2008
@@ -146,7 +146,7 @@
if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) {
- if(pc.getIdentifer().equals("Ron") && pc.getPassword().equals("noR")) {
+ if(pc.getIdentifier().equals("Ron") && pc.getPassword().equals("noR")) {
return;
@@ -180,15 +180,15 @@
pc.setKey(key);
- } else if(pc.getIdentifer().equals("alice")) {
+ } else if(pc.getIdentifier().equals("alice")) {
pc.setPassword("password");
- } else if(pc.getIdentifer().equals("bob")) {
+ } else if(pc.getIdentifier().equals("bob")) {
pc.setPassword("password");
- } else if(pc.getIdentifer().equals("Ron")) {
+ } else if(pc.getIdentifier().equals("Ron")) {
pc.setPassword("noR");
Modified: webservices/wss4j/trunk/interop/org/apache/ws/axis/oasis/ping/PingBindingImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/interop/org/apache/ws/axis/oasis/ping/PingBindingImpl.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/interop/org/apache/ws/axis/oasis/ping/PingBindingImpl.java (original)
+++ webservices/wss4j/trunk/interop/org/apache/ws/axis/oasis/ping/PingBindingImpl.java Wed Sep 24 06:59:05 2008
@@ -33,24 +33,25 @@
import org.apache.ws.security.handler.WSHandlerResult;
import javax.xml.rpc.holders.StringHolder;
+import java.security.Principal;
import java.util.Vector;
public class PingBindingImpl
implements org.apache.ws.axis.oasis.ping.PingPort {
+
public void ping(
- org.apache.ws.axis.oasis.ping.TicketType pingTicket,
- StringHolder text)
- throws java.rmi.RemoteException {
+ org.apache.ws.axis.oasis.ping.TicketType pingTicket,
+ StringHolder text
+ ) throws java.rmi.RemoteException {
MessageContext msgContext = MessageContext.getCurrentContext();
Message reqMsg = msgContext.getRequestMessage();
- Vector results = null;
- if ((results =
- (Vector) msgContext.getProperty(WSHandlerConstants.RECV_RESULTS))
- == null) {
+ Vector results =
+ (Vector) msgContext.getProperty(WSHandlerConstants.RECV_RESULTS);
+ if (results == null) {
System.out.println("No security results!!");
}
- System.out.println("Number of results: " + results.size());
+ // System.out.println("Number of results: " + results.size());
for (int i = 0; i < results.size(); i++) {
WSHandlerResult rResult =
(WSHandlerResult) results.get(i);
@@ -59,8 +60,12 @@
for (int j = 0; j < wsSecEngineResults.size(); j++) {
WSSecurityEngineResult wser =
(WSSecurityEngineResult) wsSecEngineResults.get(j);
- if (wser.getAction() != WSConstants.ENCR && wser.getPrincipal() != null) {
- System.out.println(wser.getPrincipal().getName());
+ int action =
+ ((java.lang.Integer)wser.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
+ Principal principal =
+ (Principal)wser.get(WSSecurityEngineResult.TAG_PRINCIPAL);
+ if (action != WSConstants.ENCR && principal != null) {
+ // System.out.println(principal.getName());
}
}
}
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/SOAP11Constants.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/SOAP11Constants.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/SOAP11Constants.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/SOAP11Constants.java Wed Sep 24 06:59:05 2008
@@ -60,10 +60,18 @@
}
/**
- * Obtain the Mustunderstand string
+ * Obtain the MustUnderstand string
*/
- public String getMustunderstand() {
+ public String getMustUnderstand() {
return "1";
}
+
+ /**
+ * Obtain the MustUnderstand string
+ * @deprecated use getMustUnderstand() instead
+ */
+ public String getMustunderstand() {
+ return getMustUnderstand();
+ }
}
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/SOAP12Constants.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/SOAP12Constants.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/SOAP12Constants.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/SOAP12Constants.java Wed Sep 24 06:59:05 2008
@@ -67,10 +67,18 @@
}
/**
- * Obtain the Mustunderstand string
+ * Obtain the MustUnderstand string
*/
- public String getMustunderstand() {
+ public String getMustUnderstand() {
return "true";
}
+
+ /**
+ * Obtain the MustUnderstand string
+ * @deprecated use getMustUnderstand() instead
+ */
+ public String getMustunderstand() {
+ return getMustUnderstand();
+ }
}
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/SOAPConstants.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/SOAPConstants.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/SOAPConstants.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/SOAPConstants.java Wed Sep 24 06:59:05 2008
@@ -70,6 +70,14 @@
/**
* Obtain the "next" role/actor URI
*/
+ public String getMustUnderstand();
+
+ /**
+ * Obtain the "next" role/actor URI
+ * @deprecated use getMustUnderstand() instead
+ */
public String getMustunderstand();
+
+
}
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/WSPasswordCallback.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/WSPasswordCallback.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSPasswordCallback.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSPasswordCallback.java Wed Sep 24 06:59:05 2008
@@ -111,11 +111,22 @@
*
* @return The identifier
*/
- public String getIdentifer() {
+ public String getIdentifier() {
return identifier;
}
/**
+ * Get the identifier.
+ * <p/>
+ *
+ * @return The identifier
+ * @deprecated use getIdentifier() instead
+ */
+ public String getIdentifer() {
+ return getIdentifier();
+ }
+
+ /**
* Extended callback interface allows for setting the username as well.
* Callback functions can change the identifier, this is intended in the usernametoken scenario
* where the usernametoken denotes the identity, but a fixed identity for signing is used
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/action/UsernameTokenAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/action/UsernameTokenAction.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/action/UsernameTokenAction.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/action/UsernameTokenAction.java Wed Sep 24 06:59:05 2008
@@ -35,7 +35,7 @@
actionToDo,
WSHandlerConstants.PW_CALLBACK_CLASS,
WSHandlerConstants.PW_CALLBACK_REF, reqData);
- providedUsername = callbackData.getIdentifer();
+ providedUsername = callbackData.getIdentifier();
String password = callbackData.getPassword();
WSSecUsernameToken builder = new WSSecUsernameToken();
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java Wed Sep 24 06:59:05 2008
@@ -1,19 +1,19 @@
/*
-* Copyright 2003-2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-*/
+ * Copyright 2003-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
package org.apache.ws.security.handler;
import org.apache.commons.logging.Log;
@@ -29,6 +29,7 @@
import org.apache.ws.security.components.crypto.Crypto;
import org.apache.ws.security.components.crypto.CryptoFactory;
import org.apache.ws.security.message.WSSecHeader;
+import org.apache.ws.security.message.token.SignatureConfirmation;
import org.apache.ws.security.message.token.Timestamp;
import org.apache.ws.security.util.Loader;
import org.apache.ws.security.util.StringUtil;
@@ -66,21 +67,24 @@
private boolean doDebug = log.isDebugEnabled();
- /** ut
+ /**
* Performs all defined security actions to set-up the SOAP request.
*
*
* @param doAction a set defining the actions to do
* @param doc the request as DOM document
- * @param reqData a data storage to pass values around bewteen methods
+ * @param reqData a data storage to pass values around between methods
* @param actions a vector holding the actions to do in the order defined
* in the deployment file or property
* @throws WSSecurityException
*/
- protected void doSenderAction(int doAction, Document doc,
- RequestData reqData, Vector actions,
- boolean isRequest)
- throws WSSecurityException {
+ protected void doSenderAction(
+ int doAction,
+ Document doc,
+ RequestData reqData,
+ Vector actions,
+ boolean isRequest
+ ) throws WSSecurityException {
boolean mu = decodeMustUnderstand(reqData);
@@ -88,12 +92,12 @@
if (wssConfig == null) {
wssConfig = WSSConfig.getNewInstance();
}
-
+
wssConfig
- .setEnableSignatureConfirmation(decodeEnableSignatureConfirmation(reqData));
-
+ .setEnableSignatureConfirmation(decodeEnableSignatureConfirmation(reqData));
+
wssConfig
- .setPrecisionInMilliSeconds(decodeTimestampPrecision(reqData));
+ .setPrecisionInMilliSeconds(decodeTimestampPrecision(reqData));
reqData.setWssConfig(wssConfig);
Object mc = reqData.getMsgContext();
@@ -102,7 +106,7 @@
WSSecHeader secHeader = new WSSecHeader(actor, mu);
secHeader.insertSecurityHeader(doc);
-
+
reqData.setSecHeader(secHeader);
reqData.setSoapConstants(WSSecurityUtil.getSOAPConstants(doc
.getDocumentElement()));
@@ -159,7 +163,7 @@
}
/*
* If SignatureConfirmation is enabled and this is a reqsponse then
- * insert SignatureCOnfrmation elements, note their wsu:id in the signature
+ * insert SignatureConfrmation elements, note their wsu:id in the signature
* parts. They will be signed automatically during a (probably) defined
* SIGN action.
*/
@@ -168,8 +172,7 @@
if ((done = (String) getProperty(reqData.getMsgContext(),
WSHandlerConstants.SIG_CONF_DONE)) == null
|| !DONE.equals(done)) {
- Vector results = null;
- if ((results = (Vector) getProperty(reqData.getMsgContext(),
+ if ((getProperty(reqData.getMsgContext(),
WSHandlerConstants.RECV_RESULTS)) != null) {
wssConfig.getAction(WSConstants.SC).execute(this, WSConstants.SC, doc, reqData);
}
@@ -187,36 +190,36 @@
}
switch (actionToDo) {
- case WSConstants.UT:
- case WSConstants.ENCR:
- case WSConstants.SIGN:
- case WSConstants.ST_SIGNED:
- case WSConstants.ST_UNSIGNED:
- case WSConstants.TS:
- case WSConstants.UT_SIGN:
- wssConfig.getAction(actionToDo).execute(this, actionToDo, doc, reqData);
- break;
- case WSConstants.NO_SERIALIZE:
- reqData.setNoSerialization(true);
- break;
+ case WSConstants.UT:
+ case WSConstants.ENCR:
+ case WSConstants.SIGN:
+ case WSConstants.ST_SIGNED:
+ case WSConstants.ST_UNSIGNED:
+ case WSConstants.TS:
+ case WSConstants.UT_SIGN:
+ wssConfig.getAction(actionToDo).execute(this, actionToDo, doc, reqData);
+ break;
+ case WSConstants.NO_SERIALIZE:
+ reqData.setNoSerialization(true);
+ break;
//
// Handle any "custom" actions, similarly,
// but to preserve behavior from previous
// versions, consume (but log) action lookup failures.
//
- default:
- Action doit = null;
- try {
- doit = wssConfig.getAction(actionToDo);
- } catch (final WSSecurityException e) {
- log.warn(
- "Error trying to locate a custom action (" + actionToDo + ")",
- e
- );
- }
- if (doit != null) {
- doit.execute(this, actionToDo, doc, reqData);
- }
+ default:
+ Action doit = null;
+ try {
+ doit = wssConfig.getAction(actionToDo);
+ } catch (final WSSecurityException e) {
+ log.warn(
+ "Error trying to locate a custom action (" + actionToDo + ")",
+ e
+ );
+ }
+ if (doit != null) {
+ doit.execute(this, actionToDo, doc, reqData);
+ }
}
}
/*
@@ -242,12 +245,12 @@
- protected void doReceiverAction(int doAction, RequestData reqData)
- throws WSSecurityException {
+ protected void doReceiverAction(int doAction, RequestData reqData)
+ throws WSSecurityException {
WSSConfig wssConfig = WSSConfig.getNewInstance();
wssConfig
- .setEnableSignatureConfirmation(decodeEnableSignatureConfirmation(reqData));
+ .setEnableSignatureConfirmation(decodeEnableSignatureConfirmation(reqData));
wssConfig.setTimeStampStrict(decodeTimestampStrict(reqData));
wssConfig.setHandleCustomPasswordTypes(decodeCustomPasswordTypes(reqData));
reqData.setWssConfig(wssConfig);
@@ -280,28 +283,28 @@
return false;
}
}
-
+
if (ai != size) {
return false;
}
-
+
return true;
}
protected void checkSignatureConfirmation(RequestData reqData,
- Vector wsResult) throws WSSecurityException{
+ Vector wsResult) throws WSSecurityException{
if (doDebug) {
log.debug("Check Signature confirmation");
}
/*
- * First get all Signature value stored during sending the request
- */
+ * First get all Signature value stored during sending the request
+ */
Vector sigv = (Vector) getProperty(reqData.getMsgContext(),
WSHandlerConstants.SEND_SIGV);
/*
* Now get all results that hold a SignatureConfirmation element from
- * the current run of receiver (we can have mor than on run: if we
+ * the current run of receiver (we can have more than one run: if we
* have several security header blocks with different actors/roles)
*/
Vector sigConf = new Vector();
@@ -309,12 +312,17 @@
/*
* now loop over all SignatureConfirmation results and check:
* - if there is a signature value and no Signature value generated in request: error
- * - if there is a signature value and no machting Signature value found: error
+ * - if there is a signature value and no matching Signature value found: error
*
* If a matching value found: remove from vector of stored signature values
*/
for (int i = 0; i < sigConf.size(); i++) {
- byte[] sigVal = ((WSSecurityEngineResult)sigConf.get(i)).getSigConf().getSignatureValue();
+ WSSecurityEngineResult result =
+ (WSSecurityEngineResult)sigConf.get(i);
+ SignatureConfirmation sc =
+ (SignatureConfirmation)result.get(WSSecurityEngineResult.TAG_SIGNATURE_CONFIRMATION);
+
+ byte[] sigVal = sc.getSignatureValue();
if (sigVal != null) {
if (sigv == null || sigv.size() == 0) {
//If there are no store signature values
@@ -337,16 +345,16 @@
}
if (!found) {
throw new WSSecurityException(
- "WSHandler: Check Signature confirmation: got SC element, but no matching SV");
+ "WSHandler: Check Signature confirmation: got SC element, but no matching SV");
}
}
}
}
/*
- * This indicates this is the last handler: the vector holding the
- * stored Signature values must be empty, otherwise we have an error
- */
+ * This indicates this is the last handler: the vector holding the
+ * stored Signature values must be empty, otherwise we have an error
+ */
if (!reqData.isNoSerialization()) {
log.debug("Check Signature confirmation - last handler");
if (sigv != null && !sigv.isEmpty()) {
@@ -359,14 +367,14 @@
* fit.
*/
public Crypto loadSignatureCrypto(RequestData reqData)
- throws WSSecurityException {
+ throws WSSecurityException {
Crypto crypto = null;
/*
- * Get crypto property file for signature. If none specified throw
- * fault, otherwise get a crypto instance.
- */
+ * Get crypto property file for signature. If none specified throw
+ * fault, otherwise get a crypto instance.
+ */
String sigPropFile = getString(WSHandlerConstants.SIG_PROP_FILE,
- reqData.getMsgContext());
+ reqData.getMsgContext());
if (sigPropFile != null) {
if ((crypto = (Crypto) cryptos.get(sigPropFile)) == null) {
crypto = CryptoFactory.getInstance(sigPropFile, this
@@ -390,13 +398,13 @@
}
} else {
throw new WSSecurityException(
- "WSHandler: Signature: signaturePropRefId must hold a " +
- "java.util.Properties object");
+ "WSHandler: Signature: signaturePropRefId must hold a " +
+ "java.util.Properties object");
}
}
} else {
throw new WSSecurityException(
- "WSHandler: Signature: no crypto properties");
+ "WSHandler: Signature: no crypto properties");
}
return crypto;
}
@@ -406,14 +414,14 @@
* see fit.
*/
protected Crypto loadEncryptionCrypto(RequestData reqData)
- throws WSSecurityException {
+ throws WSSecurityException {
Crypto crypto = null;
/*
- * Get encryption crypto property file. If non specified take crypto
- * instance from signature, if that fails: throw fault
- */
+ * Get encryption crypto property file. If non specified take crypto
+ * instance from signature, if that fails: throw fault
+ */
String encPropFile = getString(WSHandlerConstants.ENC_PROP_FILE,
- reqData.getMsgContext());
+ reqData.getMsgContext());
if (encPropFile != null) {
if ((crypto = (Crypto) cryptos.get(encPropFile)) == null) {
crypto = CryptoFactory.getInstance(encPropFile, this
@@ -437,33 +445,33 @@
}
} else {
throw new WSSecurityException(
- "WSHandler: Encryption: encryptionPropRefId must hold a" +
- " java.util.Properties object");
+ "WSHandler: Encryption: encryptionPropRefId must hold a" +
+ " java.util.Properties object");
}
}
} else if ((crypto = reqData.getSigCrypto()) == null) {
throw new WSSecurityException(
- "WSHandler: Encryption: no crypto property file");
+ "WSHandler: Encryption: no crypto property file");
}
return crypto;
}
protected void decodeUTParameter(RequestData reqData)
- throws WSSecurityException {
- Object mc = reqData.getMsgContext();
+ throws WSSecurityException {
+ Object mc = reqData.getMsgContext();
String type = getString(WSHandlerConstants.PASSWORD_TYPE, mc);
if (type != null) {
- if(WSConstants.PW_TEXT.equals(type)) {
- reqData.setPwType(WSConstants.PASSWORD_TEXT);
- } else if(WSConstants.PW_DIGEST.equals(type)) {
- reqData.setPwType(WSConstants.PASSWORD_DIGEST);
- } else if(WSConstants.PW_NONE.equals(type)) {
- // No password requested.
- reqData.setPwType(null);
- } else {
- throw new WSSecurityException("Unknown password type encoding: " + type);
- }
+ if(WSConstants.PW_TEXT.equals(type)) {
+ reqData.setPwType(WSConstants.PASSWORD_TEXT);
+ } else if(WSConstants.PW_DIGEST.equals(type)) {
+ reqData.setPwType(WSConstants.PASSWORD_DIGEST);
+ } else if(WSConstants.PW_NONE.equals(type)) {
+ // No password requested.
+ reqData.setPwType(null);
+ } else {
+ throw new WSSecurityException("Unknown password type encoding: " + type);
+ }
}
String add = getString(WSHandlerConstants.ADD_UT_ELEMENTS, mc);
@@ -473,23 +481,23 @@
}
protected void decodeSignatureParameter(RequestData reqData)
- throws WSSecurityException {
- Object mc = reqData.getMsgContext();
+ throws WSSecurityException {
+ Object mc = reqData.getMsgContext();
String keyId = getString(WSHandlerConstants.SIG_KEY_ID, mc);
if (keyId != null) {
Integer id = (Integer) WSHandlerConstants.keyIdentifier.get(keyId);
if (id == null) {
throw new WSSecurityException(
- "WSHandler: Signature: unknown key identification");
+ "WSHandler: Signature: unknown key identification");
}
int tmp = id.intValue();
if (!(tmp == WSConstants.ISSUER_SERIAL
- || tmp == WSConstants.BST_DIRECT_REFERENCE
- || tmp == WSConstants.X509_KEY_IDENTIFIER
- || tmp == WSConstants.SKI_KEY_IDENTIFIER
- || tmp == WSConstants.THUMBPRINT_IDENTIFIER)) {
+ || tmp == WSConstants.BST_DIRECT_REFERENCE
+ || tmp == WSConstants.X509_KEY_IDENTIFIER
+ || tmp == WSConstants.SKI_KEY_IDENTIFIER
+ || tmp == WSConstants.THUMBPRINT_IDENTIFIER)) {
throw new WSSecurityException(
- "WSHandler: Signature: illegal key identification");
+ "WSHandler: Signature: illegal key identification");
}
reqData.setSigKeyId(tmp);
}
@@ -503,54 +511,54 @@
}
protected void decodeEncryptionParameter(RequestData reqData)
- throws WSSecurityException {
- Object mc = reqData.getMsgContext();
+ throws WSSecurityException {
+ Object mc = reqData.getMsgContext();
String encUser = getString(WSHandlerConstants.ENCRYPTION_USER, mc);
-
+
if (encUser != null) {
- reqData.setEncUser(encUser);
+ reqData.setEncUser(encUser);
} else {
reqData.setEncUser(reqData.getUsername());
- }
+ }
if (reqData.getEncUser() == null) {
- throw new WSSecurityException("WSHandler: Encryption: no username");
+ throw new WSSecurityException("WSHandler: Encryption: no username");
}
/*
- * String msgType = msgContext.getCurrentMessage().getMessageType(); if
- * (msgType != null && msgType.equals(Message.RESPONSE)) {
- * handleSpecialUser(encUser); }
- */
+ * String msgType = msgContext.getCurrentMessage().getMessageType(); if
+ * (msgType != null && msgType.equals(Message.RESPONSE)) {
+ * handleSpecialUser(encUser); }
+ */
handleSpecialUser(reqData);
-
+
/*
- * If the following parameters are no used (they return null) then the
- * default values of WSS4J are used.
- */
+ * If the following parameters are no used (they return null) then the
+ * default values of WSS4J are used.
+ */
String encKeyId = getString(WSHandlerConstants.ENC_KEY_ID, mc);
if (encKeyId != null) {
Integer id = (Integer) WSHandlerConstants
- .keyIdentifier.get(encKeyId);
+ .keyIdentifier.get(encKeyId);
if (id == null) {
throw new WSSecurityException(
- "WSHandler: Encryption: unknown key identification");
+ "WSHandler: Encryption: unknown key identification");
}
int tmp = id.intValue();
- reqData.setEncKeyId(tmp);
- if (!(tmp == WSConstants.ISSUER_SERIAL
- || tmp == WSConstants.X509_KEY_IDENTIFIER
- || tmp == WSConstants.SKI_KEY_IDENTIFIER
- || tmp == WSConstants.BST_DIRECT_REFERENCE
- || tmp == WSConstants.EMBEDDED_KEYNAME
- || tmp == WSConstants.THUMBPRINT_IDENTIFIER)) {
+ reqData.setEncKeyId(tmp);
+ if (!(tmp == WSConstants.ISSUER_SERIAL
+ || tmp == WSConstants.X509_KEY_IDENTIFIER
+ || tmp == WSConstants.SKI_KEY_IDENTIFIER
+ || tmp == WSConstants.BST_DIRECT_REFERENCE
+ || tmp == WSConstants.EMBEDDED_KEYNAME
+ || tmp == WSConstants.THUMBPRINT_IDENTIFIER)) {
throw new WSSecurityException(
- "WSHandler: Encryption: illegal key identification");
+ "WSHandler: Encryption: illegal key identification");
}
- }
+ }
String encSymAlgo = getString(WSHandlerConstants.ENC_SYM_ALGO, mc);
reqData.setEncSymmAlgo(encSymAlgo);
String encKeyTransport
- = getString(WSHandlerConstants.ENC_KEY_TRANSPORT, mc);
+ = getString(WSHandlerConstants.ENC_KEY_TRANSPORT, mc);
reqData.setEncKeyTransport(encKeyTransport);
String encParts = getString(WSHandlerConstants.ENCRYPTION_PARTS, mc);
@@ -560,22 +568,22 @@
}
protected boolean decodeMustUnderstand(RequestData reqData)
- throws WSSecurityException {
+ throws WSSecurityException {
String mu = getString(WSHandlerConstants.MUST_UNDERSTAND,
- reqData.getMsgContext());
+ reqData.getMsgContext());
if (mu == null) {return true;}
- if ("0".equals(mu) || "false".equals(mu)) {return false;}
- if ("1".equals(mu) || "true".equals(mu)) {return true;}
+ if ("0".equals(mu) || "false".equals(mu)) {return false;}
+ if ("1".equals(mu) || "true".equals(mu)) {return true;}
- throw new WSSecurityException(
- "WSHandler: illegal mustUnderstand parameter");
+ throw new WSSecurityException(
+ "WSHandler: illegal mustUnderstand parameter");
}
public int decodeTimeToLive(RequestData reqData) {
String ttl = getString(WSHandlerConstants.TTL_TIMESTAMP,
- reqData.getMsgContext());
+ reqData.getMsgContext());
int ttl_i = 0;
if (ttl != null) {
try {
@@ -589,38 +597,37 @@
}
return ttl_i;
}
-
+
protected boolean decodeEnableSignatureConfirmation(RequestData reqData) throws WSSecurityException {
- String value = getString(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION,
- reqData.getMsgContext());
+ String value = getString(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION,
+ reqData.getMsgContext());
- if (value == null) {return true;}
+ if (value == null) {return true;}
- if ("0".equals(value) || "false".equals(value)) {return false;}
- if ("1".equals(value) || "true".equals(value)) {return true;}
+ if ("0".equals(value) || "false".equals(value)) {return false;}
+ if ("1".equals(value) || "true".equals(value)) {return true;}
- throw new WSSecurityException(
- "WSHandler: illegal enableSignatureConfirmation parameter");
- }
+ throw new WSSecurityException(
+ "WSHandler: illegal enableSignatureConfirmation parameter");
+ }
protected boolean decodeTimestampPrecision(RequestData reqData)
- throws WSSecurityException {
- boolean precisionInMilliSeconds = true;
+ throws WSSecurityException {
String value = getString(WSHandlerConstants.TIMESTAMP_PRECISION,
- reqData.getMsgContext());
+ reqData.getMsgContext());
if (value == null) {return true;}
- if ("0".equals(value) || "false".equals(value)) {return false;}
- if ("1".equals(value) || "true".equals(value)) {return true;}
+ if ("0".equals(value) || "false".equals(value)) {return false;}
+ if ("1".equals(value) || "true".equals(value)) {return true;}
- throw new WSSecurityException(
- "WSHandler: illegal precisionInMilliSeconds parameter");
+ throw new WSSecurityException(
+ "WSHandler: illegal precisionInMilliSeconds parameter");
}
-
+
protected boolean decodeCustomPasswordTypes(RequestData reqData)
- throws WSSecurityException {
+ throws WSSecurityException {
String value = getString(
WSHandlerConstants.HANDLE_CUSTOM_PASSWORD_TYPES,
reqData.getMsgContext()
@@ -630,37 +637,36 @@
if ("0".equals(value) || "false".equals(value)) {return false;}
if ("1".equals(value) || "true".equals(value)) {return true;}
-
+
throw new WSSecurityException(
- "WSHandler: illegal handleCustomPasswordTypes parameter");
+ "WSHandler: illegal handleCustomPasswordTypes parameter");
}
protected boolean decodeTimestampStrict(RequestData reqData)
- throws WSSecurityException {
- boolean precisionInMilliSeconds = true;
+ throws WSSecurityException {
String value = getString(WSHandlerConstants.TIMESTAMP_STRICT,
- reqData.getMsgContext());
+ reqData.getMsgContext());
if (value == null) {return true;}
- if ("0".equals(value) || "false".equals(value)) {return false;}
- if ("1".equals(value) || "true".equals(value)) {return true;}
+ if ("0".equals(value) || "false".equals(value)) {return false;}
+ if ("1".equals(value) || "true".equals(value)) {return true;}
- throw new WSSecurityException(
- "WSHandler: illegal timestampStrict parameter");
+ throw new WSSecurityException(
+ "WSHandler: illegal timestampStrict parameter");
}
-
+
/**
* Get a password to construct a UsernameToken or sign a message.
* <p/>
* Try all possible sources to get a password.
*/
public WSPasswordCallback getPassword(String username,
- int doAction,
- String clsProp,
- String refProp,
- RequestData reqData)
- throws WSSecurityException {
+ int doAction,
+ String clsProp,
+ String refProp,
+ RequestData reqData)
+ throws WSSecurityException {
WSPasswordCallback pwCb = null;
CallbackHandler cbHandler = null;
String err = "provided null or empty password";
@@ -685,12 +691,12 @@
}
return pwCb;
}
-
+
private WSPasswordCallback readPwViaCallbackClass(String callback,
- String username,
- int doAction,
- RequestData requestData)
- throws WSSecurityException {
+ String username,
+ int doAction,
+ RequestData requestData)
+ throws WSSecurityException {
Class cbClass = null;
CallbackHandler cbHandler = null;
@@ -720,16 +726,16 @@
* name.
*/
private WSPasswordCallback performCallback(CallbackHandler cbHandler,
- String username,
- int doAction)
- throws WSSecurityException {
+ String username,
+ int doAction)
+ throws WSSecurityException {
WSPasswordCallback pwCb = constructPasswordCallback(username, doAction);
Callback[] callbacks = new Callback[1];
callbacks[0] = pwCb;
/*
- * Call back the application to get the password
- */
+ * Call back the application to get the password
+ */
try {
cbHandler.handle(callbacks);
} catch (Exception e) {
@@ -737,14 +743,14 @@
}
return pwCb;
}
-
+
private WSPasswordCallback constructPasswordCallback(
- String username,
- int doAction
+ String username,
+ int doAction
) throws WSSecurityException {
-
+
int reason = WSPasswordCallback.UNKNOWN;
-
+
switch (doAction) {
case WSConstants.UT:
case WSConstants.UT_SIGN:
@@ -761,7 +767,7 @@
}
private void splitEncParts(String tmpS, Vector parts, RequestData reqData)
- throws WSSecurityException {
+ throws WSSecurityException {
WSEncryptionPart encPart = null;
String[] rawParts = StringUtil.split(tmpS, ';');
@@ -773,9 +779,9 @@
log.debug("single partDef: '" + partDef[0] + "'");
}
encPart =
- new WSEncryptionPart(partDef[0].trim(),
- reqData.getSoapConstants().getEnvelopeURI(),
- "Content");
+ new WSEncryptionPart(partDef[0].trim(),
+ reqData.getSoapConstants().getEnvelopeURI(),
+ "Content");
} else if (partDef.length == 3) {
String mode = partDef[0].trim();
if (mode.length() <= 1) {
@@ -816,30 +822,30 @@
}
Vector results = null;
if ((results =
- (Vector) getProperty(reqData.getMsgContext(), WSHandlerConstants.RECV_RESULTS))
- == null) {
+ (Vector) getProperty(reqData.getMsgContext(), WSHandlerConstants.RECV_RESULTS))
+ == null) {
return;
}
/*
- * Scan the results for a matching actor. Use results only if the
- * receiving Actor and the sending Actor match.
- */
+ * Scan the results for a matching actor. Use results only if the
+ * receiving Actor and the sending Actor match.
+ */
for (int i = 0; i < results.size(); i++) {
WSHandlerResult rResult =
- (WSHandlerResult) results.get(i);
+ (WSHandlerResult) results.get(i);
String hActor = rResult.getActor();
if (!WSSecurityUtil.isActorEqual(reqData.getActor(), hActor)) {
continue;
}
Vector wsSecEngineResults = rResult.getResults();
/*
- * Scan the results for the first Signature action. Use the
- * certificate of this Signature to set the certificate for the
- * encryption action :-).
- */
+ * Scan the results for the first Signature action. Use the
+ * certificate of this Signature to set the certificate for the
+ * encryption action :-).
+ */
for (int j = 0; j < wsSecEngineResults.size(); j++) {
WSSecurityEngineResult wser =
- (WSSecurityEngineResult) wsSecEngineResults.get(j);
+ (WSSecurityEngineResult) wsSecEngineResults.get(j);
if (wser.getAction() == WSConstants.SIGN) {
reqData.setEncCert(wser.getCertificate());
return;
@@ -853,11 +859,11 @@
* see fit.
*/
protected Crypto loadDecryptionCrypto(RequestData reqData)
- throws WSSecurityException {
+ throws WSSecurityException {
Crypto crypto = null;
String decPropFile = getString(WSHandlerConstants.DEC_PROP_FILE,
- reqData.getMsgContext());
+ reqData.getMsgContext());
if (decPropFile != null) {
if ((crypto = (Crypto) cryptos.get(decPropFile)) == null) {
crypto = CryptoFactory.getInstance(decPropFile, this
@@ -881,40 +887,40 @@
}
} else {
throw new WSSecurityException(
- "WSHandler: Decrytion: decryptionPropRefId must hold a" +
- " java.util.Properties object");
+ "WSHandler: Decrytion: decryptionPropRefId must hold a" +
+ " java.util.Properties object");
}
}
} else if ((crypto = reqData.getSigCrypto()) == null) {
throw new WSSecurityException(
- "WSHandler: Encryption: no crypto property file");
+ "WSHandler: Encryption: no crypto property file");
}
return crypto;
}
protected void decodeSignatureParameter2(RequestData reqData)
- throws WSSecurityException {
+ throws WSSecurityException {
reqData.setSigCrypto(loadSignatureCrypto(reqData));
/* There are currently no other signature parameters that need
- * to be handled here, but we call the load crypto hook rather
- * than just changing the visibility
- * of this method to maintain parity with WSDoAllSender.
- */
+ * to be handled here, but we call the load crypto hook rather
+ * than just changing the visibility
+ * of this method to maintain parity with WSDoAllSender.
+ */
}
/*
* Set and check the decryption specific parameters, if necessary
- * take over signatur crypto instance.
+ * take over signature crypto instance.
*/
protected void decodeDecryptionParameter(RequestData reqData)
- throws WSSecurityException {
+ throws WSSecurityException {
reqData.setDecCrypto(loadDecryptionCrypto(reqData));
/* There are currently no other decryption parameters that need
- * to be handled here, but we call the load crypto hook rather
- * than just changing the visibility
- * of this method to maintain parity with WSDoAllSender.
- */
+ * to be handled here, but we call the load crypto hook rather
+ * than just changing the visibility
+ * of this method to maintain parity with WSDoAllSender.
+ */
}
/**
@@ -922,9 +928,9 @@
* <p/>
*/
protected CallbackHandler getPasswordCB(RequestData reqData)
- throws WSSecurityException {
+ throws WSSecurityException {
- Object mc = reqData.getMsgContext();
+ Object mc = reqData.getMsgContext();
CallbackHandler cbHandler = null;
String callback = getString(WSHandlerConstants.PW_CALLBACK_CLASS, mc);
if (callback != null) {
@@ -934,22 +940,22 @@
.getMsgContext()), callback);
} catch (ClassNotFoundException e) {
throw new WSSecurityException(
- "WSHandler: cannot load password callback class: "
- + callback, e);
+ "WSHandler: cannot load password callback class: "
+ + callback, e);
}
try {
cbHandler = (CallbackHandler) cbClass.newInstance();
} catch (java.lang.Exception e) {
throw new WSSecurityException(
- "WSHandler: cannot create instance of password callback: "
- + callback, e);
+ "WSHandler: cannot create instance of password callback: "
+ + callback, e);
}
} else {
cbHandler = (CallbackHandler) getProperty(mc,
- WSHandlerConstants.PW_CALLBACK_REF);
+ WSHandlerConstants.PW_CALLBACK_REF);
if (cbHandler == null) {
throw new WSSecurityException(
- "WSHandler: no reference in callback property");
+ "WSHandler: no reference in callback property");
}
}
return cbHandler;
@@ -1093,24 +1099,24 @@
}
/**
- * Evaluate whether a timestamp is considered valid on receiverside. Hook to
- * allow subclasses to implement custom validation methods however they see
- * fit.
- *
- * Policy used in this implementation:
- *
- * 1. The receiver can set its own time to live (besides from that set on
- * sender side)
- *
- * 2. If the message was created before (now-ttl) the message is rejected
- *
- * @param timestamp
- * the timestamp that is validated
- * @param timeToLive
- * the limit on receiverside, the timestamp is validated against
- * @return true if the timestamp is before (now-timeToLive), false otherwise
- * @throws WSSecurityException
- */
+ * Evaluate whether a timestamp is considered valid on receiverside. Hook to
+ * allow subclasses to implement custom validation methods however they see
+ * fit.
+ *
+ * Policy used in this implementation:
+ *
+ * 1. The receiver can set its own time to live (besides from that set on
+ * sender side)
+ *
+ * 2. If the message was created before (now-ttl) the message is rejected
+ *
+ * @param timestamp
+ * the timestamp that is validated
+ * @param timeToLive
+ * the limit on receiverside, the timestamp is validated against
+ * @return true if the timestamp is before (now-timeToLive), false otherwise
+ * @throws WSSecurityException
+ */
protected boolean verifyTimestamp(Timestamp timestamp, int timeToLive) throws WSSecurityException {
// Calculate the time that is allowed for the message to travel
@@ -1120,17 +1126,17 @@
validCreation.setTime(new Date(currentTime));
if (doDebug) {
- log.debug("Preparing to verify the timestamp");
- DateFormat zulu = new XmlSchemaDateFormat();
- log.debug("Validation of Timestamp: Current time is "
- + zulu.format(Calendar.getInstance().getTime()));
- log.debug("Validation of Timestamp: Valid creation is "
- + zulu.format(validCreation.getTime()));
- if (timestamp.getCreated() != null) {
- log.debug("Validation of Timestamp: Timestamp created is "
- + zulu.format(timestamp.getCreated().getTime()));
- }
- }
+ log.debug("Preparing to verify the timestamp");
+ DateFormat zulu = new XmlSchemaDateFormat();
+ log.debug("Validation of Timestamp: Current time is "
+ + zulu.format(Calendar.getInstance().getTime()));
+ log.debug("Validation of Timestamp: Valid creation is "
+ + zulu.format(validCreation.getTime()));
+ if (timestamp.getCreated() != null) {
+ log.debug("Validation of Timestamp: Timestamp created is "
+ + zulu.format(timestamp.getCreated().getTime()));
+ }
+ }
// Validate the time it took the message to travel
// if (timestamp.getCreated().before(validCreation) ||
// !timestamp.getCreated().equals(validCreation)) {
@@ -1143,11 +1149,11 @@
}
if (doDebug) {
- log.debug("Validation of Timestamp: Everything is ok");
+ log.debug("Validation of Timestamp: Everything is ok");
}
return true;
}
-
+
/**
* Looks up key first via {@link #getOption(String)} and if not found
* there, via {@link #getProperty(Object, String)}
@@ -1158,18 +1164,18 @@
* @throws IllegalArgumentException if <code>key</code> is null.
*/
public String getString(String key, Object mc) {
- if (key == null) {
- throw new IllegalArgumentException("Key cannot be null");
- }
+ if (key == null) {
+ throw new IllegalArgumentException("Key cannot be null");
+ }
String s = getStringOption(key);
- if (s != null) {
- return s;
- }
- if (mc == null) {
- throw new
- IllegalArgumentException("Message context cannot be null");
- }
- return (String) getProperty(mc, key);
+ if (s != null) {
+ return s;
+ }
+ if (mc == null) {
+ throw new
+ IllegalArgumentException("Message context cannot be null");
+ }
+ return (String) getProperty(mc, key);
}
@@ -1182,26 +1188,26 @@
*/
public String getStringOption(String key) {
Object o = getOption(key);
- if (o instanceof String){
- return (String) o;
- } else {
- return null;
- }
- }
-
-// /**
-// * Returns the classloader to be used for loading the callback class
-// *
-// * @return class loader
-// */
-// public ClassLoader getClassLoader() {
-// try {
-// return Loader.getTCL();
-// } catch (Throwable t) {
-// return null;
-// }
-// }
-
+ if (o instanceof String){
+ return (String) o;
+ } else {
+ return null;
+ }
+ }
+
+// /**
+// * Returns the classloader to be used for loading the callback class
+// *
+// * @return class loader
+// */
+// public ClassLoader getClassLoader() {
+// try {
+// return Loader.getTCL();
+// } catch (Throwable t) {
+// return null;
+// }
+// }
+
/**
* Returns the classloader to be used for loading the callback class
* @param msgCtx The MessageContext
@@ -1214,12 +1220,12 @@
return null;
}
}
-
+
public abstract Object getOption(String key);
public abstract Object getProperty(Object msgContext, String key);
public abstract void setProperty(Object msgContext, String key,
- Object value);
+ Object value);
public abstract String getPassword(Object msgContext);
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java Wed Sep 24 06:59:05 2008
@@ -122,7 +122,7 @@
}
/**
- * Switch for transfering control to doReceiver and doSender
+ * Switch for transferring control to doReceiver and doSender
*/
public boolean processMessage(MessageContext mc, boolean isRequestMessage) throws WSSecurityException {
@@ -209,7 +209,7 @@
/*
* Now we perform some set-up for UsernameToken and Signature
* functions. No need to do it for encryption only. Check if username
- * is available and then get a passowrd.
+ * is available and then get a password.
*/
if ((doAction & (WSConstants.SIGN | WSConstants.UT | WSConstants.UT_SIGN)) != 0) {
/*
@@ -233,7 +233,7 @@
*
* During the FORM_STRING serialization Axis performs multi-ref of
* complex data types (if requested), generates and inserts references
- * for attachements and so on. The resulting Document MUST be the
+ * for attachments and so on. The resulting Document MUST be the
* complete and final SOAP request as Axis would send it over the wire.
* Therefore this must shall be the last (or only) handler in a chain.
*
@@ -457,7 +457,8 @@
WSSecurityEngineResult actionResult = WSSecurityUtil.fetchActionResult(wsResult, WSConstants.SIGN);
if (actionResult != null) {
- X509Certificate returnCert = actionResult.getCertificate();
+ X509Certificate returnCert =
+ (X509Certificate)actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
if (returnCert != null) {
if (!verifyTrust(returnCert, reqData)) {
@@ -479,7 +480,8 @@
actionResult = WSSecurityUtil.fetchActionResult(wsResult, WSConstants.TS);
if (actionResult != null) {
- Timestamp timestamp = actionResult.getTimestamp();
+ Timestamp timestamp =
+ (Timestamp)actionResult.get(WSSecurityEngineResult.TAG_TIMESTAMP);
if (timestamp != null && reqData.getWssConfig().isTimeStampStrict()) {
if (!verifyTimestamp(timestamp, decodeTimeToLive(reqData))) {
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/EnvelopeIdResolver.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/EnvelopeIdResolver.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/EnvelopeIdResolver.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/EnvelopeIdResolver.java Wed Sep 24 06:59:05 2008
@@ -31,8 +31,8 @@
import org.w3c.dom.Element;
/**
- * XML-Security resolver that is used for resolving same-document URI like URI="#id".
- * It is desgined to only work with SOAPEnvelopes.
+ * XML-Security resolver that is used for resolving same-document URIs like URI="#id".
+ * It is designed to work only with SOAPEnvelopes.
* <p/>
*
* @author Davanum Srinivas (dims@yahoo.com).
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSBaseMessage.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSBaseMessage.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSBaseMessage.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSBaseMessage.java Wed Sep 24 06:59:05 2008
@@ -267,7 +267,7 @@
if (mustunderstand) {
securityHeader.setAttributeNS(soapConstants.getEnvelopeURI(),
soapPrefix + ":" + WSConstants.ATTR_MUST_UNDERSTAND,
- soapConstants.getMustunderstand());
+ soapConstants.getMustUnderstand());
}
}
return securityHeader;
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSEncryptBody.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSEncryptBody.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSEncryptBody.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSEncryptBody.java Wed Sep 24 06:59:05 2008
@@ -396,7 +396,7 @@
* data that was encrypted with this encrypted session key :-)
*/
Element wsseSecurity = insertSecurityHeader(doc);
- Element xencEncryptedKey = createEnrcyptedKey(doc, keyEncAlgo);
+ Element xencEncryptedKey = createEncryptedKey(doc, keyEncAlgo);
if (parentNode == null) {
WSSecurityUtil.prependChildElement(doc,
wsseSecurity,
@@ -563,7 +563,7 @@
/*
* Second step: generate a symmetric key from the specified
- * key (password) for this alogrithm, and set the cipher into
+ * key (password) for this algorithm, and set the cipher into
* encryption mode.
*/
this.encryptionKey = this.symmetricKey;
@@ -657,13 +657,12 @@
* Create DOM subtree for <code>xenc:EncryptedKey</code>
*
* @param doc
- * the SOAP enevelope parent document
+ * the SOAP envelope parent document
* @param keyTransportAlgo
- * specifies which alogrithm to use to encrypt the symmetric key
+ * specifies which algorithm to use to encrypt the symmetric key
* @return an <code>xenc:EncryptedKey</code> element
*/
- public static Element createEnrcyptedKey(Document doc,
- String keyTransportAlgo) {
+ public static Element createEncryptedKey(Document doc, String keyTransportAlgo) {
Element encryptedKey =
doc.createElementNS(WSConstants.ENC_NS,
WSConstants.ENC_PREFIX + ":EncryptedKey");
@@ -678,6 +677,20 @@
WSSecurityUtil.appendChildElement(doc, encryptedKey, encryptionMethod);
return encryptedKey;
}
+
+ /**
+ * Create DOM subtree for <code>xenc:EncryptedKey</code>
+ *
+ * @param doc
+ * the SOAP envelope parent document
+ * @param keyTransportAlgo
+ * specifies which algorithm to use to encrypt the symmetric key
+ * @return an <code>xenc:EncryptedKey</code> element
+ * @deprecated use createEncryptedKey(Document doc, String keyTransportAlgo) instead
+ */
+ public static Element createEnrcyptedKey(Document doc, String keyTransportAlgo) {
+ return createEncryptedKey(doc, keyTransportAlgo);
+ }
public static Element createCipherValue(Document doc,
Element encryptedKey) {
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecBase.java Wed Sep 24 06:59:05 2008
@@ -17,8 +17,6 @@
package org.apache.ws.security.message;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.SOAPConstants;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.WSSConfig;
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDerivedKeyBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDerivedKeyBase.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDerivedKeyBase.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDerivedKeyBase.java Wed Sep 24 06:59:05 2008
@@ -219,9 +219,9 @@
ref.setValueType(this.customValueType);
}
strEncKey.setReference(ref);
- dkt.setSecuityTokenReference(strEncKey);
+ dkt.setSecurityTokenReference(strEncKey);
} else {
- dkt.setSecuityTokenReference(this.strElem);
+ dkt.setSecurityTokenReference(this.strElem);
}
}
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecEncryptedKey.java Wed Sep 24 06:59:05 2008
@@ -230,11 +230,11 @@
* Now we need to setup the EncryptedKey header block 1) create a
* EncryptedKey element and set a wsu:Id for it 2) Generate ds:KeyInfo
* element, this wraps the wsse:SecurityTokenReference 3) Create and set
- * up the SecurityTokenReference according to the keyIdentifer parameter
+ * up the SecurityTokenReference according to the keyIdentifier parameter
* 4) Create the CipherValue element structure and insert the encrypted
* session key
*/
- encryptedKeyElement = createEnrcyptedKey(document, keyEncAlgo);
+ encryptedKeyElement = createEncryptedKey(document, keyEncAlgo);
if(this.encKeyId == null || "".equals(this.encKeyId)) {
this.encKeyId = "EncKeyId-" + UUIDGenerator.getUUID();
}
@@ -325,13 +325,13 @@
* Create DOM subtree for <code>xenc:EncryptedKey</code>
*
* @param doc
- * the SOAP enevelope parent document
+ * the SOAP envelope parent document
* @param keyTransportAlgo
- * specifies which alogrithm to use to encrypt the symmetric key
+ * specifies which algorithm to use to encrypt the symmetric key
* @return an <code>xenc:EncryptedKey</code> element
*/
- protected Element createEnrcyptedKey(Document doc, String keyTransportAlgo) {
+ protected Element createEncryptedKey(Document doc, String keyTransportAlgo) {
Element encryptedKey = doc.createElementNS(WSConstants.ENC_NS,
WSConstants.ENC_PREFIX + ":EncryptedKey");
@@ -343,6 +343,20 @@
WSSecurityUtil.appendChildElement(doc, encryptedKey, encryptionMethod);
return encryptedKey;
}
+
+ /**
+ * Create DOM subtree for <code>xenc:EncryptedKey</code>
+ *
+ * @param doc
+ * the SOAP envelope parent document
+ * @param keyTransportAlgo
+ * specifies which algorithm to use to encrypt the symmetric key
+ * @return an <code>xenc:EncryptedKey</code> element
+ * @deprecated use createEncryptedKey(Document doc, String keyTransportAlgo) instead
+ */
+ protected Element createEnrcyptedKey(Document doc, String keyTransportAlgo) {
+ return createEncryptedKey(doc, keyTransportAlgo);
+ }
protected Element createCipherValue(Document doc, Element encryptedKey) {
Element cipherData = doc.createElementNS(WSConstants.ENC_NS,
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecHeader.java Wed Sep 24 06:59:05 2008
@@ -17,8 +17,6 @@
package org.apache.ws.security.message;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.SOAPConstants;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.util.WSSecurityUtil;
@@ -170,7 +168,7 @@
if (mustunderstand) {
securityHeader.setAttributeNS(soapConstants.getEnvelopeURI(),
soapPrefix + ":" + WSConstants.ATTR_MUST_UNDERSTAND,
- soapConstants.getMustunderstand());
+ soapConstants.getMustUnderstand());
}
return securityHeader;
}
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java Wed Sep 24 06:59:05 2008
@@ -139,16 +139,34 @@
*
* @param ref Security token reference
*/
- public void setSecuityTokenReference(SecurityTokenReference ref) {
+ public void setSecurityTokenReference(SecurityTokenReference ref) {
this.elementSecurityTokenReference = ref.getElement();
//WSSecurityUtil.appendChildElement(doc, this.element, ref.getElement());
WSSecurityUtil.prependChildElement(this.element.getOwnerDocument(), this.element, ref.getElement(), false);
}
- public void setSecuityTokenReference(Element elem) {
+ /**
+ * Sets the security token reference of the derived key token
+ * This is the reference to the shared secret used in the conversation/context
+ *
+ * @param ref Security token reference
+ * @deprecated use setSecurityTokenReference(SecurityTokenReference ref) instead
+ */
+ public void setSecuityTokenReference(SecurityTokenReference ref) {
+ setSecurityTokenReference(ref);
+ }
+
+ public void setSecurityTokenReference(Element elem) {
this.elementSecurityTokenReference = elem;
WSSecurityUtil.prependChildElement(elem.getOwnerDocument(), this.element, elem, false);
}
+
+ /**
+ * @deprecated use setSecurityTokenReference(Element elem) instead
+ */
+ public void setSecuityTokenReference(Element elem) {
+ setSecurityTokenReference(elem);
+ }
/**
* Returns the SecurityTokenReference of the derived key token
@@ -156,13 +174,25 @@
* @return the Security Token Reference of the derived key token
* @throws WSSecurityException
*/
- public SecurityTokenReference getSecuityTokenReference() throws
+ public SecurityTokenReference getSecurityTokenReference() throws
WSSecurityException {
if (this.elementSecurityTokenReference != null) {
return new SecurityTokenReference(this.elementSecurityTokenReference);
}
return null;
}
+
+ /**
+ * Returns the SecurityTokenReference of the derived key token
+ *
+ * @return the Security Token Reference of the derived key token
+ * @throws WSSecurityException
+ * @deprecated use getSecurityTokenReference() instead
+ */
+ public SecurityTokenReference getSecuityTokenReference() throws
+ WSSecurityException {
+ return getSecurityTokenReference();
+ }
//Write the getter for security token reference
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java Wed Sep 24 06:59:05 2008
@@ -227,7 +227,7 @@
*/
/**
- * Sets the KeyIdentifer Element as a X509 certificate.
+ * Sets the KeyIdentifier Element as a X509 certificate.
* Takes a X509 certificate, converts its data into base 64 and inserts
* it into a <code>wsse:KeyIdentifier</code> element, which is placed
* in the <code>wsse:SecurityTokenReference</code> element.
@@ -254,7 +254,7 @@
}
/**
- * Sets the KeyIdentifer Element as a X509 Subject-Key-Identifier (SKI).
+ * Sets the KeyIdentifier Element as a X509 Subject-Key-Identifier (SKI).
* Takes a X509 certificate, gets it SKI data, converts into base 64 and
* inserts it into a <code>wsse:KeyIdentifier</code> element, which is placed
* in the <code>wsse:SecurityTokenReference</code> element.
@@ -283,7 +283,7 @@
}
/**
- * Sets the KeyIdentifer Element as a Thumbprint.
+ * Sets the KeyIdentifier Element as a Thumbprint.
*
* Takes a X509 certificate, computes its thumbprint using SHA-1, converts
* into base 64 and inserts it into a <code>wsse:KeyIdentifier</code>
@@ -369,7 +369,7 @@
}
/**
- * Gets the KeyIdentifer.
+ * Gets the KeyIdentifier.
*
* @return the the X509 certificate or zero if a unknown key identifier
* type was detected.
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/DerivedKeyTokenProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/DerivedKeyTokenProcessor.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/DerivedKeyTokenProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/DerivedKeyTokenProcessor.java Wed Sep 24 06:59:05 2008
@@ -114,7 +114,7 @@
*/
private void extractSecret(WSDocInfo wsDocInfo, DerivedKeyToken dkt, CallbackHandler cb, Crypto crypto)
throws WSSecurityException {
- SecurityTokenReference str = dkt.getSecuityTokenReference();
+ SecurityTokenReference str = dkt.getSecurityTokenReference();
if (str != null) {
Processor processor;
String uri = null;
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/SignatureProcessor.java Wed Sep 24 06:59:05 2008
@@ -376,7 +376,7 @@
throw new WSSecurityException(
WSSecurityException.FAILED_CHECK);
}
- returnElements.add(WSSecurityUtil.getIDfromReference(uri));
+ returnElements.add(WSSecurityUtil.getIDFromReference(uri));
} else {
//This is the case where the signed element is identified
//by a transform such as XPath filtering
@@ -403,14 +403,14 @@
principal.setLength(dkt.getLength());
principal.setOffset(dkt.getOffset());
String basetokenId = null;
- SecurityTokenReference secuityTokenReference = dkt
- .getSecuityTokenReference();
- if (secuityTokenReference.containsReference()) {
- basetokenId = secuityTokenReference.getReference()
+ SecurityTokenReference securityTokenReference = dkt
+ .getSecurityTokenReference();
+ if (securityTokenReference.containsReference()) {
+ basetokenId = securityTokenReference.getReference()
.getURI().substring(1);
} else {
// KeyIdentifier
- basetokenId = secuityTokenReference
+ basetokenId = securityTokenReference
.getKeyIdentifierValue();
}
principal.setBasetokenId(basetokenId);
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/UsernameTokenProcessor.java Wed Sep 24 06:59:05 2008
@@ -175,7 +175,7 @@
}
/**
- * Get the processed USernameToken.
+ * Get the processed UsernameToken.
*
* @return the ut
*/
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/transform/STRTransform.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/transform/STRTransform.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/transform/STRTransform.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/transform/STRTransform.java Wed Sep 24 06:59:05 2008
@@ -117,7 +117,7 @@
/*
* Here we get some information about the document that is being
- * processed, in partucular the crypto implementation, and already
+ * processed, in particular the crypto implementation, and already
* detected BST that may be used later during dereferencing.
*/
wsDocInfo = WSDocInfoStore.lookup(docHash);
@@ -128,7 +128,7 @@
/*
* According to the OASIS WS Specification "Web Services Security:
* SOAP Message Security 1.0" Monday, 19 January 2004, chapter 8.3
- * describes that the input node set must be processed bythe c14n
+ * describes that the input node set must be processed by the c14n
* that is specified in the argument element of the STRTransform
* element.
*
@@ -331,7 +331,7 @@
} else {
elem.setAttributeNS(null, "ValueType", X509Security.X509_V3_TYPE);
}
- Text certText = doc.createTextNode(Base64.encode(data)); // no lne
+ Text certText = doc.createTextNode(Base64.encode(data)); // no line
// wrap
elem.appendChild(certText);
return elem;
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/util/WSSecurityUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/util/WSSecurityUtil.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/util/WSSecurityUtil.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/util/WSSecurityUtil.java Wed Sep 24 06:59:05 2008
@@ -60,7 +60,7 @@
private static Log log = LogFactory.getLog(WSSecurityUtil.class);
/**
- * A cached pseuo-random number generator
+ * A cached pseudo-random number generator
* NB. On some JVMs, caching this random number
* generator is required to overcome punitive
* overhead.
@@ -253,7 +253,7 @@
Element foundElement = null;
/*
- * Replace the formely recursive implementation with a depth-first-loop
+ * Replace the formerly recursive implementation with a depth-first-loop
* lookup
*/
if (startNode == null) {
@@ -434,7 +434,7 @@
if (id == null) {
return null;
}
- id = getIDfromReference(id);
+ id = getIDFromReference(id);
return WSSecurityUtil.findElementById(doc.getDocumentElement(), id,
WSConstants.WSU_NS);
}
@@ -446,13 +446,25 @@
* @return ref trimmed and with the leading "#" removed, or null if not
* correctly formed
*/
- public static String getIDfromReference(String ref) {
+ public static String getIDFromReference(String ref) {
String id = ref.trim();
if ((id.length() == 0) || (id.charAt(0) != '#')) {
return null;
}
return id.substring(1);
}
+
+ /**
+ * Turn a reference (eg "#5") into an ID (eg "5").
+ *
+ * @param ref
+ * @return ref trimmed and with the leading "#" removed, or null if not
+ * correctly formed
+ * @deprecated use getIDFromReference instead
+ */
+ public static String getIDfromReference(String ref) {
+ return getIDFromReference(ref);
+ }
/**
* Search for an element given its generic id. <p/>
@@ -507,7 +519,7 @@
* @param namespaceUri
* of the element
* @param localName
- * of the eleme
+ * of the element
* @return the found element or null if the element does not exist
*/
private static Element findChildElement(Element parent,
@@ -598,7 +610,7 @@
* @param envelope
* the SOAP envelope
* @param actor
- * the acttoer (role) name of the WSS header
+ * the actor (role) name of the WSS header
* @param doCreate
* if true create a new WSS header block if none exists
* @return the WSS header or null if none found and doCreate is false
@@ -705,7 +717,11 @@
for (int i = 0; i < wsResultVector.size(); i++) {
// Check the result of every action whether it matches the given
// action
- if (((WSSecurityEngineResult) wsResultVector.get(i)).getAction() == action) {
+ WSSecurityEngineResult result =
+ (WSSecurityEngineResult) wsResultVector.get(i);
+ int resultAction =
+ ((java.lang.Integer)result.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
+ if (resultAction == action) {
wsResult = (WSSecurityEngineResult) wsResultVector.get(i);
}
}
@@ -732,7 +748,11 @@
for (int i = 0; i < wsResultVector.size(); i++) {
// Check the result of every action whether it matches the given
// action
- if (((WSSecurityEngineResult) wsResultVector.get(i)).getAction() == action) {
+ WSSecurityEngineResult result =
+ (WSSecurityEngineResult) wsResultVector.get(i);
+ int resultAction =
+ ((java.lang.Integer)result.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
+ if (resultAction == action) {
results.add(wsResultVector.get(i));
}
}
@@ -891,19 +911,22 @@
Iterator actions = result.getResults().iterator();
while (actions.hasNext()) {
- WSSecurityEngineResult resultItem = (WSSecurityEngineResult) actions
- .next();
- if (resultItem.getAction() == WSConstants.SIGN) {
+ WSSecurityEngineResult resultItem =
+ (WSSecurityEngineResult) actions.next();
+ int resultAction =
+ ((java.lang.Integer)resultItem.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
+
+ if (resultAction == WSConstants.SIGN) {
try {
checkSignsAllElements(resultItem, requiredIDs);
- return resultItem.getCertificate();
+ return
+ (X509Certificate)resultItem.get(
+ WSSecurityEngineResult.TAG_X509_CERTIFICATE
+ );
} catch (WSSecurityException ex) {
// Store the exception but keep going... there may be a
// better signature later
- log
- .debug(
- "SIGN result does not sign all required elements",
- ex);
+ log.debug("SIGN result does not sign all required elements", ex);
fault = ex;
}
}
@@ -913,8 +936,7 @@
if (fault != null)
throw fault;
- throw new WSSecurityException(WSSecurityException.FAILED_CHECK,
- "noSignResult");
+ throw new WSSecurityException(WSSecurityException.FAILED_CHECK, "noSignResult");
}
/**
@@ -931,13 +953,17 @@
private static void checkSignsAllElements(
WSSecurityEngineResult resultItem, String[] requiredIDs)
throws WSSecurityException {
- if (resultItem.getAction() != WSConstants.SIGN)
+ int resultAction =
+ ((java.lang.Integer)resultItem.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
+ if (resultAction != WSConstants.SIGN) {
throw new IllegalArgumentException("Not a SIGN result");
+ }
- Set sigElems = resultItem.getSignedElements();
- if (sigElems == null)
+ Set sigElems = (Set)resultItem.get(WSSecurityEngineResult.TAG_SIGNED_ELEMENT_IDS);
+ if (sigElems == null) {
throw new RuntimeException(
"Missing signedElements set in WSSecurityEngineResult!");
+ }
log.debug("Found SIGN result...");
for (Iterator i = sigElems.iterator(); i.hasNext();) {
Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityGetPassword.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityGetPassword.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityGetPassword.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityGetPassword.java Wed Sep 24 06:59:05 2008
@@ -159,7 +159,7 @@
"SomeCallbackRef",
reqData
);
- assertTrue("bob".equals(callback.getIdentifer()));
+ assertTrue("bob".equals(callback.getIdentifier()));
assertTrue("securityPassword".equals(callback.getPassword()));
assertTrue(WSPasswordCallback.USERNAME_TOKEN == callback.getUsage());
}
@@ -295,7 +295,7 @@
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WSPasswordCallback) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
- if (pc.getIdentifer() == "bob") {
+ if (pc.getIdentifier() == "bob") {
pc.setPassword("securityPassword");
}
} else {
Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew5.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew5.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew5.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew5.java Wed Sep 24 06:59:05 2008
@@ -446,15 +446,15 @@
if (callbacks[i] instanceof WSPasswordCallback) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN
- && "wernerd".equals(pc.getIdentifer())) {
+ && "wernerd".equals(pc.getIdentifier())) {
pc.setPassword("verySecret");
} else if (
pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN
) {
- if ("wernerd".equals(pc.getIdentifer())
+ if ("wernerd".equals(pc.getIdentifier())
&& "verySecret".equals(pc.getPassword())) {
return;
- } else if ("customUser".equals(pc.getIdentifer())) {
+ } else if ("customUser".equals(pc.getIdentifier())) {
return;
} else {
throw new IOException("Authentication failed");
Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSCT.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSCT.java?rev=698575&r1=698574&r2=698575&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSCT.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSCT.java Wed Sep 24 06:59:05 2008
@@ -327,7 +327,7 @@
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof WSPasswordCallback) {
WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
- byte[] secret = (byte[]) this.secrets.get(pc.getIdentifer());
+ byte[] secret = (byte[]) this.secrets.get(pc.getIdentifier());
pc.setKey(secret);
} else {
throw new UnsupportedCallbackException(callbacks[i],
---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org