meder 2005/02/07 10:52:44
Modified: wss4j/src/org/apache/ws/security/conversation/message/token
RequestedProofToken.java
wss4j/src/org/apache/ws/security/message WSEncryptBody.java
Log:
Add method to get at symmetric key used for encryption and use it in
RequestedProofToken
Revision Changes Path
1.8 +4 -4
ws-fx/wss4j/src/org/apache/ws/security/conversation/message/token/RequestedProofToken.java
Index: RequestedProofToken.java
===================================================================
RCS file:
/home/cvs/ws-fx/wss4j/src/org/apache/ws/security/conversation/message/token/RequestedProofToken.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- RequestedProofToken.java 29 Dec 2004 02:04:54 -0000 1.7
+++ RequestedProofToken.java 7 Feb 2005 18:52:44 -0000 1.8
@@ -70,7 +70,6 @@
* Constructor.
*
* @param doc is the SOAP envelop.
- * @param secret is the secret.
* @throws WSSecurityException
*/
public RequestedProofToken(Document doc) throws WSSecurityException {
@@ -163,7 +162,7 @@
wsEncrypt.setParentNode(this.element);
if (this.sharedSecret != null) {
//wsEncrypt.setSymmetricKey(WSSecurityUtil.prepareSecretKey(WSConstants.TRIPLE_DES,
this.sharedSecret));//TODO
- }
+ }
// wsEncrypt.setParentNode(
// (Element) (doc
// .getElementsByTagNameNS(
@@ -171,6 +170,7 @@
// "RequestedProofToken")
// .item(0)));
wsEncrypt.build(doc, crypto);
+ this.sharedSecret = wsEncrypt.getEncryptionKey().getEncoded();
} catch (WSSecurityException e) {
e.printStackTrace();
}
@@ -235,7 +235,7 @@
/*
* Second step: generate a symmetric key (session key) for
- * this alogrithm, and set the cipher into encryption mode.
+ * this alogrithm, and set the cipher into encryption mode.
*/
KeyGenerator keyGen = null;
try {
@@ -259,7 +259,7 @@
* the generated symmetric (session) key.
* Up to now we support RSA 1-5 as public key algorithm
*/
-
+
X509Certificate remoteCert = null;
X509Certificate[] certs = crypto.getCertificates(user);
if (certs == null || certs.length <= 0) {
1.27 +25 -9
ws-fx/wss4j/src/org/apache/ws/security/message/WSEncryptBody.java
Index: WSEncryptBody.java
===================================================================
RCS file:
/home/cvs/ws-fx/wss4j/src/org/apache/ws/security/message/WSEncryptBody.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- WSEncryptBody.java 29 Dec 2004 02:04:54 -0000 1.26
+++ WSEncryptBody.java 7 Feb 2005 18:52:44 -0000 1.27
@@ -74,6 +74,11 @@
protected SecretKey symmetricKey = null;
/**
+ * Symmetric key that's actually used.
+ */
+ protected SecretKey encryptionKey = null;
+
+ /**
* Parent node to which the EncryptedKeyElement should be added.
*/
protected Element parentNode = null;
@@ -291,12 +296,12 @@
* this alogrithm, and set the cipher into encryption mode.
*/
// This variable is made a classs attribute :: SecretKey
symmetricKey = null;
- SecretKey encryptionKey = this.symmetricKey;
+ this.encryptionKey = this.symmetricKey;
if (encryptionKey == null) {
KeyGenerator keyGen = getKeyGenerator();
- encryptionKey = keyGen.generateKey();
+ this.encryptionKey = keyGen.generateKey();
}
- Vector encDataRefs = doEncryption(doc, encryptionKey);
+ Vector encDataRefs = doEncryption(doc, this.encryptionKey);
if (tlog.isDebugEnabled()) {
t1 = System.currentTimeMillis();
@@ -335,7 +340,7 @@
} catch (InvalidKeyException e) {
throw new
WSSecurityException(WSSecurityException.FAILED_ENC_DEC, null, null, e);
}
- byte[] encKey = encryptionKey.getEncoded();
+ byte[] encKey = this.encryptionKey.getEncoded();
if (doDebug) {
log.debug("cipher blksize: "
+ cipher.getBlockSize()
@@ -543,10 +548,11 @@
* key (password) for this alogrithm, and set the cipher into
* encryption mode.
*/
- SecretKey encryptionKey = this.symmetricKey;
- if (encryptionKey == null) {
- encryptionKey = WSSecurityUtil.prepareSecretKey(symEncAlgo,
- embeddedKey);
+ this.encryptionKey = this.symmetricKey;
+ if (this.encryptionKey == null) {
+ this.encryptionKey = WSSecurityUtil.prepareSecretKey(
+ symEncAlgo,
+ embeddedKey);
}
KeyInfo keyInfo = null;
@@ -575,7 +581,7 @@
}
}
- Vector encDataRefs = doEncryption(doc, encryptionKey, keyInfo);
+ Vector encDataRefs = doEncryption(doc, this.encryptionKey, keyInfo);
/*
* At this point data is encrypted with the symmetric key and can be
@@ -701,6 +707,16 @@
}
/**
+ * Get the symmetric key used for subscription. This may be the same as
+ * the symmetric key.
+ *
+ * @return The symmetric key
+ */
+ public SecretKey getEncryptionKey() {
+ return this.encryptionKey;
+ }
+
+ /**
* @return
*/
public SecurityTokenReference getSecurityTokenReference() {