cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ashaki...@apache.org
Subject svn commit: r1484164 - in /cxf/trunk/services/xkms: xkms-common/src/main/java/org/apache/cxf/xkms/exception/ xkms-common/src/main/java/org/apache/cxf/xkms/handlers/ xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/locator/
Date Sat, 18 May 2013 19:15:09 GMT
Author: ashakirin
Date: Sat May 18 19:15:08 2013
New Revision: 1484164

URL: http://svn.apache.org/r1484164
Log:
Fixed XKMS lookup certificate tests to ignore .svn folder

Modified:
    cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/exception/ExceptionMapper.java
    cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/handlers/DnUtils.java
    cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/locator/FileLocator.java

Modified: cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/exception/ExceptionMapper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/exception/ExceptionMapper.java?rev=1484164&r1=1484163&r2=1484164&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/exception/ExceptionMapper.java
(original)
+++ cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/exception/ExceptionMapper.java
Sat May 18 19:15:08 2013
@@ -32,19 +32,19 @@ public final class ExceptionMapper {
     public static <T extends ResultType> T toResponse(Exception e, T result) {
         if (e instanceof XKMSException) {
             XKMSException xkmsEx = (XKMSException)e;
-            result = initResultType(xkmsEx.getMessage(), xkmsEx.getResultMajor(), xkmsEx.getResultMinor(),
result);
+            initResultType(xkmsEx.getMessage(), xkmsEx.getResultMajor(), xkmsEx.getResultMinor(),
result);
         } else if (e instanceof UnsupportedOperationException) {
-            result = initResultType(e.getMessage(),
+            initResultType(e.getMessage(),
                                     ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_SENDER,
                                     ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_MESSAGE_NOT_SUPPORTED,
                                     result);
         } else if (e instanceof IllegalArgumentException) {
-            result = initResultType(e.getMessage(),
+            initResultType(e.getMessage(),
                                     ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_SENDER,
                                     ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_FAILURE,
                                     result);
         } else {
-            result = initResultType(e.getMessage(),
+            initResultType(e.getMessage(),
                                     ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_RECEIVER,
                                     ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_FAILURE,
                                     result);
@@ -72,7 +72,7 @@ public final class ExceptionMapper {
         return new XKMSException(major, minor, message);
     }
 
-    private static <T extends ResultType> T initResultType(String message, ResultMajorEnum
majorCode,
+    private static <T extends ResultType> void initResultType(String message, ResultMajorEnum
majorCode,
                                              ResultMinorEnum minorCode, T result) {
         result.setResultMajor((majorCode != null)
             ? majorCode.value() : ResultMajorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_RECEIVER.value());
@@ -83,6 +83,5 @@ public final class ExceptionMapper {
             resultDetails.setDetails(message);
             result.getMessageExtension().add(resultDetails);
         }
-        return result;
     }
 }

Modified: cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/handlers/DnUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/handlers/DnUtils.java?rev=1484164&r1=1484163&r2=1484164&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/handlers/DnUtils.java
(original)
+++ cxf/trunk/services/xkms/xkms-common/src/main/java/org/apache/cxf/xkms/handlers/DnUtils.java
Sat May 18 19:15:08 2013
@@ -72,18 +72,19 @@ public final class DnUtils {
     
     private static String normalizeAttribute(String val) {
         String[] split;
+        String normalized = val;
         if (null != val) {
             split = val.split("=");
             // normalize the prefix if present
             if (split.length == 2) {
                 String prefix = split[0].toLowerCase().trim();
                 String value = split[1].trim();
-                val = prefix + "=" + value;
+                normalized = prefix + "=" + value;
             } else {
-                val = val.trim();
+                normalized = val.trim();
             }
         }
-        return val;
+        return normalized;
     }
 
     public static class DnAttribute {

Modified: cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/locator/FileLocator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/locator/FileLocator.java?rev=1484164&r1=1484163&r2=1484164&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/locator/FileLocator.java
(original)
+++ cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/locator/FileLocator.java
Sat May 18 19:15:08 2013
@@ -46,11 +46,13 @@ import org.apache.cxf.xkms.model.xkms.Un
 import org.apache.cxf.xkms.model.xkms.UseKeyWithType;
 import org.apache.cxf.xkms.x509.parser.LocateRequestParser;
 import org.apache.cxf.xkms.x509.utils.X509Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class FileLocator implements Locator {
 
     private static final String CN_PREFIX = "cn=";
-    //private static final Logger LOG = LoggerFactory.getLogger(FilePersistenceManager.class);
+    private static final Logger LOG = LoggerFactory.getLogger(FileLocator.class);
     private final File storageDir;
     private final CertificateFactory certFactory;
 
@@ -116,18 +118,18 @@ public class FileLocator implements Loca
     private List<X509Certificate> findCertificateBySubjectDn(String subjectDN) {
         List<X509Certificate> result = new ArrayList<X509Certificate>();
         File[] list = getX509Files();
-        //        String searchId = DnUtils.extractMostSignificantAttribute(subjectDN);
         for (File certFile : list) {
             try {
+                if (certFile.isDirectory()) {
+                    continue;
+                }
                 X509Certificate cert = readCertificate(certFile);
-                //                String id = DnUtils.extractMostSignificantAttribute(cert.getSubjectDN().getName());
-                //                if (searchId.equalsIgnoreCase(id)) {
                 if (subjectDN.equalsIgnoreCase(cert.getSubjectDN().getName())
                         || subjectDN.equalsIgnoreCase(cert.getSubjectX500Principal().getName()))
{
                     result.add(cert);
                 }
             } catch (Exception e) {
-                throw new RuntimeException("Error reading certificate for " + subjectDN +
": " + e.getMessage(), e);
+                LOG.warn(String.format("Cannot load certificate from file: %s. Error: %s",
certFile, e.getMessage()));
             }
 
         }
@@ -139,6 +141,9 @@ public class FileLocator implements Loca
         File[] list = getX509Files();
         for (File certFile : list) {
             try {
+                if (certFile.isDirectory()) {
+                    continue;
+                }
                 X509Certificate cert = readCertificate(certFile);
                 BigInteger cs = cert.getSerialNumber();
                 BigInteger ss = new BigInteger(serial, 16);
@@ -146,7 +151,7 @@ public class FileLocator implements Loca
                     result.add(cert);
                 }
             } catch (Exception e) {
-                throw new RuntimeException("Error reading certificate for issuer " + issuer
+ ": " + e.getMessage(), e);
+                LOG.warn(String.format("Cannot load certificate from file: %s. Error: %s",
certFile, e.getMessage()));
             }
 
         }



Mime
View raw message