Author: coheigea
Date: Wed Sep 24 09:54:55 2008
New Revision: 698650
URL: http://svn.apache.org/viewvc?rev=698650&view=rev
Log:
[WSS-102] - Added some other changes that never made it from the 1_5_4 tag to
trunk
Modified:
webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
webservices/wss4j/trunk/test/components/TestMerlin.java
webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java
Modified:
webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java?rev=698650&r1=698649&r2=698650&view=diff
==============================================================================
---
webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
(original)
+++
webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
Wed Sep 24 09:54:55 2008
@@ -339,7 +339,14 @@
if (tmpE.getLocalName().equals("DataReference")) {
dataRefURI = ((Element) tmpE).getAttribute("URI");
dataRef = new WSDataRef(dataRefURI.substring(1));
- decryptDataRef(doc, dataRefURI,dataRef, decryptedBytes);
+ Element elt =
+ decryptDataRef(doc, dataRefURI,dataRef,
decryptedBytes);
+ dataRef.setName(
+ new javax.xml.namespace.QName(
+ elt.getNamespaceURI(),
+ elt.getLocalName()
+ )
+ );
dataRefs.add(dataRef);
}
}
Modified: webservices/wss4j/trunk/test/components/TestMerlin.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/components/TestMerlin.java?rev=698650&r1=698649&r2=698650&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/components/TestMerlin.java (original)
+++ webservices/wss4j/trunk/test/components/TestMerlin.java Wed Sep 24 09:54:55
2008
@@ -3,8 +3,9 @@
import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.ws.security.components.crypto.CryptoFactory;
+import org.apache.ws.security.components.crypto.AbstractCrypto;
import org.apache.ws.security.components.crypto.Crypto;
+import org.apache.ws.security.components.crypto.CryptoFactory;
/**
* Created by IntelliJ IDEA.
@@ -38,4 +39,22 @@
Crypto crypto = CryptoFactory.getInstance();
assertTrue(crypto != null);
}
+
+ public void testAbstractCryptoWithNullProperties()
+ throws Exception {
+ Crypto crypto = new NullPropertiesCrypto();
+ assertTrue(crypto != null);
+ }
+
+ /**
+ * WSS-102 -- ensure AbstractCrypto will null properties
+ * can be instantiated
+ */
+ private static class NullPropertiesCrypto extends AbstractCrypto {
+
+ public NullPropertiesCrypto()
+ throws Exception {
+ super((java.util.Properties) null);
+ }
+ }
}
Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java?rev=698650&r1=698649&r2=698650&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java Wed Sep 24
09:54:55 2008
@@ -32,6 +32,8 @@
import org.apache.ws.security.WSPasswordCallback;
import org.apache.ws.security.WSSecurityEngine;
import org.apache.ws.security.WSEncryptionPart;
+import org.apache.ws.security.WSSecurityEngineResult;
+import org.apache.ws.security.WSDataRef;
import org.apache.ws.security.components.crypto.Crypto;
import org.apache.ws.security.components.crypto.CryptoFactory;
import org.apache.ws.security.message.WSSecEncrypt;
@@ -65,6 +67,11 @@
static final WSSecurityEngine secEngine = new WSSecurityEngine();
static final Crypto crypto =
CryptoFactory.getInstance("cryptoSKI.properties");
+ static final javax.xml.namespace.QName SOAP_BODY =
+ new javax.xml.namespace.QName(
+ WSConstants.URI_SOAP11_ENV,
+ "Body"
+ );
MessageContext msgContext;
Message message;
@@ -161,7 +168,7 @@
String encryptedString = encryptedMsg.getSOAPPartAsString();
assertTrue(encryptedString.indexOf("LogTestService2") == -1 ? true :
false);
encryptedDoc = encryptedMsg.getSOAPEnvelope().getAsDocument();
- verify(encryptedDoc);
+ verify(encryptedDoc, SOAP_BODY);
/*
* second run, same Junit set up, but change encryption method,
@@ -192,7 +199,13 @@
encryptedString = encryptedMsg.getSOAPPartAsString();
assertTrue(encryptedString.indexOf("LogTestService2") == -1 ? true :
false);
encryptedDoc = encryptedMsg.getSOAPEnvelope().getAsDocument();
- verify(encryptedDoc);
+ verify(
+ encryptedDoc,
+ new javax.xml.namespace.QName(
+ "uri:LogTestService2",
+ "testMethod"
+ )
+ );
}
/**
@@ -224,7 +237,7 @@
String encryptedString = encryptedMsg.getSOAPPartAsString();
assertTrue(encryptedString.indexOf("LogTestService2") == -1 ? true :
false);
encryptedDoc = encryptedMsg.getSOAPEnvelope().getAsDocument();
- verify(encryptedDoc);
+ verify(encryptedDoc, SOAP_BODY);
}
@@ -235,11 +248,41 @@
* @param envelope
* @throws Exception Thrown when there is a problem in verification
*/
- private void verify(Document doc) throws Exception {
- secEngine.processSecurityHeader(doc, null, this, crypto);
+ private void verify(
+ Document doc,
+ javax.xml.namespace.QName expectedEncryptedElement
+ ) throws Exception {
+ final java.util.List results = secEngine.processSecurityHeader(doc,
null, this, crypto);
SOAPUtil.updateSOAPMessage(doc, message);
String decryptedString = message.getSOAPPartAsString();
assertTrue(decryptedString.indexOf("LogTestService2") > 0 ? true :
false);
+ //
+ // walk through the results, and make sure there is an encrytion [sic]
+ // action, together with a reference to the decrypted element
+ // (as a QName)
+ //
+ boolean encrypted = false;
+ for (java.util.Iterator ipos = results.iterator(); ipos.hasNext();) {
+ final java.util.Map result = (java.util.Map) ipos.next();
+ final Integer action = (Integer)
result.get(WSSecurityEngineResult.TAG_ACTION);
+ assertNotNull(action);
+ if ((action.intValue() & WSConstants.ENCR) != 0) {
+ final java.util.List refs =
+ (java.util.List)
result.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
+ assertNotNull(refs);
+ encrypted = true;
+ for (java.util.Iterator jpos = refs.iterator();
jpos.hasNext();) {
+ final WSDataRef ref = (WSDataRef) jpos.next();
+ assertNotNull(ref);
+ assertNotNull(ref.getName());
+ assertEquals(
+ expectedEncryptedElement,
+ ref.getName()
+ );
+ }
+ }
+ }
+ assertTrue(encrypted);
}
public void handle(Callback[] callbacks)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]