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 2017/03/06 14:56:53 UTC

svn commit: r1785658 - in /webservices/wss4j/trunk: ws-security-common/src/main/java/org/apache/wss4j/common/crypto/ ws-security-common/src/main/java/org/apache/wss4j/common/saml/ ws-security-common/src/main/java/org/apache/wss4j/common/spnego/ ws-secu...

Author: coheigea
Date: Mon Mar  6 14:56:53 2017
New Revision: 1785658

URL: http://svn.apache.org/viewvc?rev=1785658&view=rev
Log:
Some log parameterization work

Modified:
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CertificateStore.java
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/DefaultSpnegoClientAction.java
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/DefaultSpnegoServiceAction.java
    webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/SpnegoTokenContext.java
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/X509SecurityTokenImpl.java
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/UsernameTokenValidatorImpl.java

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CertificateStore.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CertificateStore.java?rev=1785658&r1=1785657&r2=1785658&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CertificateStore.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CertificateStore.java Mon Mar  6 14:56:53 2017
@@ -178,11 +178,9 @@ public class CertificateStore extends Cr
             // to ensure against phony DNs (compare encoded form including signature)
             //
             if (foundCerts != null && foundCerts[0] != null && foundCerts[0].equals(certs[0])) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug(
-                        "Direct trust for certificate with " + certs[0].getSubjectX500Principal().getName()
-                    );
-                }
+                LOG.debug(
+                    "Direct trust for certificate with {}", certs[0].getSubjectX500Principal().getName()
+                );
                 return;
             }
         }
@@ -201,12 +199,9 @@ public class CertificateStore extends Cr
         // As a direct result, do not trust the transmitted certificate
         if (foundCerts == null || foundCerts.length < 1) {
             String subjectString = certs[0].getSubjectX500Principal().getName();
-            if (LOG.isDebugEnabled()) {
-                LOG.debug(
-                    "No certs found in keystore for issuer " + issuerString
-                    + " of certificate for " + subjectString
-                );
-            }
+            LOG.debug(
+                "No certs found in keystore for issuer {} of certificate for {}", issuerString, subjectString
+            );
             throw new WSSecurityException(
                 WSSecurityException.ErrorCode.FAILURE, "certpath",
                 new Object[] {"No trusted certs found"}
@@ -217,11 +212,9 @@ public class CertificateStore extends Cr
         // THIRD step
         // Check the certificate trust path for the issuer cert chain
         //
-        if (LOG.isDebugEnabled()) {
-            LOG.debug(
-                "Preparing to validate certificate path for issuer " + issuerString
-            );
-        }
+        LOG.debug(
+            "Preparing to validate certificate path for issuer {}", issuerString
+        );
 
         //
         // Form a certificate chain from the transmitted certificate

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java?rev=1785658&r1=1785657&r2=1785658&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/crypto/CryptoFactory.java Mon Mar  6 14:56:53 2017
@@ -71,9 +71,7 @@ public abstract class CryptoFactory {
      */
     public static Crypto getInstance(Properties properties) throws WSSecurityException {
         if (properties == null) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Cannot load Crypto instance as properties object is null");
-            }
+            LOG.debug("Cannot load Crypto instance as properties object is null");
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
                     "empty", new Object[] {"Cannot load Crypto instance as properties object is null"});
         }
@@ -103,9 +101,7 @@ public abstract class CryptoFactory {
         PasswordEncryptor passwordEncryptor
     ) throws WSSecurityException {
         if (properties == null) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Cannot load Crypto instance as properties object is null");
-            }
+            LOG.debug("Cannot load Crypto instance as properties object is null");
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
                     "empty", new Object[] {"Cannot load Crypto instance as properties object is null"});
         }
@@ -122,9 +118,7 @@ public abstract class CryptoFactory {
             try {
                 return new Merlin(properties, classLoader, passwordEncryptor);
             } catch (java.lang.Exception e) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Unable to instantiate Merlin", e);
-                }
+                LOG.debug("Unable to instantiate Merlin", e);
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e, "empty",
                                               new Object[] {"Cannot create Crypto class " + cryptoClassName});
             }
@@ -133,9 +127,7 @@ public abstract class CryptoFactory {
                 // instruct the class loader to load the crypto implementation
                 cryptoClass = Loader.loadClass(cryptoClassName, Crypto.class);
             } catch (ClassNotFoundException ex) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug(ex.getMessage(), ex);
-                }
+                LOG.debug(ex.getMessage(), ex);
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex,
                         "empty", new Object[] {cryptoClassName + " Not Found"});
             }
@@ -207,9 +199,7 @@ public abstract class CryptoFactory {
         Map<Object, Object> map,
         ClassLoader loader
     ) throws WSSecurityException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Using Crypto Engine [" + cryptoClass + "]");
-        }
+        LOG.debug("Using Crypto Engine [{}]", cryptoClass);
         try {
             Constructor<? extends Crypto> c = null;
             try {
@@ -243,9 +233,7 @@ public abstract class CryptoFactory {
         Properties map,
         ClassLoader loader
     ) throws WSSecurityException {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Using Crypto Engine [" + cryptoClass + "]");
-        }
+        LOG.debug("Using Crypto Engine [{}]", cryptoClass);
         try {
             Constructor<? extends Crypto> c = null;
             try {

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java?rev=1785658&r1=1785657&r2=1785658&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/saml/OpenSAMLUtil.java Mon Mar  6 14:56:53 2017
@@ -70,9 +70,7 @@ public final class OpenSAMLUtil {
      */
     public static synchronized void initSamlEngine() {
         if (!samlEngineInitialized) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Initializing the opensaml2 library...");
-            }
+            LOG.debug("Initializing the opensaml2 library...");
             WSProviderConfig.init();
 
             Configuration configuration = new MapBasedConfiguration();
@@ -102,9 +100,7 @@ public final class OpenSAMLUtil {
                 }
 
                 samlEngineInitialized = true;
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("opensaml3 library bootstrap complete");
-                }
+                LOG.debug("opensaml3 library bootstrap complete");
             } catch (XMLConfigurationException ex) {
                 LOG.error("Unable to bootstrap the opensaml3 library - all SAML operations will fail", ex);
             }

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/DefaultSpnegoClientAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/DefaultSpnegoClientAction.java?rev=1785658&r1=1785657&r2=1785658&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/DefaultSpnegoClientAction.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/DefaultSpnegoClientAction.java Mon Mar  6 14:56:53 2017
@@ -70,9 +70,7 @@ public class DefaultSpnegoClientAction i
             byte[] token = new byte[0];
             return secContext.initSecContext(token, 0, token.length);
         } catch (GSSException e) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Error in obtaining a Kerberos token", e);
-            }
+            LOG.debug("Error in obtaining a Kerberos token", e);
         }
 
         return null;

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/DefaultSpnegoServiceAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/DefaultSpnegoServiceAction.java?rev=1785658&r1=1785657&r2=1785658&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/DefaultSpnegoServiceAction.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/DefaultSpnegoServiceAction.java Mon Mar  6 14:56:53 2017
@@ -67,9 +67,7 @@ public class DefaultSpnegoServiceAction
 
             return secContext.acceptSecContext(ticket, 0, ticket.length);
         } catch (GSSException e) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Error in obtaining a Kerberos token", e);
-            }
+            LOG.debug("Error in obtaining a Kerberos token", e);
         }
 
         return null;

Modified: webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/SpnegoTokenContext.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/SpnegoTokenContext.java?rev=1785658&r1=1785657&r2=1785658&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/SpnegoTokenContext.java (original)
+++ webservices/wss4j/trunk/ws-security-common/src/main/java/org/apache/wss4j/common/spnego/SpnegoTokenContext.java Mon Mar  6 14:56:53 2017
@@ -121,16 +121,12 @@ public class SpnegoTokenContext {
             }
             loginContext.login();
         } catch (LoginException ex) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug(ex.getMessage(), ex);
-            }
+            LOG.debug(ex.getMessage(), ex);
             throw new WSSecurityException(
                 WSSecurityException.ErrorCode.FAILURE, ex, "kerberosLoginError",
                 new Object[] {ex.getMessage()});
         }
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Successfully authenticated to the TGT");
-        }
+        LOG.debug("Successfully authenticated to the TGT");
 
         Subject clientSubject = loginContext.getSubject();
         Set<Principal> clientPrincipals = clientSubject.getPrincipals();
@@ -186,9 +182,7 @@ public class SpnegoTokenContext {
             }
         }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Successfully retrieved a service ticket");
-        }
+        LOG.debug("Successfully retrieved a service ticket");
     }
 
     /**
@@ -233,16 +227,12 @@ public class SpnegoTokenContext {
             }
             loginContext.login();
         } catch (LoginException ex) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug(ex.getMessage(), ex);
-            }
+            LOG.debug(ex.getMessage(), ex);
             throw new WSSecurityException(
                 WSSecurityException.ErrorCode.FAILURE, ex, "kerberosLoginError",
                 new Object[] {ex.getMessage()});
         }
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Successfully authenticated to the TGT");
-        }
+        LOG.debug("Successfully authenticated to the TGT");
 
         // Get the service name to use - fall back on the principal
         Subject subject = loginContext.getSubject();
@@ -295,9 +285,7 @@ public class SpnegoTokenContext {
             }
         }
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Successfully validated a service ticket");
-        }
+        LOG.debug("Successfully validated a service ticket");
     }
 
     /**
@@ -332,9 +320,7 @@ public class SpnegoTokenContext {
         try {
             return secContext.unwrap(secret, 0, secret.length, mProp);
         } catch (GSSException e) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Error in cleaning up a GSS context", e);
-            }
+            LOG.debug("Error in cleaning up a GSS context", e);
             throw new WSSecurityException(
                 WSSecurityException.ErrorCode.FAILURE, e, "spnegoKeyError"
             );
@@ -349,9 +335,7 @@ public class SpnegoTokenContext {
         try {
             return secContext.wrap(secret, 0, secret.length, mProp);
         } catch (GSSException e) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Error in cleaning up a GSS context", e);
-            }
+            LOG.debug("Error in cleaning up a GSS context", e);
             throw new WSSecurityException(
                 WSSecurityException.ErrorCode.FAILURE, e, "spnegoKeyError"
             );
@@ -380,9 +364,7 @@ public class SpnegoTokenContext {
         try {
             secContext.dispose();
         } catch (GSSException e) {
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("Error in cleaning up a GSS context", e);
-            }
+            LOG.debug("Error in cleaning up a GSS context", e);
         }
     }
 

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=1785658&r1=1785657&r2=1785658&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 Mar  6 14:56:53 2017
@@ -220,9 +220,7 @@ public class WSSSignatureOutputProcessor
                     }
 
                     String calculatedDigest = Base64.getMimeEncoder().encodeToString(digestOutputStream.getDigestValue());
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Calculated Digest: " + calculatedDigest);
-                    }
+                    LOG.debug("Calculated Digest: {}", calculatedDigest);
 
                     signaturePartDef.setDigestValue(calculatedDigest);
 

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/X509SecurityTokenImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/X509SecurityTokenImpl.java?rev=1785658&r1=1785657&r2=1785658&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/X509SecurityTokenImpl.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/X509SecurityTokenImpl.java Mon Mar  6 14:56:53 2017
@@ -145,9 +145,7 @@ public abstract class X509SecurityTokenI
             for (Pattern subjectDNPattern : subjectDNPatterns) {
                 final Matcher matcher = subjectDNPattern.matcher(subjectName);
                 if (matcher.matches()) {
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Subject DN " + subjectName + " matches with pattern " + subjectDNPattern);
-                    }
+                    LOG.debug("Subject DN {} matches with pattern {}", subjectName, subjectDNPattern);
                     subjectMatch = true;
                     break;
                 }

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/UsernameTokenValidatorImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/UsernameTokenValidatorImpl.java?rev=1785658&r1=1785657&r2=1785658&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/UsernameTokenValidatorImpl.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/UsernameTokenValidatorImpl.java Mon Mar  6 14:56:53 2017
@@ -62,19 +62,15 @@ public class UsernameTokenValidatorImpl
             tokenContext.getWssSecurityProperties().getUsernameTokenPasswordType();
         if (requiredPasswordType != null) {
             if (passwordType == null || passwordType.getType() == null) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Authentication failed as the received password type does not "
-                        + "match the required password type of: " + requiredPasswordType);
-                }
+                LOG.debug("Authentication failed as the received password type does not "
+                    + "match the required password type of: {}", requiredPasswordType);
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_AUTHENTICATION);
             }
             WSSConstants.UsernameTokenPasswordType usernameTokenPasswordType =
                 WSSConstants.UsernameTokenPasswordType.getUsernameTokenPasswordType(passwordType.getType());
             if (requiredPasswordType != usernameTokenPasswordType) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Authentication failed as the received password type does not "
-                        + "match the required password type of: " + requiredPasswordType);
-                }
+                LOG.debug("Authentication failed as the received password type does not "
+                    + "match the required password type of: {}", requiredPasswordType);
                 throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_AUTHENTICATION);
             }
         }