Author: coheigea
Date: Mon May 18 09:56:24 2015
New Revision: 1679976
URL: http://svn.apache.org/r1679976
Log:
Some code cleanup
Modified:
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/SecurityTokenReference.java
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
Modified:
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/SecurityTokenReference.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/SecurityTokenReference.java?rev=1679976&r1=1679975&r2=1679976&view=diff
==============================================================================
---
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/SecurityTokenReference.java
(original)
+++
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/token/SecurityTokenReference.java
Mon May 18 09:56:24 2015
@@ -599,7 +599,7 @@ public class SecurityTokenReference {
if (!WSS4JConstants.WSS_SAML_KI_VALUE_TYPE.equals(valueType)
&& !WSS4JConstants.WSS_SAML2_KI_VALUE_TYPE.equals(valueType)
- && (encodingType == null || "".equals(encodingType))) {
+ && "".equals(encodingType)) {
bspEnforcer.handleBSPRule(BSPRule.R3070);
}
} else if ("Embedded".equals(child.getLocalName())) {
Modified:
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java?rev=1679976&r1=1679975&r2=1679976&view=diff
==============================================================================
---
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
(original)
+++
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/DerivedKeyToken.java
Mon May 18 09:56:24 2015
@@ -22,6 +22,7 @@ package org.apache.wss4j.dom.message.tok
import java.security.Principal;
import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import javax.xml.namespace.QName;
@@ -92,7 +93,8 @@ public class DerivedKeyToken {
ns = ConversationConstants.getWSCNs(version);
element =
- doc.createElementNS(ns, "wsc:" +
ConversationConstants.DERIVED_KEY_TOKEN_LN);
+ doc.createElementNS(ns, ConversationConstants.WSC_PREFIX + ":"
+ + ConversationConstants.DERIVED_KEY_TOKEN_LN);
XMLUtils.setNamespace(element, ns, ConversationConstants.WSC_PREFIX);
bspEnforcer = new BSPEnforcer();
}
@@ -208,12 +210,13 @@ public class DerivedKeyToken {
if (elementProperties == null) { //Create the properties element if it
is not there
elementProperties =
element.getOwnerDocument().createElementNS(
- ns, "wsc:" + ConversationConstants.PROPERTIES_LN
+ ns, ConversationConstants.WSC_PREFIX + ":" +
ConversationConstants.PROPERTIES_LN
);
element.appendChild(elementProperties);
}
Element tempElement =
- element.getOwnerDocument().createElementNS(ns, "wsc:" + propName);
+ element.getOwnerDocument().createElementNS(ns,
ConversationConstants.WSC_PREFIX + ":"
+ + propName);
tempElement.appendChild(element.getOwnerDocument().createTextNode(propValue));
elementProperties.appendChild(tempElement);
@@ -246,8 +249,8 @@ public class DerivedKeyToken {
*/
public void setProperties(Map<String, String> properties) {
if (properties != null && !properties.isEmpty()) {
- for (String key : properties.keySet()) {
- String propertyName = properties.get(key); //Get the property
name
+ for (Entry<String, String> entry : properties.entrySet()) {
+ String propertyName = entry.getValue();
//Check whether this property is already there
//If so change the value
Element node =
@@ -286,7 +289,7 @@ public class DerivedKeyToken {
public void setLength(int length) {
elementLength =
element.getOwnerDocument().createElementNS(
- ns, "wsc:" + ConversationConstants.LENGTH_LN
+ ns, ConversationConstants.WSC_PREFIX + ":" +
ConversationConstants.LENGTH_LN
);
elementLength.appendChild(
element.getOwnerDocument().createTextNode(Long.toString(length))
@@ -311,7 +314,7 @@ public class DerivedKeyToken {
if (elementGeneration == null) {
elementOffset =
element.getOwnerDocument().createElementNS(
- ns, "wsc:" + ConversationConstants.OFFSET_LN
+ ns, ConversationConstants.WSC_PREFIX + ":" +
ConversationConstants.OFFSET_LN
);
elementOffset.appendChild(
element.getOwnerDocument().createTextNode(Integer.toString(offset))
@@ -340,7 +343,7 @@ public class DerivedKeyToken {
if (elementOffset == null) {
elementGeneration =
element.getOwnerDocument().createElementNS(
- ns, "wsc:" + ConversationConstants.GENERATION_LN
+ ns, ConversationConstants.WSC_PREFIX + ":" +
ConversationConstants.GENERATION_LN
);
elementGeneration.appendChild(
element.getOwnerDocument().createTextNode(Integer.toString(generation))
@@ -366,7 +369,7 @@ public class DerivedKeyToken {
public void setLabel(String label) {
elementLabel =
element.getOwnerDocument().createElementNS(
- ns, "wsc:" + ConversationConstants.LABEL_LN
+ ns, ConversationConstants.WSC_PREFIX + ":" +
ConversationConstants.LABEL_LN
);
elementLabel.appendChild(element.getOwnerDocument().createTextNode(label));
element.appendChild(elementLabel);
@@ -380,7 +383,7 @@ public class DerivedKeyToken {
public void setNonce(String nonce) {
elementNonce =
element.getOwnerDocument().createElementNS(
- ns, "wsc:" + ConversationConstants.NONCE_LN
+ ns, ConversationConstants.WSC_PREFIX + ":" +
ConversationConstants.NONCE_LN
);
elementNonce.appendChild(element.getOwnerDocument().createTextNode(nonce));
element.appendChild(elementNonce);
@@ -536,10 +539,11 @@ public class DerivedKeyToken {
System.arraycopy(labelBytes, 0, seed, 0, labelBytes.length);
System.arraycopy(nonce, 0, seed, labelBytes.length, nonce.length);
- if (length <= 0) {
- length = getLength();
+ int keyLength = length;
+ if (keyLength <= 0) {
+ keyLength = getLength();
}
- return algo.createKey(secret, seed, getOffset(), length);
+ return algo.createKey(secret, seed, getOffset(), keyLength);
} catch (Exception e) {
throw new WSSecurityException(
Modified:
webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java?rev=1679976&r1=1679975&r2=1679976&view=diff
==============================================================================
---
webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java
(original)
+++
webservices/wss4j/trunk/ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java
Mon May 18 09:56:24 2015
@@ -119,7 +119,7 @@ public class PolicyEnforcer implements S
// HttpsToken Algorithms
//unused tokens must be checked (algorithms etc)
- protected static final transient org.slf4j.Logger log =
+ private static final transient org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(PolicyEnforcer.class);
private static final QName SOAP11_FAULT = new
QName(WSSConstants.NS_SOAP11, "Fault");
@@ -659,7 +659,7 @@ public class PolicyEnforcer implements S
while (assertableIterator.hasNext()) {
Assertable assertable = assertableIterator.next();
if (!assertable.isAsserted() &&
!assertable.isLogged()) {
- log.error(entry.getKey().getName() + " not
satisfied: " + assertable.getErrorMessage());
+ LOG.error(entry.getKey().getName() + " not
satisfied: " + assertable.getErrorMessage());
assertable.setLogged(true);
}
}
@@ -672,7 +672,7 @@ public class PolicyEnforcer implements S
@Override
public synchronized void registerSecurityEvent(SecurityEvent
securityEvent) throws WSSecurityException {
- if (securityEvent instanceof NoSecuritySecurityEvent) {
+ if (!noSecurityHeader && securityEvent instanceof
NoSecuritySecurityEvent) {
noSecurityHeader = true;
}
@@ -687,8 +687,8 @@ public class PolicyEnforcer implements S
if
(WSSecurityEventConstants.Operation.equals(securityEvent.getSecurityEventType()))
{
operationSecurityEventOccured = true;
final OperationSecurityEvent operationSecurityEvent =
(OperationSecurityEvent) securityEvent;
- if (SOAP11_FAULT.equals(operationSecurityEvent.getOperation())
- || SOAP12_FAULT.equals(operationSecurityEvent.getOperation()))
{
+ if (!faultOccurred &&
(SOAP11_FAULT.equals(operationSecurityEvent.getOperation())
+ ||
SOAP12_FAULT.equals(operationSecurityEvent.getOperation()))) {
faultOccurred = true;
}
Modified:
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java?rev=1679976&r1=1679975&r2=1679976&view=diff
==============================================================================
---
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java
(original)
+++
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/ConfigurationConverter.java
Mon May 18 09:56:24 2015
@@ -641,8 +641,8 @@ public final class ConfigurationConverte
final Map<QName, Validator> validatorMap =
(Map<QName,
Validator>)config.get(ConfigurationConstants.VALIDATOR_MAP);
if (validatorMap != null) {
- for (QName key : validatorMap.keySet()) {
- properties.addValidator(key, validatorMap.get(key));
+ for (Map.Entry<QName, Validator> entry : validatorMap.entrySet()) {
+ properties.addValidator(entry.getKey(), entry.getValue());
}
}
Modified:
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java?rev=1679976&r1=1679975&r2=1679976&view=diff
==============================================================================
---
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
(original)
+++
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
Mon May 18 09:56:24 2015
@@ -196,7 +196,7 @@ public class EncryptOutputProcessor exte
final String externalReference = securePart.getExternalReference();
if (externalReference != null &&
externalReference.startsWith("cid:")) {
attachmentSecurePart = securePart;
- externalId = externalReference.substring(4);
+ externalId = externalReference.substring("cid:".length());
break;
}
}
@@ -454,7 +454,7 @@ public class EncryptOutputProcessor exte
if (use200512Namespace) {
attributes.add(createAttribute(WSSConstants.ATT_NULL_ValueType,
WSSConstants.NS_WSC_05_12 + "/sct"));
} else {
-
attributes.add(createAttribute(WSSConstants.ATT_NULL_ValueType,
WSSConstants.NS_WSC_05_12 + "/sct"));
+
attributes.add(createAttribute(WSSConstants.ATT_NULL_ValueType,
WSSConstants.NS_WSC_05_02 + "/sct"));
}
} else if
(WSSecurityTokenConstants.EncryptedKeyToken.equals(securityToken.getTokenType()))
{
attributes.add(createAttribute(WSSConstants.ATT_NULL_ValueType,
WSSConstants.NS_WSS_ENC_KEY_VALUE_TYPE));
Modified:
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java?rev=1679976&r1=1679975&r2=1679976&view=diff
==============================================================================
---
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
(original)
+++
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
Mon May 18 09:56:24 2015
@@ -161,7 +161,7 @@ public class WSSSignatureOutputProcessor
}
AttachmentRequestCallback attachmentRequestCallback = new
AttachmentRequestCallback();
- String id = securePart.getExternalReference().substring(4);
+ String id =
securePart.getExternalReference().substring("cid:".length());
attachmentRequestCallback.setAttachmentId(id);
try {
attachmentCallbackHandler.handle(new
Callback[]{attachmentRequestCallback});