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 2009/07/23 12:26:09 UTC
svn commit: r797008 - in
/webservices/wss4j/trunk/src/org/apache/ws/security/message/token:
BinarySecurity.java Reference.java SecurityTokenReference.java
SignatureConfirmation.java UsernameToken.java
Author: coheigea
Date: Thu Jul 23 10:26:09 2009
New Revision: 797008
URL: http://svn.apache.org/viewvc?rev=797008&view=rev
Log:
Merged a fix to parsing BinarySecurityTokens plus changed all non namespace-aware setAttribute methods to setAttributeNS
Modified:
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Reference.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SignatureConfirmation.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/UsernameToken.java
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java?rev=797008&r1=797007&r2=797008&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java Thu Jul 23 10:26:09 2009
@@ -19,6 +19,8 @@
package org.apache.ws.security.message.token;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.WSSecurityException;
import org.apache.ws.security.util.DOM2Writer;
@@ -41,6 +43,7 @@
public static final QName TOKEN_BST = new QName(WSConstants.WSSE_NS, "BinarySecurityToken");
public static final QName TOKEN_KI = new QName(WSConstants.WSSE_NS, "KeyIdentifier");
public static final String BASE64_ENCODING = WSConstants.SOAPMESSAGE_NS + "#Base64Binary";
+ private static final Log LOG = LogFactory.getLog(BinarySecurity.class.getName());
protected Element element = null;
/**
@@ -128,7 +131,7 @@
* @param type
*/
public void setValueType(String type) {
- element.setAttribute("ValueType", type);
+ element.setAttributeNS(null, "ValueType", type);
}
/**
@@ -146,22 +149,30 @@
* @param encoding
*/
public void setEncodingType(String encoding) {
- element.setAttribute("EncodingType", encoding);
+ element.setAttributeNS(null, "EncodingType", encoding);
}
/**
* get the byte array containing token information.
*
- * @return TODO
+ * @return the byte array containing token information
*/
public byte[] getToken() {
- Text node = getFirstNode();
- if (node == null) {
- return null;
+ Node node = element.getFirstChild();
+ StringBuffer buffer = new StringBuffer();
+ while (node != null) {
+ if (Node.TEXT_NODE == node.getNodeType()) {
+ buffer.append(((Text)node).getData());
+ }
+ node = node.getNextSibling();
}
+
try {
- return Base64.decode(node.getData());
- } catch (Exception e) {
+ return Base64.decode(buffer.toString());
+ } catch (Exception ex) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(ex.getMessage(), ex);
+ }
return null;
}
}
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Reference.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Reference.java?rev=797008&r1=797007&r2=797008&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Reference.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Reference.java Thu Jul 23 10:26:09 2009
@@ -107,7 +107,7 @@
* @param valueType
*/
public void setValueType(String valueType) {
- element.setAttribute("ValueType", valueType);
+ element.setAttributeNS(null, "ValueType", valueType);
}
/**
@@ -116,7 +116,7 @@
* @param uri
*/
public void setURI(String uri) {
- element.setAttribute("URI", uri);
+ element.setAttributeNS(null, "URI", uri);
}
/**
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=797008&r1=797007&r2=797008&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 Thu Jul 23 10:26:09 2009
@@ -404,9 +404,9 @@
private void createKeyIdentifier(Document doc, String uri, Node node, boolean base64) {
Element keyId = doc.createElementNS(WSConstants.WSSE_NS, "wsse:KeyIdentifier");
- keyId.setAttribute("ValueType", uri);
+ keyId.setAttributeNS(null, "ValueType", uri);
if (base64) {
- keyId.setAttribute("EncodingType", BinarySecurity.BASE64_ENCODING);
+ keyId.setAttributeNS(null, "EncodingType", BinarySecurity.BASE64_ENCODING);
}
keyId.appendChild(node);
@@ -541,6 +541,22 @@
element.appendChild(ref.getElement());
}
}
+
+
+ /**
+ * Set an unknown element.
+ *
+ * @param unknownElement the org.w3c.dom.Element to put into this
+ * SecurityTokenReference
+ */
+ public void setUnknownElement(Element unknownElement) {
+ Element elem = getFirstElement();
+ if (elem != null) {
+ element.replaceChild(unknownElement, elem);
+ } else {
+ element.appendChild(unknownElement);
+ }
+ }
/**
* Gets the certificate identified with X509 issuerSerial data.
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SignatureConfirmation.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SignatureConfirmation.java?rev=797008&r1=797007&r2=797008&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SignatureConfirmation.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SignatureConfirmation.java Thu Jul 23 10:26:09 2009
@@ -73,7 +73,7 @@
WSSecurityUtil.setNamespace(element, WSConstants.WSSE11_NS, WSConstants.WSSE11_PREFIX);
if (signVal != null) {
String sv = Base64.encode(signVal);
- element.setAttribute(SC_VALUE_ATTR, sv);
+ element.setAttributeNS(null, SC_VALUE_ATTR, sv);
}
}
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/UsernameToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/UsernameToken.java?rev=797008&r1=797007&r2=797008&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/UsernameToken.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/UsernameToken.java Thu Jul 23 10:26:09 2009
@@ -275,7 +275,7 @@
random.nextBytes(nonceValue);
elementNonce = doc.createElementNS(WSConstants.WSSE_NS, "wsse:" + WSConstants.NONCE_LN);
elementNonce.appendChild(doc.createTextNode(Base64.encode(nonceValue)));
- elementNonce.setAttribute("EncodingType", BASE64_ENCODING);
+ elementNonce.setAttributeNS(null, "EncodingType", BASE64_ENCODING);
element.appendChild(elementNonce);
}
@@ -465,7 +465,7 @@
node.setData(pwd);
}
if (passwordType != null) {
- elementPassword.setAttribute("Type", passwordType);
+ elementPassword.setAttributeNS(null, "Type", passwordType);
}
} catch (Exception e) {
if (DO_DEBUG) {
---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org