cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1536403 - in /cxf/branches/2.7.x-fixes: ./ services/xkms/xkms-client/ services/xkms/xkms-common/ services/xkms/xkms-itests/src/test/resources/etc/ services/xkms/xkms-osgi/ services/xkms/xkms-osgi/src/main/resources/OSGI-INF/blueprint/ serv...
Date Mon, 28 Oct 2013 16:55:13 GMT
Author: cschneider
Date: Mon Oct 28 16:55:12 2013
New Revision: 1536403

URL: http://svn.apache.org/r1536403
Log:
Improve logging in tests

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/services/xkms/xkms-client/   (props changed)
    cxf/branches/2.7.x-fixes/services/xkms/xkms-common/   (props changed)
    cxf/branches/2.7.x-fixes/services/xkms/xkms-itests/src/test/resources/etc/org.ops4j.pax.logging.cfg
    cxf/branches/2.7.x-fixes/services/xkms/xkms-osgi/   (props changed)
    cxf/branches/2.7.x-fixes/services/xkms/xkms-osgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    cxf/branches/2.7.x-fixes/services/xkms/xkms-service/src/main/java/org/apache/cxf/xkms/service/XKMSService.java
    cxf/branches/2.7.x-fixes/services/xkms/xkms-x509-handlers/   (props changed)
    cxf/branches/2.7.x-fixes/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1536397,1536401

Propchange: cxf/branches/2.7.x-fixes/services/xkms/xkms-client/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Oct 28 16:55:12 2013
@@ -5,3 +5,9 @@
 .classpath
 
 target
+
+.pmdruleset.xml
+
+.checkstyle
+
+.pmd

Propchange: cxf/branches/2.7.x-fixes/services/xkms/xkms-common/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Oct 28 16:55:12 2013
@@ -5,3 +5,9 @@
 .project
 
 target
+
+.pmd
+
+.pmdruleset.xml
+
+.checkstyle

Modified: cxf/branches/2.7.x-fixes/services/xkms/xkms-itests/src/test/resources/etc/org.ops4j.pax.logging.cfg
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/xkms/xkms-itests/src/test/resources/etc/org.ops4j.pax.logging.cfg?rev=1536403&r1=1536402&r2=1536403&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/services/xkms/xkms-itests/src/test/resources/etc/org.ops4j.pax.logging.cfg
(original)
+++ cxf/branches/2.7.x-fixes/services/xkms/xkms-itests/src/test/resources/etc/org.ops4j.pax.logging.cfg
Mon Oct 28 16:55:12 2013
@@ -21,5 +21,5 @@ log4j.appender.file.threshold=DEBUG
 log4j.appender.file=org.apache.log4j.FileAppender
 log4j.appender.file.layout=org.apache.log4j.PatternLayout
 log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-50.50c | %m%n
-log4j.appender.file.file=${karaf.home}/log/tesb.log
+log4j.appender.file.file=${karaf.data}/log/karaf.log
 log4j.appender.file.append=true

Propchange: cxf/branches/2.7.x-fixes/services/xkms/xkms-osgi/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Oct 28 16:55:12 2013
@@ -5,3 +5,9 @@
 .project
 
 target
+
+.pmdruleset.xml
+
+.pmd
+
+.checkstyle

Modified: cxf/branches/2.7.x-fixes/services/xkms/xkms-osgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/xkms/xkms-osgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1536403&r1=1536402&r2=1536403&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/services/xkms/xkms-osgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(original)
+++ cxf/branches/2.7.x-fixes/services/xkms/xkms-osgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Mon Oct 28 16:55:12 2013
@@ -23,6 +23,7 @@
 	<cm:property-placeholder persistent-id="org.apache.cxf.xkms" update-strategy="reload">
 		<cm:default-properties>
 			<cm:property name="xkms.enableXKRSS" value="true"/>
+            <cm:property name="xkms.logExceptions" value="false"/>
 			<cm:property name="xkms.certificate.repo" value="ldap"/>
 			<cm:property name="xkms.file.storageDir" value="data/xkms/certificates"/>
 			<cm:property name="xkms.ldap.url" value="tcp:localhost:389"/>
@@ -86,6 +87,7 @@
 
     <bean id="xkmsService" class="org.apache.cxf.xkms.service.XKMSService">
     	<property name="enableXKRSS" value="${xkms.enableXKRSS}" />
+        <property name="logExceptions" value="${xkms.logExceptions}" />
         <property name="validators">
             <list>
                 <ref component-id="dateValidator" />

Modified: cxf/branches/2.7.x-fixes/services/xkms/xkms-service/src/main/java/org/apache/cxf/xkms/service/XKMSService.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/xkms/xkms-service/src/main/java/org/apache/cxf/xkms/service/XKMSService.java?rev=1536403&r1=1536402&r2=1536403&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/services/xkms/xkms-service/src/main/java/org/apache/cxf/xkms/service/XKMSService.java
(original)
+++ cxf/branches/2.7.x-fixes/services/xkms/xkms-service/src/main/java/org/apache/cxf/xkms/service/XKMSService.java
Mon Oct 28 16:55:12 2013
@@ -63,65 +63,54 @@ public class XKMSService implements XKMS
     protected static final Logger LOG = LogUtils.getL7dLogger(XKMSService.class);
 
     private String serviceName = XKMSConstants.XKMS_ENDPOINT_NAME;
-
     private List<Locator> locators = new ArrayList<Locator>();
-
     private List<Validator> validators = new ArrayList<Validator>();
-
     private List<Register> keyRegisterHandlers = new ArrayList<Register>();
-    
     private boolean enableXKRSS = true;
+    private boolean logExceptions;
 
     @Override
     public ReissueResultType reissue(ReissueRequestType request) {
-        assertXKRSSAllowed();
+        ReissueResultType response = XKMSResponseFactory.createResponse(request, new ReissueResultType());
         try {
+            assertXKRSSAllowed();
             validateRequest(request);
-            ReissueResultType response = XKMSResponseFactory.createResponse(request, new
ReissueResultType());
-            try {
-                for (Register handler : keyRegisterHandlers) {
-                    if (handler.canProcess(request)) {
-                        return handler.reissue(request, response);
-                    }
+            for (Register handler : keyRegisterHandlers) {
+                if (handler.canProcess(request)) {
+                    return handler.reissue(request, response);
                 }
-                throw new UnsupportedOperationException("Service was unable to handle your
request");
-            } catch (Exception e) {
-                LOG.log(Level.SEVERE, "Error due X509 Validation: " + e.getMessage(), e);
-                return ExceptionMapper.toResponse(e, response);
             }
+            throw new UnsupportedOperationException("Service was unable to handle your request");
         } catch (Exception e) {
-            return ExceptionMapper.toResponse(e, XKMSResponseFactory.createResponse(request,
new ReissueResultType()));
+            return handleException("reissue", e, response);
         }
     }
 
+
     @Override
     public CompoundResultType compound(CompoundRequestType request) {
         validateRequest(request);
 
         RuntimeException ex = new UnsupportedOperationException("XKMS compound request is
currently not supported");
         CompoundResultType response = XKMSResponseFactory.createResponse(request, new CompoundResultType());
-        return ExceptionMapper.toResponse(ex, response);
+        return handleException("compound", ex, response);
     }
 
     @Override
     public RegisterResultType register(RegisterRequestType request) {
+        RegisterResultType response = XKMSResponseFactory.createResponse(request, new RegisterResultType());
         try {
-            assertXKRSSAllowed();
+            assertXKRSSAllowed();            
             validateRequest(request);
-            RegisterResultType response = XKMSResponseFactory.createResponse(request, new
RegisterResultType());
-            try {
-                for (Register handler : keyRegisterHandlers) {
-                    if (handler.canProcess(request)) {
-                        return handler.register(request, response);
-                    }
+            
+            for (Register handler : keyRegisterHandlers) {
+                if (handler.canProcess(request)) {
+                    return handler.register(request, response);
                 }
-                throw new UnsupportedOperationException("Service was unable to handle your
request");
-            } catch (Exception e) {
-                LOG.log(Level.SEVERE, "Error due X509 Validation: " + e.getMessage(), e);
-                return ExceptionMapper.toResponse(e, response);
             }
+            throw new UnsupportedOperationException("Service was unable to handle your request");
         } catch (Exception e) {
-            return ExceptionMapper.toResponse(e, XKMSResponseFactory.createResponse(request,
new RegisterResultType()));
+            return handleException("register", e, response);
         }
     }
 
@@ -135,67 +124,56 @@ public class XKMSService implements XKMS
 
     @Override
     public RevokeResultType revoke(RevokeRequestType request) {
+        RevokeResultType response = XKMSResponseFactory.createResponse(request, new RevokeResultType());
         try {
             assertXKRSSAllowed();
             validateRequest(request);
-            RevokeResultType response = XKMSResponseFactory.createResponse(request, new RevokeResultType());
-            try {
-                for (Register handler : keyRegisterHandlers) {
-                    if (handler.canProcess(request)) {
-                        return handler.revoke(request, response);
-                    }
+            for (Register handler : keyRegisterHandlers) {
+                if (handler.canProcess(request)) {
+                    return handler.revoke(request, response);
                 }
-                throw new UnsupportedOperationException("Service was unable to handle your
request");
-            } catch (Exception e) {
-                LOG.log(Level.SEVERE, "Error due X509 Validation: " + e.getMessage(), e);
-                return ExceptionMapper.toResponse(e, response);
             }
+            throw new UnsupportedOperationException("Service was unable to handle your request");
         } catch (Exception e) {
-            return ExceptionMapper.toResponse(e, XKMSResponseFactory.createResponse(request,
new RevokeResultType()));
+            return handleException("revoke", e, response);
         }
     }
 
     @Override
     public LocateResultType locate(LocateRequestType request) {
+        LocateResultType response = XKMSResponseFactory.createResponse(request, new LocateResultType());
         try {
             validateRequest(request);
-            // Create basic response
-            LocateResultType result = XKMSResponseFactory.createResponse(request, new LocateResultType());
             // Search
             for (Locator locator : locators) {
                 UnverifiedKeyBindingType keyBinding = locator.locate(request);
                 if (keyBinding != null) {
-                    result.getUnverifiedKeyBinding().add(keyBinding);
-                    return result;
+                    response.getUnverifiedKeyBinding().add(keyBinding);
+                    return response;
                 }
             }
             // No matches found
-            result.setResultMinor(ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_NO_MATCH.value());
-            return result;
+            response.setResultMinor(ResultMinorEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_NO_MATCH.value());
+            return response;
         } catch (Exception e) {
-            return ExceptionMapper.toResponse(e, XKMSResponseFactory.createResponse(request,
new LocateResultType()));
+            return handleException("locate", e, response);
         }
     }
 
     @Override
     public RecoverResultType recover(RecoverRequestType request) {
+        RecoverResultType response = XKMSResponseFactory.createResponse(request, new RecoverResultType());
         try {
             assertXKRSSAllowed();
             validateRequest(request);
-            RecoverResultType response = XKMSResponseFactory.createResponse(request, new
RecoverResultType());
-            try {
-                for (Register handler : keyRegisterHandlers) {
-                    if (handler.canProcess(request)) {
-                        return handler.recover(request, response);
-                    }
+            for (Register handler : keyRegisterHandlers) {
+                if (handler.canProcess(request)) {
+                    return handler.recover(request, response);
                 }
-                throw new UnsupportedOperationException("Service was unable to handle your
request");
-            } catch (Exception e) {
-                LOG.log(Level.SEVERE, "Error during recover: " + e.getMessage(), e);
-                return ExceptionMapper.toResponse(e, response);
             }
+            throw new UnsupportedOperationException("Service was unable to handle your request");
         } catch (Exception e) {
-            return ExceptionMapper.toResponse(e, XKMSResponseFactory.createResponse(request,
new RecoverResultType()));
+            return handleException("recover", e, response);
         }
     }
 
@@ -209,12 +187,12 @@ public class XKMSService implements XKMS
 
     @Override
     public ValidateResultType validate(ValidateRequestType request) {
+        ValidateResultType response = XKMSResponseFactory.createResponse(request, new ValidateResultType());
         try {
             validateRequest(request);
 
             // Create basic response
-            ValidateResultType result = XKMSResponseFactory.createResponse(request, new ValidateResultType());
-            KeyBindingType binding = createKeyBinding(result);
+            KeyBindingType binding = createKeyBinding(response);
 
             // Validate request
             for (Validator validator : validators) {
@@ -223,10 +201,17 @@ public class XKMSService implements XKMS
             }
 
             resolveValidationStatus(binding);
-            return result;
+            return response;
         } catch (Exception e) {
-            return ExceptionMapper.toResponse(e, XKMSResponseFactory.createResponse(request,
new ValidateResultType()));
+            return handleException("recover", e, response);
+        }
+    }
+    
+    private <T extends ResultType> T handleException(String method, Exception e, T
response) {
+        if (logExceptions) {
+            LOG.log(Level.SEVERE, "Error during " + method + ": " + e.getMessage(), e);
         }
+        return ExceptionMapper.toResponse(e, response);
     }
 
     /**
@@ -322,9 +307,14 @@ public class XKMSService implements XKMS
         LOG.info("enableXKRSS:" + enableXKRSS);
     }
 
+    public void setLogExceptions(boolean logExceptions) {
+        this.logExceptions = logExceptions;
+    }
+
     private void assertXKRSSAllowed() {
         if (!enableXKRSS) {
             throw new UnsupportedOperationException("XKRSS Operations are disabled");
         }
     }
 }
+

Propchange: cxf/branches/2.7.x-fixes/services/xkms/xkms-x509-handlers/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Oct 28 16:55:12 2013
@@ -5,3 +5,9 @@
 .settings
 
 target
+
+.pmdruleset.xml
+
+.checkstyle
+
+.pmd

Modified: cxf/branches/2.7.x-fixes/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java?rev=1536403&r1=1536402&r2=1536403&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java
(original)
+++ cxf/branches/2.7.x-fixes/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java
Mon Oct 28 16:55:12 2013
@@ -88,7 +88,7 @@ public class DateValidator implements Va
 
         for (X509Certificate x509Certificate : certificates) {
             if (!isCertificateValid(x509Certificate)) {
-                LOG.severe("Certificate is expired: " + x509Certificate.getSubjectX500Principal());
+                LOG.info("Certificate is expired: " + x509Certificate.getSubjectX500Principal());
                 return false;
             }
         }



Mime
View raw message