Author: dkulp
Date: Wed Apr 8 18:49:57 2009
New Revision: 763349
URL: http://svn.apache.org/viewvc?rev=763349&view=rev
Log:
Merged revisions 763162 via svnmerge from
https://svn.apache.org/repos/asf/webservices/wss4j/trunk
........
r763162 | coheigea | 2009-04-08 06:05:15 -0400 (Wed, 08 Apr 2009) | 2 lines
A fix for some failing WCF interop wstrust10 tests.
........
Modified:
webservices/wss4j/branches/1_5_x-fixes/ (props changed)
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/errors.properties
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/processor/EncryptedDataProcessor.java
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/util/WSSecurityUtil.java
Propchange: webservices/wss4j/branches/1_5_x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Apr 8 18:49:57 2009
@@ -1 +1 @@
-/webservices/wss4j/trunk:757428
+/webservices/wss4j/trunk:757428,763162
Propchange: webservices/wss4j/branches/1_5_x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Apr 8 18:49:57 2009
@@ -1 +1 @@
-/webservices/wss4j/trunk:1-753313,757428
+/webservices/wss4j/trunk:1-753313,757428,763162
Modified:
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/errors.properties
URL:
http://svn.apache.org/viewvc/webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/errors.properties?rev=763349&r1=763348&r2=763349&view=diff
==============================================================================
---
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/errors.properties
(original)
+++
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/errors.properties
Wed Apr 8 18:49:57 2009
@@ -59,6 +59,7 @@
unsupportedKeyTransp=unsupported key transport encryption algorithm: {0}
noCipher=WSSecurityEngine: EncryptedKey does not contain
xenc:CipherData/xenc:CipherValue
noKeyinfo=WSSecurityEngine: EncryptedKey does not contain ds:KeyInfo
+noEncKey=WSSecurityEngine: EncryptedData does not contain xenc:EncryptedKey
noSecTokRef=WSSecurityEngine: EncryptedKey does not contain
ds:KeyInfo/wsse:SecurityTokenReference
unsupportedKeyId=Unsupported key identification
dataRef=WSSecurityEngine: DataReference - referenced data not found
Modified:
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/processor/EncryptedDataProcessor.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/processor/EncryptedDataProcessor.java?rev=763349&r1=763348&r2=763349&view=diff
==============================================================================
---
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/processor/EncryptedDataProcessor.java
(original)
+++
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/processor/EncryptedDataProcessor.java
Wed Apr 8 18:49:57 2009
@@ -19,7 +19,6 @@
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.WSDocInfo;
import org.apache.ws.security.WSSConfig;
-import org.apache.ws.security.WSSecurityEngine;
import org.apache.ws.security.WSSecurityException;
import org.apache.ws.security.components.crypto.Crypto;
import org.apache.ws.security.util.WSSecurityUtil;
@@ -27,7 +26,6 @@
import org.apache.xml.security.encryption.XMLEncryptionException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
import javax.crypto.SecretKey;
import javax.security.auth.callback.CallbackHandler;
@@ -42,8 +40,6 @@
*/
public class EncryptedDataProcessor implements Processor {
- private byte[] symmKey;
-
public String getId() {
return null;
}
@@ -57,29 +53,30 @@
Vector returnResults,
WSSConfig config
) throws WSSecurityException {
- Element kiElem = (Element)WSSecurityUtil.findElement(elem, "KeyInfo",
WSConstants.SIG_NS);
-
- NodeList children = kiElem.getChildNodes();
- int len = children.getLength();
-
- for(int i = 0; i < len; i++) {
- Node child = children.item(i);
- if (child.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
- QName el = new QName(child.getNamespaceURI(),
child.getLocalName());
- if(el.equals(WSSecurityEngine.ENCRYPTED_KEY)) {
- EncryptedKeyProcessor encrKeyProc = new
EncryptedKeyProcessor();
- encrKeyProc.handleToken(
- (Element)child, crypto, decCrypto, cb, wsDocInfo,
returnResults, config
- );
- this.symmKey = encrKeyProc.getDecryptedBytes();
- break;
- }
+ Element kiElem =
+ WSSecurityUtil.getDirectChildElement(elem, "KeyInfo",
WSConstants.SIG_NS);
+ if (kiElem == null) {
+ throw new WSSecurityException(
+ WSSecurityException.UNSUPPORTED_ALGORITHM, "noKeyinfo"
+ );
}
+ Element encryptedKeyElement =
+ WSSecurityUtil.getDirectChildElement(
+ kiElem, WSConstants.ENC_KEY_LN, WSConstants.ENC_NS
+ );
+ if (encryptedKeyElement == null) {
+ throw new WSSecurityException(
+ WSSecurityException.UNSUPPORTED_ALGORITHM, "noEncKey"
+ );
+ }
+ EncryptedKeyProcessor encrKeyProc = new EncryptedKeyProcessor();
+ encrKeyProc.handleToken(
+ encryptedKeyElement, crypto, decCrypto, cb, wsDocInfo,
returnResults, config
+ );
+ byte[] symmKey = encrKeyProc.getDecryptedBytes();
String encAlgo = X509Util.getEncAlgo(elem);
- SecretKey key = WSSecurityUtil.prepareSecretKey(encAlgo, this.symmKey);
+ SecretKey key = WSSecurityUtil.prepareSecretKey(encAlgo, symmKey);
// initialize Cipher ....
XMLCipher xmlCipher = null;
@@ -91,7 +88,6 @@
WSSecurityException.UNSUPPORTED_ALGORITHM, null, null, e1
);
}
-
Node previousSibling = elem.getPreviousSibling();
Node parent = elem.getParentNode();
try {
@@ -102,18 +98,18 @@
);
}
- // Get hold of the plain text element
- Element decryptedElem;
- if (previousSibling == null) {
- decryptedElem = (Element)parent.getFirstChild();
- } else {
- decryptedElem = (Element)previousSibling.getNextSibling();
- }
- QName el = new QName(decryptedElem.getNamespaceURI(),
decryptedElem.getLocalName());
if (config != null) {
+ // Get hold of the plain text element
+ Element decryptedElem;
+ if (previousSibling == null) {
+ decryptedElem = (Element)parent.getFirstChild();
+ } else {
+ decryptedElem = (Element)previousSibling.getNextSibling();
+ }
+ QName el = new QName(decryptedElem.getNamespaceURI(),
decryptedElem.getLocalName());
Processor proc = config.getProcessor(el);
proc.handleToken(
- decryptedElem, crypto, decCrypto, cb, wsDocInfo,
returnResults, config
+ decryptedElem, crypto, decCrypto, cb, wsDocInfo,
returnResults, config
);
wsDocInfo.setProcessor(proc);
}
Modified:
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/util/WSSecurityUtil.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/util/WSSecurityUtil.java?rev=763349&r1=763348&r2=763349&view=diff
==============================================================================
---
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/util/WSSecurityUtil.java
(original)
+++
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/util/WSSecurityUtil.java
Wed Apr 8 18:49:57 2009
@@ -157,6 +157,32 @@
}
/**
+ * Gets a direct child with specified localname and namespace. <p/>
+ *
+ * @param fNode the node where to start the search
+ * @param localName local name of the child to get
+ * @param namespace the namespace of the child to get
+ * @return the node or <code>null</code> if not such node found
+ */
+ public static Element getDirectChildElement(
+ Node fNode,
+ String localName,
+ String namespace
+ ) {
+ for (
+ Node currentChild = fNode.getFirstChild();
+ currentChild != null;
+ currentChild = currentChild.getNextSibling()
+ ) {
+ if (Node.ELEMENT_NODE == currentChild.getNodeType()
+ && localName.equals(currentChild.getLocalName())
+ && namespace.equals(currentChild.getNamespaceURI())) {
+ return (Element)currentChild;
+ }
+ }
+ return null;
+ }
+ /**
* return the first soap "Body" element. <p/>
*
* @param doc
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]