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/05/07 13:52:17 UTC
svn commit: r772622 - in
/webservices/wss4j/trunk/src/org/apache/ws/security: ./ message/
message/token/ processor/ saml/
Author: coheigea
Date: Thu May 7 11:52:16 2009
New Revision: 772622
URL: http://svn.apache.org/viewvc?rev=772622&view=rev
Log:
Removed all "instanceof Element/Text" calls with getNodeType()
Modified:
webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKEncrypt.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKSign.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityContextToken.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/UsernameToken.java
webservices/wss4j/trunk/src/org/apache/ws/security/processor/EncryptedKeyProcessor.java
webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java
webservices/wss4j/trunk/src/org/apache/ws/security/saml/SAMLUtil.java
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java?rev=772622&r1=772621&r2=772622&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/WSSecurityEngine.java Thu May 7 11:52:16 2009
@@ -312,7 +312,7 @@
final WSSConfig cfg = getWssConfig();
for (int i = 0; i < len; i++) {
elem = list.item(i);
- if (elem.getNodeType() != Node.ELEMENT_NODE) {
+ if (elem == null || elem.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
QName el = new QName(elem.getNamespaceURI(), elem.getLocalName());
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKEncrypt.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKEncrypt.java?rev=772622&r1=772621&r2=772622&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKEncrypt.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKEncrypt.java Thu May 7 11:52:16 2009
@@ -213,7 +213,7 @@
*/
public void addExternalRefElement(Element referenceList, WSSecHeader secHeader) {
Node node = dkt.getElement().getNextSibling();
- if (node instanceof Element) {
+ if (node != null && Node.ELEMENT_NODE == node.getNodeType()) {
secHeader.getSecurityHeader().insertBefore(referenceList, node);
} else {
// If (at this moment) DerivedKeyToken is the LAST element of
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKSign.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKSign.java?rev=772622&r1=772621&r2=772622&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKSign.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecDKSign.java Thu May 7 11:52:16 2009
@@ -179,7 +179,7 @@
Node parent = target;
NamedNodeMap attributes;
Node attribute;
- while (!(parent.getParentNode() instanceof Document)) {
+ while (!(Node.DOCUMENT_NODE == parent.getParentNode().getNodeType())) {
parent = parent.getParentNode();
attributes = parent.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java?rev=772622&r1=772621&r2=772622&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/WSSecSignature.java Thu May 7 11:52:16 2009
@@ -791,7 +791,7 @@
protected Set getInclusivePrefixes(Element target, boolean excludeVisible) {
Set result = new HashSet();
Node parent = target;
- while (!(parent.getParentNode() instanceof Document)) {
+ while (!(Node.DOCUMENT_NODE == parent.getParentNode().getNodeType())) {
parent = parent.getParentNode();
NamedNodeMap attributes = parent.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
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=772622&r1=772621&r2=772622&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 May 7 11:52:16 2009
@@ -50,8 +50,8 @@
* @throws WSSecurityException
*/
public BinarySecurity(Element elem) throws WSSecurityException {
- this.element = elem;
- QName el = new QName(this.element.getNamespaceURI(), this.element.getLocalName());
+ element = elem;
+ QName el = new QName(element.getNamespaceURI(), element.getLocalName());
if (!(el.equals(TOKEN_BST) || el.equals(TOKEN_KI))) {
throw new WSSecurityException(
WSSecurityException.INVALID_SECURITY_TOKEN,
@@ -92,9 +92,9 @@
* @param doc
*/
public BinarySecurity(Document doc) {
- this.element = doc.createElementNS(WSConstants.WSSE_NS, "wsse:BinarySecurityToken");
+ element = doc.createElementNS(WSConstants.WSSE_NS, "wsse:BinarySecurityToken");
setEncodingType(BASE64_ENCODING);
- this.element.appendChild(doc.createTextNode(""));
+ element.appendChild(doc.createTextNode(""));
}
/**
@@ -119,7 +119,7 @@
* @return TODO
*/
public String getValueType() {
- return this.element.getAttribute("ValueType");
+ return element.getAttribute("ValueType");
}
/**
@@ -128,7 +128,7 @@
* @param type
*/
public void setValueType(String type) {
- this.element.setAttributeNS(null, "ValueType", type);
+ element.setAttributeNS(null, "ValueType", type);
}
/**
@@ -137,7 +137,7 @@
* @return TODO
*/
public String getEncodingType() {
- return this.element.getAttribute("EncodingType");
+ return element.getAttribute("EncodingType");
}
/**
@@ -146,7 +146,7 @@
* @param encoding
*/
public void setEncodingType(String encoding) {
- this.element.setAttributeNS(null, "EncodingType", encoding);
+ element.setAttributeNS(null, "EncodingType", encoding);
}
/**
@@ -185,8 +185,8 @@
* @return TODO
*/
protected Text getFirstNode() {
- Node node = this.element.getFirstChild();
- return ((node != null) && node instanceof Text) ? (Text) node : null;
+ Node node = element.getFirstChild();
+ return (node != null && Node.TEXT_NODE == node.getNodeType()) ? (Text) node : null;
}
/**
@@ -195,7 +195,7 @@
* @return TODO
*/
public Element getElement() {
- return this.element;
+ return element;
}
/**
@@ -204,7 +204,7 @@
* @return TODO
*/
public String getID() {
- return this.element.getAttributeNS(WSConstants.WSU_NS, "Id");
+ return element.getAttributeNS(WSConstants.WSU_NS, "Id");
}
/**
@@ -213,7 +213,7 @@
* @param id
*/
public void setID(String id) {
- this.element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
+ element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
}
/**
@@ -222,6 +222,6 @@
* @return TODO
*/
public String toString() {
- return DOM2Writer.nodeToString((Node) this.element);
+ return DOM2Writer.nodeToString((Node)element);
}
}
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java?rev=772622&r1=772621&r2=772622&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/DerivedKeyToken.java Thu May 7 11:52:16 2009
@@ -87,10 +87,10 @@
public DerivedKeyToken(int version, Document doc) throws ConversationException {
log.debug("DerivedKeyToken: created");
- this.ns = ConversationConstants.getWSCNs(version);
- this.element =
+ ns = ConversationConstants.getWSCNs(version);
+ element =
doc.createElementNS(ns, "wsc:" + ConversationConstants.DERIVED_KEY_TOKEN_LN);
- WSSecurityUtil.setNamespace(this.element, ns, ConversationConstants.WSC_PREFIX);
+ WSSecurityUtil.setNamespace(element, ns, ConversationConstants.WSC_PREFIX);
}
/**
@@ -101,9 +101,9 @@
*/
public DerivedKeyToken(Element elem) throws WSSecurityException {
log.debug("DerivedKeyToken: created : element constructor");
- this.element = elem;
+ element = elem;
QName el =
- new QName(this.element.getNamespaceURI(), this.element.getLocalName());
+ new QName(element.getNamespaceURI(), element.getLocalName());
if (!(el.equals(ConversationConstants.DERIVED_KEY_TOKEN_QNAME_05_02) ||
el.equals(ConversationConstants.DERIVED_KEY_TOKEN_QNAME_05_12))) {
@@ -113,38 +113,38 @@
new Object[]{el}
);
}
- this.elementSecurityTokenReference =
+ elementSecurityTokenReference =
WSSecurityUtil.getDirectChildElement(
- this.element,
+ element,
ConversationConstants.SECURITY_TOKEN_REFERENCE_LN,
WSConstants.WSSE_NS
);
- this.ns = el.getNamespaceURI();
+ ns = el.getNamespaceURI();
- this.elementProperties =
+ elementProperties =
WSSecurityUtil.getDirectChildElement(
- this.element, ConversationConstants.PROPERTIES_LN, this.ns
+ element, ConversationConstants.PROPERTIES_LN, ns
);
- this.elementGeneration =
+ elementGeneration =
WSSecurityUtil.getDirectChildElement(
- this.element, ConversationConstants.GENERATION_LN, this.ns
+ element, ConversationConstants.GENERATION_LN, ns
);
- this.elementOffset =
+ elementOffset =
WSSecurityUtil.getDirectChildElement(
- this.element, ConversationConstants.OFFSET_LN, this.ns
+ element, ConversationConstants.OFFSET_LN, ns
);
- this.elementLength =
+ elementLength =
WSSecurityUtil.getDirectChildElement(
- this.element, ConversationConstants.LENGTH_LN, this.ns
+ element, ConversationConstants.LENGTH_LN, ns
);
- this.elementLabel =
+ elementLabel =
WSSecurityUtil.getDirectChildElement(
- this.element, ConversationConstants.LABEL_LN, this.ns
+ element, ConversationConstants.LABEL_LN, ns
);
- this.elementNonce =
+ elementNonce =
WSSecurityUtil.getDirectChildElement(
- this.element, ConversationConstants.NONCE_LN, this.ns
+ element, ConversationConstants.NONCE_LN, ns
);
}
@@ -163,13 +163,13 @@
* @param ref Security token reference
*/
public void setSecurityTokenReference(SecurityTokenReference ref) {
- this.elementSecurityTokenReference = ref.getElement();
- WSSecurityUtil.prependChildElement(this.element, ref.getElement());
+ elementSecurityTokenReference = ref.getElement();
+ WSSecurityUtil.prependChildElement(element, ref.getElement());
}
public void setSecurityTokenReference(Element elem) {
- this.elementSecurityTokenReference = elem;
- WSSecurityUtil.prependChildElement(this.element, elem);
+ elementSecurityTokenReference = elem;
+ WSSecurityUtil.prependChildElement(element, elem);
}
/**
@@ -179,8 +179,8 @@
* @throws WSSecurityException
*/
public SecurityTokenReference getSecurityTokenReference() throws WSSecurityException {
- if (this.elementSecurityTokenReference != null) {
- return new SecurityTokenReference(this.elementSecurityTokenReference);
+ if (elementSecurityTokenReference != null) {
+ return new SecurityTokenReference(elementSecurityTokenReference);
}
return null;
}
@@ -193,18 +193,18 @@
* @param propValue Value of the property
*/
private void addProperty(String propName, String propValue) {
- if (this.elementProperties == null) { //Create the properties element if it is not there
- this.elementProperties =
- this.element.getOwnerDocument().createElementNS(
- this.ns, "wsc:" + ConversationConstants.PROPERTIES_LN
+ if (elementProperties == null) { //Create the properties element if it is not there
+ elementProperties =
+ element.getOwnerDocument().createElementNS(
+ ns, "wsc:" + ConversationConstants.PROPERTIES_LN
);
- this.element.appendChild(this.elementProperties);
+ element.appendChild(elementProperties);
}
Element tempElement =
- this.element.getOwnerDocument().createElementNS(this.ns, "wsc:" + propName);
- tempElement.appendChild(this.element.getOwnerDocument().createTextNode(propValue));
+ element.getOwnerDocument().createElementNS(ns, "wsc:" + propName);
+ tempElement.appendChild(element.getOwnerDocument().createTextNode(propValue));
- this.elementProperties.appendChild(tempElement);
+ elementProperties.appendChild(tempElement);
}
/**
@@ -223,7 +223,7 @@
table.put("Name", name);
table.put("Label", label);
table.put("Nonce", nonce);
- this.setProperties(table);
+ setProperties(table);
}
/**
@@ -239,24 +239,24 @@
//Check whether this property is already there
//If so change the value
Node node =
- WSSecurityUtil.findElement(this.elementProperties, propertyName, this.ns);
- if (node instanceof Element) { //If the node is not null
+ WSSecurityUtil.findElement(elementProperties, propertyName, ns);
+ if (node != null && Node.ELEMENT_NODE == node.getNodeType()) { //If the node is not null
Text node1 = getFirstNode((Element) node);
node1.setData((String) properties.get(propertyName));
} else {
- this.addProperty(propertyName, (String) properties.get(propertyName));
+ addProperty(propertyName, (String) properties.get(propertyName));
}
}
}
public Hashtable getProperties() {
- if (this.elementProperties != null) {
+ if (elementProperties != null) {
Hashtable table = new Hashtable();
- NodeList nodes = this.elementProperties.getChildNodes();
+ NodeList nodes = elementProperties.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node tempNode = nodes.item(i);
- if (tempNode instanceof Element) {
- Text text = this.getFirstNode((Element) tempNode);
+ if (tempNode != null && Node.ELEMENT_NODE == tempNode.getNodeType()) {
+ Text text = getFirstNode((Element) tempNode);
table.put(tempNode.getNodeName(), text.getData());
}
}
@@ -270,19 +270,19 @@
* @param length The length of the derived key as a long
*/
public void setLength(int length) {
- this.elementLength =
- this.element.getOwnerDocument().createElementNS(
- this.ns, "wsc:" + ConversationConstants.LENGTH_LN
+ elementLength =
+ element.getOwnerDocument().createElementNS(
+ ns, "wsc:" + ConversationConstants.LENGTH_LN
);
- this.elementLength.appendChild(
- this.element.getOwnerDocument().createTextNode(Long.toString(length))
+ elementLength.appendChild(
+ element.getOwnerDocument().createTextNode(Long.toString(length))
);
- this.element.appendChild(this.elementLength);
+ element.appendChild(elementLength);
}
public int getLength() {
- if (this.elementLength != null) {
- return Integer.parseInt(getFirstNode(this.elementLength).getData());
+ if (elementLength != null) {
+ return Integer.parseInt(getFirstNode(elementLength).getData());
}
return -1;
}
@@ -294,15 +294,15 @@
*/
public void setOffset(int offset) throws ConversationException {
//This element MUST NOT be used if the <Generation> element is specified
- if (this.elementGeneration == null) {
- this.elementOffset =
- this.element.getOwnerDocument().createElementNS(
- this.ns, "wsc:" + ConversationConstants.OFFSET_LN
+ if (elementGeneration == null) {
+ elementOffset =
+ element.getOwnerDocument().createElementNS(
+ ns, "wsc:" + ConversationConstants.OFFSET_LN
);
- this.elementOffset.appendChild(
- this.element.getOwnerDocument().createTextNode(Integer.toString(offset))
+ elementOffset.appendChild(
+ element.getOwnerDocument().createTextNode(Integer.toString(offset))
);
- this.element.appendChild(this.elementOffset);
+ element.appendChild(elementOffset);
} else {
throw new ConversationException(
"Offset cannot be set along with generation - generation is already set"
@@ -312,8 +312,8 @@
}
public int getOffset() {
- if (this.elementOffset != null) {
- return Integer.parseInt(getFirstNode(this.elementOffset).getData());
+ if (elementOffset != null) {
+ return Integer.parseInt(getFirstNode(elementOffset).getData());
}
return -1;
}
@@ -323,18 +323,17 @@
*
* @param generation generation value as an integer
*/
- public void setGeneration(int generation) throws
- ConversationException {
+ public void setGeneration(int generation) throws ConversationException {
//This element MUST NOT be used if the <Offset> element is specified
- if (this.elementOffset == null) {
- this.elementGeneration =
- this.element.getOwnerDocument().createElementNS(
- this.ns, "wsc:" + ConversationConstants.GENERATION_LN
+ if (elementOffset == null) {
+ elementGeneration =
+ element.getOwnerDocument().createElementNS(
+ ns, "wsc:" + ConversationConstants.GENERATION_LN
);
- this.elementGeneration.appendChild(
- this.element.getOwnerDocument().createTextNode(Integer.toString(generation))
+ elementGeneration.appendChild(
+ element.getOwnerDocument().createTextNode(Integer.toString(generation))
);
- this.element.appendChild(this.elementGeneration);
+ element.appendChild(elementGeneration);
} else {
throw new ConversationException(
"Generation cannot be set along with offset - Offset is already set"
@@ -343,8 +342,8 @@
}
public int getGeneration() {
- if (this.elementGeneration != null) {
- return Integer.parseInt(getFirstNode(this.elementGeneration).getData());
+ if (elementGeneration != null) {
+ return Integer.parseInt(getFirstNode(elementGeneration).getData());
}
return -1;
}
@@ -355,12 +354,12 @@
* @param label Label value as a string
*/
public void setLabel(String label) {
- this.elementLabel =
- this.element.getOwnerDocument().createElementNS(
- this.ns, "wsc:" + ConversationConstants.LABEL_LN
+ elementLabel =
+ element.getOwnerDocument().createElementNS(
+ ns, "wsc:" + ConversationConstants.LABEL_LN
);
- this.elementLabel.appendChild(this.element.getOwnerDocument().createTextNode(label));
- this.element.appendChild(this.elementLabel);
+ elementLabel.appendChild(element.getOwnerDocument().createTextNode(label));
+ element.appendChild(elementLabel);
}
/**
@@ -369,12 +368,12 @@
* @param nonce Nonce value as a string
*/
public void setNonce(String nonce) {
- this.elementNonce =
- this.element.getOwnerDocument().createElementNS(
- this.ns, "wsc:" + ConversationConstants.NONCE_LN
+ elementNonce =
+ element.getOwnerDocument().createElementNS(
+ ns, "wsc:" + ConversationConstants.NONCE_LN
);
- this.elementNonce.appendChild(this.element.getOwnerDocument().createTextNode(nonce));
- this.element.appendChild(this.elementNonce);
+ elementNonce.appendChild(element.getOwnerDocument().createTextNode(nonce));
+ element.appendChild(elementNonce);
}
/**
@@ -383,8 +382,8 @@
* @return Label of the derived key token
*/
public String getLabel() {
- if (this.elementLabel != null) {
- return getFirstNode(this.elementLabel).getData();
+ if (elementLabel != null) {
+ return getFirstNode(elementLabel).getData();
}
return null;
}
@@ -395,8 +394,8 @@
* @return Nonce of the derived key token
*/
public String getNonce() {
- if (this.elementNonce != null) {
- return getFirstNode(this.elementNonce).getData();
+ if (elementNonce != null) {
+ return getFirstNode(elementNonce).getData();
}
return null;
}
@@ -410,7 +409,7 @@
*/
private Text getFirstNode(Element e) {
Node node = e.getFirstChild();
- return (node instanceof Text) ? (Text) node : null;
+ return (node != null && Node.TEXT_NODE == node.getNodeType()) ? (Text) node : null;
}
/**
@@ -419,7 +418,7 @@
* @return the DerivedKeyToken element
*/
public Element getElement() {
- return this.element;
+ return element;
}
/**
@@ -428,7 +427,7 @@
* @return a XML string representation
*/
public String toString() {
- return DOM2Writer.nodeToString((Node) this.element);
+ return DOM2Writer.nodeToString((Node)element);
}
/**
@@ -438,7 +437,7 @@
* DerivedKeyToken
*/
public String getID() {
- return this.element.getAttributeNS(WSConstants.WSU_NS, "Id");
+ return element.getAttributeNS(WSConstants.WSU_NS, "Id");
}
/**
@@ -448,7 +447,7 @@
* DerivedKeyToken
*/
public void setID(String id) {
- this.element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
+ element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
}
/**
@@ -458,7 +457,7 @@
* DerivedKeyToken
*/
public String getAlgorithm() {
- String algo = this.element.getAttributeNS(this.ns, "Algorithm");
+ String algo = element.getAttributeNS(ns, "Algorithm");
if (algo == null || algo.equals("")) {
return ConversationConstants.DerivationAlgorithm.P_SHA_1;
} else {
@@ -473,8 +472,8 @@
* DerivedKeyToken
*/
public void setAlgorithm(String algo) {
- this.element.setAttributeNS(
- this.ns, ConversationConstants.WSC_PREFIX + ":Algorithm", algo
+ element.setAttributeNS(
+ ns, ConversationConstants.WSC_PREFIX + ":Algorithm", algo
);
}
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityContextToken.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityContextToken.java?rev=772622&r1=772621&r2=772622&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityContextToken.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityContextToken.java Thu May 7 11:52:16 2009
@@ -77,21 +77,21 @@
String ns = ConversationConstants.getWSCNs(version);
- this.element =
+ element =
doc.createElementNS(ns, "wsc:" + ConversationConstants.SECURITY_CONTEXT_TOKEN_LN);
- WSSecurityUtil.setNamespace(this.element, ns, ConversationConstants.WSC_PREFIX);
+ WSSecurityUtil.setNamespace(element, ns, ConversationConstants.WSC_PREFIX);
- this.elementIdentifier =
+ elementIdentifier =
doc.createElementNS(ns, "wsc:" + ConversationConstants.IDENTIFIER_LN);
- this.element.appendChild(this.elementIdentifier);
+ element.appendChild(elementIdentifier);
String uuid = UUIDGenerator.getUUID();
- this.elementIdentifier.appendChild(doc.createTextNode(uuid));
+ elementIdentifier.appendChild(doc.createTextNode(uuid));
- this.setID(WSSConfig.getDefaultWSConfig().getIdAllocator().createSecureId("sctId-", this.element));
+ setID(WSSConfig.getDefaultWSConfig().getIdAllocator().createSecureId("sctId-", element));
}
/**
@@ -103,17 +103,17 @@
String ns = ConversationConstants.getWSCNs(version);
- this.element =
+ element =
doc.createElementNS(ns, "wsc:" + ConversationConstants.SECURITY_CONTEXT_TOKEN_LN);
- WSSecurityUtil.setNamespace(this.element, ns, ConversationConstants.WSC_PREFIX);
+ WSSecurityUtil.setNamespace(element, ns, ConversationConstants.WSC_PREFIX);
- this.elementIdentifier =
+ elementIdentifier =
doc.createElementNS(ns, "wsc:" + ConversationConstants.IDENTIFIER_LN);
- this.element.appendChild(this.elementIdentifier);
+ element.appendChild(elementIdentifier);
- this.elementIdentifier.appendChild(doc.createTextNode(uuid));
+ elementIdentifier.appendChild(doc.createTextNode(uuid));
}
@@ -124,8 +124,8 @@
* @throws WSSecurityException If the element passed in in not a security context token
*/
public SecurityContextToken(Element elem) throws WSSecurityException {
- this.element = elem;
- QName el = new QName(this.element.getNamespaceURI(), this.element.getLocalName());
+ element = elem;
+ QName el = new QName(element.getNamespaceURI(), element.getLocalName());
// If the element is not a security context token, throw an exception
if (!(el.equals(ConversationConstants.SECURITY_CTX_TOKEN_QNAME_05_02) ||
@@ -138,7 +138,7 @@
);
}
- this.elementIdentifier =
+ elementIdentifier =
WSSecurityUtil.getDirectChildElement(
element,
ConversationConstants.IDENTIFIER_LN,
@@ -168,14 +168,14 @@
* @return the data from the identifier element.
*/
public String getIdentifier() {
- if (this.elementIdentifier != null) {
- return getFirstNode(this.elementIdentifier).getData();
+ if (elementIdentifier != null) {
+ return getFirstNode(elementIdentifier).getData();
}
return null;
}
public void setElement(Element elem) {
- this.element.appendChild(elem);
+ element.appendChild(elem);
}
/**
@@ -187,7 +187,7 @@
*/
private Text getFirstNode(Element e) {
Node node = e.getFirstChild();
- return (node instanceof Text) ? (Text) node : null;
+ return (node != null && Node.TEXT_NODE == node.getNodeType()) ? (Text) node : null;
}
/**
@@ -196,7 +196,7 @@
* @return the <code>wsse:UsernameToken</code> element
*/
public Element getElement() {
- return this.element;
+ return element;
}
/**
@@ -205,7 +205,7 @@
* @return a XML string representation
*/
public String toString() {
- return DOM2Writer.nodeToString((Node) this.element);
+ return DOM2Writer.nodeToString((Node)element);
}
/**
@@ -215,7 +215,7 @@
* SecurityContextToken
*/
public String getID() {
- return this.element.getAttributeNS(WSConstants.WSU_NS, "Id");
+ return element.getAttributeNS(WSConstants.WSU_NS, "Id");
}
/**
@@ -225,7 +225,7 @@
* SecurityContextToken
*/
public void setID(String id) {
- this.element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
+ element.setAttributeNS(WSConstants.WSU_NS, WSConstants.WSU_PREFIX + ":Id", id);
}
}
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=772622&r1=772621&r2=772622&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 May 7 11:52:16 2009
@@ -423,11 +423,11 @@
* @return the first <code>Element</code> child node
*/
public Element getFirstElement() {
- for (Node currentChild = this.element.getFirstChild();
+ for (Node currentChild = element.getFirstChild();
currentChild != null;
currentChild = currentChild.getNextSibling()
) {
- if (currentChild instanceof Element) {
+ if (Node.ELEMENT_NODE == currentChild.getNodeType()) {
return (Element) currentChild;
}
}
@@ -460,7 +460,7 @@
if (node == null) {
return null;
}
- if (node.getNodeType() == Node.TEXT_NODE) {
+ if (Node.TEXT_NODE == node.getNodeType()) {
byte[] thumb = Base64.decode(((Text) node).getData());
alias = crypto.getAliasForX509CertThumb(thumb);
}
@@ -699,7 +699,7 @@
int result = 0;
for (int i = 0; i < childNodes.getLength(); i++) {
Node n = childNodes.item(i);
- if (n.getNodeType() == Node.ELEMENT_NODE) {
+ if (n != null && n.getNodeType() == Node.ELEMENT_NODE) {
String ns = n.getNamespaceURI();
String name = n.getLocalName();
if ((((namespace != null) && namespace.equals(ns))
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java?rev=772622&r1=772621&r2=772622&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java Thu May 7 11:52:16 2009
@@ -74,7 +74,7 @@
currentChild != null;
currentChild = currentChild.getNextSibling()
) {
- if (currentChild instanceof Element) {
+ if (Node.ELEMENT_NODE == currentChild.getNodeType()) {
Element currentChildElement = (Element) currentChild;
if (WSConstants.CREATED_LN.equals(currentChild.getLocalName()) &&
WSConstants.WSU_NS.equals(currentChild.getNamespaceURI())) {
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=772622&r1=772621&r2=772622&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 May 7 11:52:16 2009
@@ -492,7 +492,7 @@
*/
private Text getFirstNode(Element e) {
Node node = e.getFirstChild();
- return (node instanceof Text) ? (Text) node : null;
+ return (node != null && Node.TEXT_NODE == node.getNodeType()) ? (Text) node : null;
}
/**
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=772622&r1=772621&r2=772622&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 Thu May 7 11:52:16 2009
@@ -194,7 +194,7 @@
node != null;
node = node.getNextSibling()
) {
- if (node.getNodeType() != Node.ELEMENT_NODE) {
+ if (Node.ELEMENT_NODE != node.getNodeType()) {
continue;
}
if (!node.getNamespaceURI().equals(WSConstants.ENC_NS)) {
@@ -242,7 +242,7 @@
int iMax = children.getLength();
for (int i = 0; i < iMax; i++) {
Node curr = children.item(i);
- if (curr.getNodeType() == Node.TEXT_NODE) {
+ if (curr != null && Node.TEXT_NODE == curr.getNodeType()) {
sb.append(((Text) curr).getData());
}
}
@@ -541,7 +541,7 @@
pos.hasNext();
) {
Node node = (Node) pos.next();
- if (node instanceof Element) {
+ if (node != null && Node.ELEMENT_NODE == node.getNodeType()) {
if (!Constants.SignatureSpecNS.equals(node.getNamespaceURI()) &&
node.getAttributes().getNamedItemNS(WSConstants.WSU_NS, "Id") == null) {
String wsuPrefix =
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java?rev=772622&r1=772621&r2=772622&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/processor/ReferenceListProcessor.java Thu May 7 11:52:16 2009
@@ -222,7 +222,7 @@
pos.hasNext();
) {
Node node = (Node) pos.next();
- if (node instanceof Element) {
+ if (node != null && Node.ELEMENT_NODE == node.getNodeType()) {
if(!Constants.SignatureSpecNS.equals(node.getNamespaceURI())
&& node.getAttributes().getNamedItemNS(WSConstants.WSU_NS, "Id") == null) {
String wsuPrefix =
Modified: webservices/wss4j/trunk/src/org/apache/ws/security/saml/SAMLUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/saml/SAMLUtil.java?rev=772622&r1=772621&r2=772622&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/saml/SAMLUtil.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/saml/SAMLUtil.java Thu May 7 11:52:16 2009
@@ -112,7 +112,7 @@
for (int i = 0; i < len; i++) {
Node child = children.item(i);
- if (child.getNodeType() != Node.ELEMENT_NODE) {
+ if (child == null || child.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
QName el = new QName(child.getNamespaceURI(), child.getLocalName());
---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org