Author: coheigea
Date: Tue Mar  3 17:11:54 2009
New Revision: 749664

URL: http://svn.apache.org/viewvc?rev=749664&view=rev
Log:
[WSS-167] - Apply maven-pmd-plugin to the source tree.

Modified:
    webservices/wss4j/trunk/pom.xml
    webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllReceiver.java
    webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllSender.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java
    webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/BinarySecurity.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/message/token/SecurityTokenReference.java
    
webservices/wss4j/trunk/src/org/apache/ws/security/util/XmlSchemaDateFormat.java

Modified: webservices/wss4j/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/pom.xml?rev=749664&r1=749663&r2=749664&view=diff
==============================================================================
--- webservices/wss4j/trunk/pom.xml (original)
+++ webservices/wss4j/trunk/pom.xml Tue Mar  3 17:11:54 2009
@@ -131,6 +131,31 @@
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-pmd-plugin</artifactId>
+                <version>2.4</version>
+                <configuration>
+                    <linkXRef>false</linkXRef>
+                    <failOnViolation>true</failOnViolation>
+                    <verbose>true</verbose>
+                    <includeTests>false</includeTests>
+                    <excludes>
+                        <exclude>**/Merlin.java, **/CryptoBase.java, 
**/SAMLIssuerImpl.java,
+                                 **/DOM2Writer.java
+                        </exclude>
+                    </excludes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>validate</id>
+                        <phase>validate</phase>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-antrun-plugin</artifactId>
                 <version>1.2</version>
                 <executions>
@@ -264,6 +289,7 @@
                         <tarLongFileMode>gnu</tarLongFileMode>
                     </configuration>
                 </plugin>
+  
             </plugins>
         </pluginManagement>
     </build>

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllReceiver.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllReceiver.java?rev=749664&r1=749663&r2=749664&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllReceiver.java 
(original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllReceiver.java 
Tue Mar  3 17:11:54 2009
@@ -287,11 +287,9 @@
             if (actionResult != null) {
                 X509Certificate returnCert = actionResult.getCertificate();
 
-                if (returnCert != null) {
-                    if (!verifyTrust(returnCert, reqData)) {
-                        throw new AxisFault(
-                                "WSDoAllReceiver: The certificate used for the 
signature is not trusted");
-                    }
+                if (returnCert != null && !verifyTrust(returnCert, reqData)) {
+                    throw new AxisFault(
+                            "WSDoAllReceiver: The certificate used for the 
signature is not trusted");
                 }
             }
 
@@ -312,11 +310,9 @@
             if (actionResult != null) {
                 Timestamp timestamp = actionResult.getTimestamp();
 
-                if (timestamp != null) {
-                    if (!verifyTimestamp(timestamp, 
decodeTimeToLive(reqData))) {
-                        throw new AxisFault(
-                                "WSDoAllReceiver: The timestamp could not be 
validated");
-                    }
+                if (timestamp != null 
+                    && !verifyTimestamp(timestamp, decodeTimeToLive(reqData))) 
{
+                    throw new AxisFault("WSDoAllReceiver: The timestamp could 
not be validated");
                 }
             }
 

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllSender.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllSender.java?rev=749664&r1=749663&r2=749664&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllSender.java 
(original)
+++ webservices/wss4j/trunk/src/org/apache/ws/axis/security/WSDoAllSender.java 
Tue Mar  3 17:11:54 2009
@@ -106,15 +106,13 @@
              * functions. No need to do it for encryption only. Check if
              * username is available and then get a passowrd.
              */
-            if ((doAction & (WSConstants.SIGN | WSConstants.UT | 
WSConstants.UT_SIGN)) != 0) {
+            if (((doAction & (WSConstants.SIGN | WSConstants.UT | 
WSConstants.UT_SIGN)) != 0)
+                && (reqData.getUsername() == null || 
reqData.getUsername().equals(""))) {
                 /*
                  * We need a username - if none throw an AxisFault. For
                  * encryption there is a specific parameter to get a username.
                  */
-                if (reqData.getUsername() == null || 
reqData.getUsername().equals("")) {
-                    throw new AxisFault(
-                    "WSDoAllSender: Empty username for specified action");
-                }
+                 throw new AxisFault("WSDoAllSender: Empty username for 
specified action");
             }
             if (doDebug) {
                 log.debug("Action: " + doAction);

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java?rev=749664&r1=749663&r2=749664&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java
 Tue Mar  3 17:11:54 2009
@@ -100,7 +100,10 @@
         if (provider != null) {
             factory = (CertificateFactory)certFactMap.get(provider);
         } else if (keyStoreProvider != null) {
-            factory = 
(CertificateFactory)certFactMap.get(mapKeystoreProviderToCertProvider(keyStoreProvider));
+            factory = 
+                (CertificateFactory)certFactMap.get(
+                    mapKeystoreProviderToCertProvider(keyStoreProvider)
+                );
             if (factory == null) {
                 factory = 
(CertificateFactory)certFactMap.get(keyStoreProvider);                
             }
@@ -112,11 +115,17 @@
                 if (provider == null || provider.length() == 0) {
                     if (keyStoreProvider != null && keyStoreProvider.length() 
!= 0) {
                         try {
-                            factory = CertificateFactory.getInstance("X.509", 
-                                                                 
mapKeystoreProviderToCertProvider(keyStoreProvider));
+                            factory = 
+                                CertificateFactory.getInstance(
+                                    "X.509", 
+                                    
mapKeystoreProviderToCertProvider(keyStoreProvider)
+                                );
                             certFactMap.put(keyStoreProvider, factory);
-                            
certFactMap.put(mapKeystoreProviderToCertProvider(keyStoreProvider), factory);
+                            certFactMap.put(
+                                
mapKeystoreProviderToCertProvider(keyStoreProvider), factory
+                            );
                         } catch (Exception ex) {
+                            log.debug(ex);
                             //Ignore, we'll just use the default since they 
didn't specify one.
                             //Hopefully that will work for them.
                         }

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java?rev=749664&r1=749663&r2=749664&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java 
(original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSS4JHandler.java 
Tue Mar  3 17:11:54 2009
@@ -190,7 +190,8 @@
         Vector actions = new Vector();
         String action = (String) getOption(WSHandlerConstants.SEND + '.' + 
WSHandlerConstants.ACTION);
         if (action == null) {
-            if ((action = (String) getOption(WSHandlerConstants.ACTION)) == 
null) {
+            action = (String) getOption(WSHandlerConstants.ACTION);
+            if (action == null) {
                 action = (String) mc.getProperty(WSHandlerConstants.ACTION);
             }
         }
@@ -217,14 +218,13 @@
         * functions. No need to do it for encryption only. Check if username
         * is available and then get a password.
         */
-        if ((doAction & (WSConstants.SIGN | WSConstants.UT | 
WSConstants.UT_SIGN)) != 0) {
+        if (((doAction & (WSConstants.SIGN | WSConstants.UT | 
WSConstants.UT_SIGN)) != 0)
+            && (reqData.getUsername() == null || 
reqData.getUsername().equals(""))) {
             /*
             * We need a username - if none throw an JAXRPCException. For 
encryption
             * there is a specific parameter to get a username.
             */
-            if (reqData.getUsername() == null || 
reqData.getUsername().equals("")) {
-                throw new JAXRPCException("WSS4JHandler: Empty username for 
specified action");
-            }
+            throw new JAXRPCException("WSS4JHandler: Empty username for 
specified action");
         }
         if (doDebug) {
             log.debug("Action: " + doAction);
@@ -332,7 +332,8 @@
         Vector actions = new Vector();
         String action = (String) getOption(WSHandlerConstants.RECEIVE + '.' + 
WSHandlerConstants.ACTION);
         if (action == null) {
-            if ((action = (String) getOption(WSHandlerConstants.ACTION)) == 
null) {
+            action = (String) getOption(WSHandlerConstants.ACTION);
+            if (action == null) {
                 action = (String) mc.getProperty(WSHandlerConstants.ACTION);
             }
         }
@@ -488,10 +489,8 @@
             X509Certificate returnCert = 
                 
(X509Certificate)actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
 
-            if (returnCert != null) {
-                if (!verifyTrust(returnCert, reqData)) {
-                    throw new JAXRPCException("WSS4JHandler: The certificate 
used for the signature is not trusted");
-                }
+            if (returnCert != null && !verifyTrust(returnCert, reqData)) {
+                throw new JAXRPCException("WSS4JHandler: The certificate used 
for the signature is not trusted");
             }
         }
 
@@ -511,10 +510,9 @@
             Timestamp timestamp = 
                 
(Timestamp)actionResult.get(WSSecurityEngineResult.TAG_TIMESTAMP);
 
-            if (timestamp != null && 
reqData.getWssConfig().isTimeStampStrict()) {
-                if (!verifyTimestamp(timestamp, decodeTimeToLive(reqData))) {
-                    throw new JAXRPCException("WSS4JHandler: The timestamp 
could not be validated");
-                }
+            if (timestamp != null && reqData.getWssConfig().isTimeStampStrict()
+                && !verifyTimestamp(timestamp, decodeTimeToLive(reqData))) {
+                throw new JAXRPCException("WSS4JHandler: The timestamp could 
not be validated");
             }
         }
 

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=749664&r1=749663&r2=749664&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
 Tue Mar  3 17:11:54 2009
@@ -75,14 +75,12 @@
                     new Object[] {encoding}
                 );
             }
-        } else if (el.equals(TOKEN_KI)) {
-            if (encoding == null || !encoding.equals(BASE64_ENCODING)) {
-                throw new WSSecurityException(
-                    WSSecurityException.INVALID_SECURITY_TOKEN,
-                    "badEncoding", 
-                    new Object[] {encoding}
-                );
-            }
+        } else if (el.equals(TOKEN_KI) && !BASE64_ENCODING.equals(encoding)) {
+            throw new WSSecurityException(
+                WSSecurityException.INVALID_SECURITY_TOKEN,
+                "badEncoding", 
+                new Object[] {encoding}
+            );
         }
     }
 

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=749664&r1=749663&r2=749664&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
 Tue Mar  3 17:11:54 2009
@@ -630,11 +630,11 @@
             if (n.getNodeType() == Node.ELEMENT_NODE) {
                 String ns = n.getNamespaceURI();
                 String name = n.getLocalName();
-                if (((namespace != null) && (ns != null) && 
namespace.equals(ns))
-                    || ((namespace == null) && (ns == null))) {
-                    if (localname.equals(name)) {
-                        result++;
-                    }
+                if ((((namespace != null) && namespace.equals(ns))
+                    || ((namespace == null) && (ns == null)))
+                    && (localname.equals(name))
+                ) {
+                    result++;
                 }
             }
         }

Modified: 
webservices/wss4j/trunk/src/org/apache/ws/security/util/XmlSchemaDateFormat.java
URL: 
http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/util/XmlSchemaDateFormat.java?rev=749664&r1=749663&r2=749664&view=diff
==============================================================================
--- 
webservices/wss4j/trunk/src/org/apache/ws/security/util/XmlSchemaDateFormat.java
 (original)
+++ 
webservices/wss4j/trunk/src/org/apache/ws/security/util/XmlSchemaDateFormat.java
 Tue Mar  3 17:11:54 2009
@@ -187,7 +187,7 @@
 
         append_buf.append(str);
 
-        return (append_buf);
+        return append_buf;
     }
 
     private void validateChar(String str, ParsePosition parse_pos, int index,
@@ -206,7 +206,10 @@
 
     private void handleParseError(ParsePosition parse_pos, String error_reason)
             throws ParseException {
-        throw new ParseException("INVALID_XSD_DATETIME", 
parse_pos.getErrorIndex());
+        throw new ParseException(
+            "INVALID_XSD_DATETIME: " + error_reason, 
+            parse_pos.getErrorIndex()
+        );
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to