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 2010/08/23 20:45:35 UTC
svn commit: r988246 - in /webservices/wss4j/trunk:
src/org/apache/ws/security/WSSecurityEngineResult.java
src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
test/wssec/TestWSSecurityEncryptionParts.java
Author: coheigea
Date: Mon Aug 23 18:45:35 2010
New Revision: 988246
URL: http://svn.apache.org/viewvc?rev=988246&view=rev
Log:
[WSS-237] - Provide key transport algorithm in encryption processor results
- Thanks to David Valeri for the patch.
Modified:
webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngineResult.java
webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
webservices/wss4j/trunk/test/wssec/TestWSSecurityEncryptionParts.java
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngineResult.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngineResult.java?rev=988246&r1=988245&r2=988246&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngineResult.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngineResult.java Mon Aug 23 18:45:35 2010
@@ -149,6 +149,13 @@ public class WSSecurityEngineResult exte
public static final Object TAG_ENCRYPTED_EPHEMERAL_KEY = "encrypted-ephemeral-key-bytes";
/**
+ * Tag denoting the encrypted key transport algorithm.
+ *
+ * The value under this tag is of type String.
+ */
+ public static final Object TAG_ENCRYPTED_KEY_TRANSPORT_METHOD = "encrypted-key-transport-method";
+
+ /**
* Tag denoting the algorithm that was used to sign the message
*
* The value under this tag is of type String.
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=988246&r1=988245&r2=988246&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 Mon Aug 23 18:45:35 2010
@@ -64,6 +64,8 @@ public class EncryptedKeyProcessor imple
private String encryptedKeyId = null;
private X509Certificate[] certs;
+
+ private String encryptedKeyTransportMethod = null;
public void handleToken(
Element elem,
@@ -86,16 +88,21 @@ public class EncryptedKeyProcessor imple
}
List dataRefs = handleEncryptedKey(elem, cb, decCrypto, null);
encryptedKeyId = elem.getAttribute("Id");
- returnResults.add(
- 0,
- new WSSecurityEngineResult(
+
+ WSSecurityEngineResult result = new WSSecurityEngineResult(
WSConstants.ENCR,
decryptedBytes,
encryptedEphemeralKey,
encryptedKeyId,
dataRefs,
certs
- )
+ );
+
+ result.put(WSSecurityEngineResult.TAG_ENCRYPTED_KEY_TRANSPORT_METHOD, this.encryptedKeyTransportMethod);
+
+ returnResults.add(
+ 0,
+ result
);
}
@@ -129,8 +136,8 @@ public class EncryptedKeyProcessor imple
// lookup xenc:EncryptionMethod, get the Algorithm attribute to determine
// how the key was encrypted. Then check if we support the algorithm
//
- String keyEncAlgo = X509Util.getEncAlgo(xencEncryptedKey);
- Cipher cipher = WSSecurityUtil.getCipherInstance(keyEncAlgo);
+ this.encryptedKeyTransportMethod = X509Util.getEncAlgo(xencEncryptedKey);
+ Cipher cipher = WSSecurityUtil.getCipherInstance(this.encryptedKeyTransportMethod);
//
// Now lookup CipherValue.
//
Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityEncryptionParts.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityEncryptionParts.java?rev=988246&r1=988245&r2=988246&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityEncryptionParts.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityEncryptionParts.java Mon Aug 23 18:45:35 2010
@@ -139,9 +139,13 @@ public class TestWSSecurityEncryptionPar
WSSecurityEngineResult actionResult =
WSSecurityUtil.fetchActionResult(results, WSConstants.ENCR);
assertTrue(actionResult != null);
+ assertFalse(actionResult.isEmpty());
final java.util.List refs =
(java.util.List) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
- assertTrue(actionResult != null && !actionResult.isEmpty());
+
+ assertEquals(WSConstants.KEYTRANSPORT_RSA15,
+ actionResult.get(WSSecurityEngineResult.TAG_ENCRYPTED_KEY_TRANSPORT_METHOD));
+
WSDataRef wsDataRef = (WSDataRef)refs.get(0);
String xpath = wsDataRef.getXpath();
assertEquals("/soapenv:Envelope/soapenv:Header/foo:foobar", xpath);
@@ -185,9 +189,13 @@ public class TestWSSecurityEncryptionPar
WSSecurityEngineResult actionResult =
WSSecurityUtil.fetchActionResult(results, WSConstants.ENCR);
assertTrue(actionResult != null);
+ assertFalse(actionResult.isEmpty());
final java.util.List refs =
(java.util.List) actionResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
- assertTrue(actionResult != null && !actionResult.isEmpty());
+
+ assertEquals(WSConstants.KEYTRANSPORT_RSA15,
+ actionResult.get(WSSecurityEngineResult.TAG_ENCRYPTED_KEY_TRANSPORT_METHOD));
+
WSDataRef wsDataRef = (WSDataRef)refs.get(0);
String xpath = wsDataRef.getXpath();
assertEquals("/soapenv:Envelope/soapenv:Header/foo:foobar", xpath);
---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org