cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1536397 - in /cxf/trunk/services/xkms: xkms-itests/ xkms-itests/src/test/java/org/apache/cxf/xkms/itests/ xkms-itests/src/test/resources/etc/ xkms-osgi/src/main/resources/OSGI-INF/blueprint/ xkms-service/src/main/java/org/apache/cxf/xkms/s...
Date Mon, 28 Oct 2013 16:39:27 GMT
Author: cschneider
Date: Mon Oct 28 16:39:27 2013
New Revision: 1536397

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

Added:
    cxf/trunk/services/xkms/xkms-itests/src/test/resources/etc/org.ops4j.pax.logging.cfg
Modified:
    cxf/trunk/services/xkms/xkms-itests/pom.xml
    cxf/trunk/services/xkms/xkms-itests/src/test/java/org/apache/cxf/xkms/itests/BasicIntegrationTest.java
    cxf/trunk/services/xkms/xkms-itests/src/test/resources/etc/org.apache.cxf.xkms.cfg
    cxf/trunk/services/xkms/xkms-osgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    cxf/trunk/services/xkms/xkms-service/src/main/java/org/apache/cxf/xkms/service/XKMSService.java
    cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java

Modified: cxf/trunk/services/xkms/xkms-itests/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-itests/pom.xml?rev=1536397&r1=1536396&r2=1536397&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-itests/pom.xml (original)
+++ cxf/trunk/services/xkms/xkms-itests/pom.xml Mon Oct 28 16:39:27 2013
@@ -88,16 +88,7 @@
         		</exclusion>
         	</exclusions>
         </dependency>
-         
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-        </dependency>
 
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-jdk14</artifactId>
-        </dependency>
     </dependencies>
 
     <build>
@@ -107,6 +98,7 @@
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
                     <systemPropertyVariables>
+                        <org.ops4j.pax.logging.DefaultServiceLog.level>WARN</org.ops4j.pax.logging.DefaultServiceLog.level>
                         <project.version>${project.version}</project.version>
                         <karaf.version>${karaf.version}</karaf.version>
                         <buildDirectory>${project.build.directory}</buildDirectory>

Modified: cxf/trunk/services/xkms/xkms-itests/src/test/java/org/apache/cxf/xkms/itests/BasicIntegrationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-itests/src/test/java/org/apache/cxf/xkms/itests/BasicIntegrationTest.java?rev=1536397&r1=1536396&r2=1536397&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-itests/src/test/java/org/apache/cxf/xkms/itests/BasicIntegrationTest.java
(original)
+++ cxf/trunk/services/xkms/xkms-itests/src/test/java/org/apache/cxf/xkms/itests/BasicIntegrationTest.java
Mon Oct 28 16:39:27 2013
@@ -24,7 +24,6 @@ import javax.inject.Inject;
 
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
 import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
 import org.ops4j.pax.exam.options.MavenUrlReference;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
@@ -33,10 +32,11 @@ import org.w3._2002._03.xkms_wsdl.XKMSPo
 
 import static org.ops4j.pax.exam.CoreOptions.maven;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
+import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceConfigurationFile;
 
 @ExamReactorStrategy(PerClass.class)
@@ -69,7 +69,6 @@ public class BasicIntegrationTest {
         return new Option[] {
             karafDistributionConfiguration().frameworkUrl(karafUrl).karafVersion(karafVersion)
                 .unpackDirectory(new File("target/paxexam/unpack/")).useDeployFolder(false),
-            logLevel(LogLevel.INFO),
             systemProperty("java.awt.headless").value("true"),
 
             replaceConfigurationFile("data/xkms/certificates/trusted_cas/root.cer",
@@ -83,11 +82,14 @@ public class BasicIntegrationTest {
             replaceConfigurationFile("data/xkms/certificates/crls/wss40CACRL.cer",
                                      new File("src/test/resources/data/xkms/certificates/crls/wss40CACRL.cer")),
             replaceConfigurationFile("etc/org.apache.cxf.xkms.cfg", getConfigFile()),
-
+            replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg", 
+                    new File("src/test/resources/etc/org.ops4j.pax.logging.cfg")),
             editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg", "org.ops4j.pax.url.mvn.repositories",
REPOS), 
             editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port",
HTTP_PORT),
             editConfigurationFilePut("etc/org.apache.cxf.xkms.client.cfg", "xkms.endpoint",
XKMS_ENDPOINT),
             features(xkmsFeatures, "cxf-xkms-service", "cxf-xkms-client"),
+            configureConsole().ignoreLocalConsole(),
+            keepRuntimeFolder()
             //CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
         };
     }

Modified: cxf/trunk/services/xkms/xkms-itests/src/test/resources/etc/org.apache.cxf.xkms.cfg
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-itests/src/test/resources/etc/org.apache.cxf.xkms.cfg?rev=1536397&r1=1536396&r2=1536397&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-itests/src/test/resources/etc/org.apache.cxf.xkms.cfg (original)
+++ cxf/trunk/services/xkms/xkms-itests/src/test/resources/etc/org.apache.cxf.xkms.cfg Mon
Oct 28 16:39:27 2013
@@ -26,6 +26,9 @@ xkms.certificate.repo=file
 # Disable Revocation
 xkms.enableRevocation=false
 
+# Do not log exceptions on server side
+xkms.logExceptions=false
+
 # Filesystem backend
 xkms.file.storageDir=data/xkms/certificates
 

Added: cxf/trunk/services/xkms/xkms-itests/src/test/resources/etc/org.ops4j.pax.logging.cfg
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-itests/src/test/resources/etc/org.ops4j.pax.logging.cfg?rev=1536397&view=auto
==============================================================================
--- cxf/trunk/services/xkms/xkms-itests/src/test/resources/etc/org.ops4j.pax.logging.cfg (added)
+++ cxf/trunk/services/xkms/xkms-itests/src/test/resources/etc/org.ops4j.pax.logging.cfg Mon
Oct 28 16:39:27 2013
@@ -0,0 +1,25 @@
+# Root logger
+log4j.rootLogger=WARN, stdout, file
+log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer
+
+log4j.logger.org.apache.cxf.xkms=INFO
+log4j.logger.org.apache.cxf.xkms.x509.validator=WARN
+
+# Reduce noisy output
+log4j.logger.org.ops4j.pax.swissbox.bnd.BndUtils=ERROR
+
+# CONSOLE appender
+log4j.appender.stdout.threshold=INFO
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-50.50c | %m%n
+#log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-40.40c | %-3.3X{bundle.id}
- %-20.20X{bundle.name} | %m%n
+
+
+# File appender
+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.append=true

Modified: cxf/trunk/services/xkms/xkms-osgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-osgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1536397&r1=1536396&r2=1536397&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-osgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(original)
+++ cxf/trunk/services/xkms/xkms-osgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Mon Oct 28 16:39:27 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/trunk/services/xkms/xkms-service/src/main/java/org/apache/cxf/xkms/service/XKMSService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-service/src/main/java/org/apache/cxf/xkms/service/XKMSService.java?rev=1536397&r1=1536396&r2=1536397&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-service/src/main/java/org/apache/cxf/xkms/service/XKMSService.java
(original)
+++ cxf/trunk/services/xkms/xkms-service/src/main/java/org/apache/cxf/xkms/service/XKMSService.java
Mon Oct 28 16:39:27 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");
         }
     }
 }
+

Modified: cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java?rev=1536397&r1=1536396&r2=1536397&view=diff
==============================================================================
--- cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java
(original)
+++ cxf/trunk/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/validator/DateValidator.java
Mon Oct 28 16:39:27 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