cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From owu...@apache.org
Subject svn commit: r1487036 - in /cxf/branches/2.7.x-fixes/services/sts: sts-core/ sts-core/src/main/java/org/apache/cxf/sts/event/ sts-war/src/main/resources/
Date Tue, 28 May 2013 18:47:20 GMT
Author: owulff
Date: Tue May 28 18:47:20 2013
New Revision: 1487036

URL: http://svn.apache.org/r1487036
Log:
PatternLayout added for LoggerListener

Added:
    cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerPatternLayoutLog4J.java
    cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerPatternLayoutLogback.java
Modified:
    cxf/branches/2.7.x-fixes/services/sts/sts-core/pom.xml
    cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerListener.java
    cxf/branches/2.7.x-fixes/services/sts/sts-war/src/main/resources/log4j.properties

Modified: cxf/branches/2.7.x-fixes/services/sts/sts-core/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/sts/sts-core/pom.xml?rev=1487036&r1=1487035&r2=1487036&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/services/sts/sts-core/pom.xml (original)
+++ cxf/branches/2.7.x-fixes/services/sts/sts-core/pom.xml Tue May 28 18:47:20 2013
@@ -92,7 +92,20 @@
             <artifactId>${cxf.servlet-api.artifact}</artifactId>
             <scope>provided</scope>
             <optional>true</optional>
-        </dependency>        
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.17</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>1.0.13</version>
+            <scope>provided</scope>
+        </dependency>
+             
    </dependencies>
 
    <build>

Modified: cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerListener.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerListener.java?rev=1487036&r1=1487035&r2=1487036&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerListener.java
(original)
+++ cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerListener.java
Tue May 28 18:47:20 2013
@@ -125,14 +125,25 @@ public class LoggerListener implements A
             map.put(KEYS.DURATION.name(), String.valueOf(baseEvent.getDuration()) + "ms");
             
             TokenProviderParameters params = event.getTokenParameters();
-            HttpServletRequest req = (HttpServletRequest)params.getWebServiceContext().
-                getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);
-            map.put(KEYS.REMOTE_HOST.name(), req.getRemoteHost());
-            map.put(KEYS.REMOTE_PORT.name(), String.valueOf(req.getRemotePort()));
-            map.put(KEYS.URL.name(), (String)params.getWebServiceContext().
-                    getMessageContext().get("org.apache.cxf.request.url"));
+            try {
+                HttpServletRequest req = (HttpServletRequest)params.getWebServiceContext().
+                    getMessageContext().get(AbstractHTTPDestination.HTTP_REQUEST);
+                map.put(KEYS.REMOTE_HOST.name(), req.getRemoteHost());
+                map.put(KEYS.REMOTE_PORT.name(), String.valueOf(req.getRemotePort()));
+                map.put(KEYS.URL.name(), (String)params.getWebServiceContext().
+                        getMessageContext().get("org.apache.cxf.request.url"));
+            } catch (NullPointerException ex) {
+                map.put(KEYS.REMOTE_HOST.name(), "N.A.");
+                map.put(KEYS.REMOTE_PORT.name(), "N.A.");
+                map.put(KEYS.URL.name(), "N.A.");
+            }
+            
+            try {
+                map.put(KEYS.TOKENTYPE.name(), params.getTokenRequirements().getTokenType());
+            } catch (NullPointerException ex) {
+                map.put(KEYS.TOKENTYPE.name(), "N.A.");
+            }
             
-            map.put(KEYS.TOKENTYPE.name(), params.getTokenRequirements().getTokenType());
             try {
                 if (params.getTokenRequirements().getOnBehalfOf() != null) {
                     map.put(KEYS.ONBEHALFOF_PRINCIPAL.name(),

Added: cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerPatternLayoutLog4J.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerPatternLayoutLog4J.java?rev=1487036&view=auto
==============================================================================
--- cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerPatternLayoutLog4J.java
(added)
+++ cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerPatternLayoutLog4J.java
Tue May 28 18:47:20 2013
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.sts.event;
+
+import org.apache.log4j.PatternLayout;
+
+public class LoggerPatternLayoutLog4J extends PatternLayout {
+
+    private String header;  
+    
+    public void setHeader(String header) {  
+        this.header = header;  
+    }  
+  
+    @Override
+    public String getHeader() {
+        if (this.header != null) {
+            return this.header + System.getProperty("line.separator");
+        }
+        LoggerListener ll = new LoggerListener();
+        StringBuffer line = new StringBuffer();
+        for (String item : ll.getFieldOrder()) {
+            line.append(item).append(";");
+        }
+        return line.toString() + System.getProperty("line.separator");
+    }  
+    
+}

Added: cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerPatternLayoutLogback.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerPatternLayoutLogback.java?rev=1487036&view=auto
==============================================================================
--- cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerPatternLayoutLogback.java
(added)
+++ cxf/branches/2.7.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/event/LoggerPatternLayoutLogback.java
Tue May 28 18:47:20 2013
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.sts.event;
+
+import ch.qos.logback.classic.PatternLayout;
+
+public class LoggerPatternLayoutLogback extends PatternLayout {
+    
+    private String header;  
+
+    @Override
+    public String getFileHeader() {
+        if (this.header != null) {
+            return this.header + System.getProperty("line.separator");
+        }
+        LoggerListener ll = new LoggerListener();
+        StringBuffer line = new StringBuffer();
+        for (String item : ll.getFieldOrder()) {
+            line.append(item).append(";");
+        }
+        return line.toString() + System.getProperty("line.separator");        
+    }
+
+}

Modified: cxf/branches/2.7.x-fixes/services/sts/sts-war/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/services/sts/sts-war/src/main/resources/log4j.properties?rev=1487036&r1=1487035&r2=1487036&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/services/sts/sts-war/src/main/resources/log4j.properties (original)
+++ cxf/branches/2.7.x-fixes/services/sts/sts-war/src/main/resources/log4j.properties Tue
May 28 18:47:20 2013
@@ -20,5 +20,6 @@ log4j.appender.AUDIT=org.apache.log4j.Fi
 log4j.appender.AUDIT.File=${catalina.base}/logs/audit.log
 log4j.appender.AUDIT.Append=true
 log4j.appender.AUDIT.Threshold=DEBUG
-log4j.appender.AUDIT.layout=org.apache.log4j.PatternLayout
-log4j.appender.AUDIT.layout.ConversionPattern=%m%n
\ No newline at end of file
+log4j.appender.AUDIT.layout=org.apache.cxf.sts.event.LoggerPatternLayoutLog4J
+log4j.appender.AUDIT.layout.ConversionPattern=%m%n
+#log4j.appender.AUDIT.layout.Header=TIME;STATUS;DURATION;REMOTE_HOST;REMOTE_PORT;OPERATION;URL;REALM;WS_SEC_PRINCIPAL;ONBEHALFOF_PRINCIPAL;ACTAS_PRINCIPAL;VALIDATE_PRINCIPAL;CANCEL_PRINCIPAL;RENEW_PRINCIPAL;TOKENTYPE;APPLIESTO;CLAIMS_PRIMARY;CLAIMS_SECONDARY;EXCEPTION;
\ No newline at end of file



Mime
View raw message