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:37:49 UTC
svn commit: r1710160 - in
/webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common:
cache/ crypto/ saml/ saml/bean/ util/
Author: coheigea
Date: Fri Oct 23 09:37:49 2015
New Revision: 1710160
URL: http://svn.apache.org/viewvc?rev=1710160&view=rev
Log:
More cleanup
Conflicts:
ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java
ws-security-common/src/main/java/org/apache/wss4j/common/saml/SamlAssertionWrapper.java
ws-security-dom/src/main/java/org/apache/wss4j/dom/WSDocInfo.java
Modified:
webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java
webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/Merlin.java
webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java
webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java
webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/KeyInfoBean.java
webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ProxyRestrictionBean.java
webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/Loader.java
webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/NSStack.java
webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/UsernameTokenUtil.java
Modified: webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java?rev=1710160&r1=1710159&r2=1710160&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/cache/EHCacheReplayCache.java Fri Oct 23 09:37:49 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/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/Merlin.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/Merlin.java?rev=1710160&r1=1710159&r2=1710160&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/Merlin.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/Merlin.java Fri Oct 23 09:37:49 2015
@@ -140,7 +140,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());
} finally {
@@ -754,17 +754,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/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java?rev=1710160&r1=1710159&r2=1710160&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLBootstrap.java Fri Oct 23 09:37:49 2015
@@ -36,7 +36,7 @@ import org.opensaml.xml.parse.XMLParserE
* This class intializes the Opensaml library. It is necessary to override DefaultBootstrap
* to avoid instantiating Velocity, which we do not need in WSS4J.
*/
-public class OpenSAMLBootstrap extends DefaultBootstrap {
+public final class OpenSAMLBootstrap extends DefaultBootstrap {
/** List of default XMLTooling configuration files. */
private static final String[] xmlToolingConfigs = {
Modified: webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java?rev=1710160&r1=1710159&r2=1710160&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ConditionsBean.java Fri Oct 23 09:37:49 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/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/KeyInfoBean.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/KeyInfoBean.java?rev=1710160&r1=1710159&r2=1710160&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/KeyInfoBean.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/KeyInfoBean.java Fri Oct 23 09:37:49 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/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ProxyRestrictionBean.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ProxyRestrictionBean.java?rev=1710160&r1=1710159&r2=1710160&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ProxyRestrictionBean.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/saml/bean/ProxyRestrictionBean.java Fri Oct 23 09:37:49 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/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/Loader.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/Loader.java?rev=1710160&r1=1710159&r2=1710160&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/Loader.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/Loader.java Fri Oct 23 09:37:49 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/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/NSStack.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/NSStack.java?rev=1710160&r1=1710159&r2=1710160&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/NSStack.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/NSStack.java Fri Oct 23 09:37:49 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/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/UsernameTokenUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/UsernameTokenUtil.java?rev=1710160&r1=1710159&r2=1710160&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/UsernameTokenUtil.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/main/java/org/apache/wss4j/common/util/UsernameTokenUtil.java Fri Oct 23 09:37:49 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;