You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2015/10/23 11:34:20 UTC
svn commit: r1710156 - in /webservices/wss4j/trunk:
ws-security-common/src/main/java/org/apache/wss4j/common/cache/
ws-security-common/src/main/java/org/apache/wss4j/common/crypto/
ws-security-common/src/main/java/org/apache/wss4j/common/saml/ ws-secur...
Author: coheigea
Date: Fri Oct 23 09:34:20 2015
New Revision: 1710156
URL: http://svn.apache.org/viewvc?rev=1710156&view=rev
Log:
More cleanup
Modified:
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/Merlin.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/SamlAssertionWrapper.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/KeyInfoBean.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ProxyRestrictionBean.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/Loader.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/NSStack.java
webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/UsernameTokenUtil.java
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSDocInfo.java
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java?rev=1710156&r1=1710155&r2=1710156&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java Fri Oct 23 09:34:20 2015
@@ -39,7 +39,7 @@ public class EHCacheReplayCache implemen
public static final long MAX_TTL = DEFAULT_TTL * 12L;
protected Ehcache cache;
protected CacheManager cacheManager;
- protected long ttl = DEFAULT_TTL;
+ private long ttl = DEFAULT_TTL;
public EHCacheReplayCache(String key, URL configFileURL) {
this(key, EHCacheManagerHolder.getCacheManager("", configFileURL));
@@ -66,7 +66,7 @@ public class EHCacheReplayCache implemen
}
private static class RefCountCache extends Cache {
- AtomicInteger count = new AtomicInteger();
+ private AtomicInteger count = new AtomicInteger();
public RefCountCache(CacheConfiguration cc) {
super(cc);
}
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/Merlin.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/Merlin.java?rev=1710156&r1=1710155&r2=1710156&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/Merlin.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/Merlin.java Fri Oct 23 09:34:20 2015
@@ -138,7 +138,7 @@ public class Merlin extends CryptoBase {
truststore = KeyStore.getInstance(KeyStore.getDefaultType());
truststore.load(cacertsIs, cacertsPasswd.toCharArray());
- loadCACerts = true;
+ this.loadCACerts = true;
} catch (Exception e) {
LOG.warn("CA certs could not be loaded: " + e.getMessage());
}
@@ -683,17 +683,18 @@ public class Merlin extends CryptoBase {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
new Object[] {msg});
}
- if (password == null && privatePasswordSet) {
- password = properties.getProperty(PREFIX + KEYSTORE_PRIVATE_PASSWORD);
- if (password == null) {
- password = properties.getProperty(OLD_PREFIX + KEYSTORE_PRIVATE_PASSWORD);
+ String pwd = password;
+ if (pwd == null && privatePasswordSet) {
+ pwd = properties.getProperty(PREFIX + KEYSTORE_PRIVATE_PASSWORD);
+ if (pwd == null) {
+ pwd = properties.getProperty(OLD_PREFIX + KEYSTORE_PRIVATE_PASSWORD);
}
- if (password != null) {
- password = password.trim();
+ if (pwd != null) {
+ pwd = pwd.trim();
}
}
- Key keyTmp = keystore.getKey(identifier, password == null
- ? new char[]{} : password.toCharArray());
+ Key keyTmp = keystore.getKey(identifier, pwd == null
+ ? new char[]{} : pwd.toCharArray());
if (!(keyTmp instanceof PrivateKey)) {
String msg = "Key is not a private key, alias: [" + identifier + "]";
String logMsg = createKeyStoreErrorMessage(keystore);
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java?rev=1710156&r1=1710155&r2=1710156&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java Fri Oct 23 09:34:20 2015
@@ -31,7 +31,7 @@ import org.opensaml.core.xml.config.XMLO
/**
* This class intializes the Opensaml library.
*/
-public class OpenSAMLBootstrap {
+public final class OpenSAMLBootstrap {
/** List of default configuration files. */
private static final String[] xmlConfigs = {
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/SamlAssertionWrapper.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/SamlAssertionWrapper.java?rev=1710156&r1=1710155&r2=1710156&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/SamlAssertionWrapper.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/SamlAssertionWrapper.java Fri Oct 23 09:34:20 2015
@@ -687,9 +687,9 @@ public class SamlAssertionWrapper {
"The SAML version was null in getSamlVersion(). Recomputing SAML version..."
);
}
- if (samlObject != null && samlObject instanceof org.opensaml.saml.saml1.core.Assertion) {
+ if (samlObject instanceof org.opensaml.saml.saml1.core.Assertion) {
samlVersion = SAMLVersion.VERSION_11;
- } else if (samlObject != null && samlObject instanceof org.opensaml.saml.saml2.core.Assertion) {
+ } else if (samlObject instanceof org.opensaml.saml.saml2.core.Assertion) {
samlVersion = SAMLVersion.VERSION_20;
} else {
// We are only supporting SAML v1.1 or SAML v2.0 at this time.
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java?rev=1710156&r1=1710155&r2=1710156&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java Fri Oct 23 09:34:20 2015
@@ -207,7 +207,9 @@ public class ConditionsBean {
ConditionsBean that = (ConditionsBean) o;
- if (tokenPeriodSeconds != that.tokenPeriodSeconds) return false;
+ if (tokenPeriodSeconds != that.tokenPeriodSeconds) {
+ return false;
+ }
if (notBefore == null && that.notBefore != null) {
return false;
@@ -228,7 +230,9 @@ public class ConditionsBean {
return false;
}
- if (oneTimeUse != that.oneTimeUse) return false;
+ if (oneTimeUse != that.oneTimeUse) {
+ return false;
+ }
if (proxyRestriction == null && that.proxyRestriction != null) {
return false;
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/KeyInfoBean.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/KeyInfoBean.java?rev=1710156&r1=1710155&r2=1710156&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/KeyInfoBean.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/KeyInfoBean.java Fri Oct 23 09:34:20 2015
@@ -143,7 +143,9 @@ public class KeyInfoBean {
KeyInfoBean that = (KeyInfoBean) o;
- if (certIdentifier != that.certIdentifier) return false;
+ if (certIdentifier != that.certIdentifier) {
+ return false;
+ }
if (cert == null && that.cert != null) {
return false;
} else if (cert != null && !cert.equals(that.cert)) {
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ProxyRestrictionBean.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ProxyRestrictionBean.java?rev=1710156&r1=1710155&r2=1710156&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ProxyRestrictionBean.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ProxyRestrictionBean.java Fri Oct 23 09:34:20 2015
@@ -85,7 +85,9 @@ public class ProxyRestrictionBean {
ProxyRestrictionBean that = (ProxyRestrictionBean) o;
- if (count != that.count) return false;
+ if (count != that.count) {
+ return false;
+ }
if (!audienceURIs.equals(that.audienceURIs)) {
return false;
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/Loader.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/Loader.java?rev=1710156&r1=1710155&r2=1710156&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/Loader.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/Loader.java Fri Oct 23 09:34:20 2015
@@ -30,9 +30,13 @@ import java.security.PrivilegedAction;
* Load resources (or images) from various sources.
* <p/>
*/
-public class Loader {
+public final class Loader {
private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(Loader.class);
+
+ private Loader() {
+ // complete
+ }
/**
* This method will search for <code>resource</code> in different
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/NSStack.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/NSStack.java?rev=1710156&r1=1710155&r2=1710156&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/NSStack.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/NSStack.java Fri Oct 23 09:34:20 2015
@@ -254,16 +254,17 @@ public class NSStack {
* Given a prefix, return the associated namespace (if any).
*/
public String getNamespaceURI(String prefix) {
- if (prefix == null) {
- prefix = "";
+ String pfix = prefix;
+ if (pfix == null) {
+ pfix = "";
}
- int hash = prefix.hashCode();
+ int hash = pfix.hashCode();
for (int cursor = top; cursor > 0; cursor--) {
Mapping map = stack[cursor];
if (map == null) {
continue;
}
- if (map.getPrefixHash() == hash && map.getPrefix().equals(prefix)) {
+ if (map.getPrefixHash() == hash && map.getPrefix().equals(pfix)) {
return map.getNamespaceURI();
}
}
Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/UsernameTokenUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/UsernameTokenUtil.java?rev=1710156&r1=1710155&r2=1710156&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/UsernameTokenUtil.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/util/UsernameTokenUtil.java Fri Oct 23 09:34:20 2015
@@ -51,10 +51,6 @@ public final class UsernameTokenUtil {
byte[] salt,
int iteration
) throws WSSecurityException {
- if (iteration == 0) {
- iteration = DEFAULT_ITERATION;
- }
-
byte[] pwSalt = new byte[salt.length + password.length];
System.arraycopy(password, 0, pwSalt, 0, password.length);
System.arraycopy(salt, 0, pwSalt, password.length, salt.length);
@@ -77,7 +73,11 @@ public final class UsernameTokenUtil {
//
// Perform the 1st up to iteration-1 hash rounds
//
- for (int i = 1; i < iteration; i++) {
+ int iter = iteration;
+ if (iter <= 0) {
+ iter = DEFAULT_ITERATION;
+ }
+ for (int i = 1; i < iter; i++) {
k = sha.digest(k);
}
return k;
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSDocInfo.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSDocInfo.java?rev=1710156&r1=1710155&r2=1710156&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSDocInfo.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/WSDocInfo.java Fri Oct 23 09:34:20 2015
@@ -353,9 +353,9 @@ public class WSDocInfo {
}
private static class TokenValue {
- final String idName;
- final String idNamespace;
- final Element token;
+ private final String idName;
+ private final String idNamespace;
+ private final Element token;
public TokenValue(String idName, String idNamespace, Element token) {
this.idName = idName;