activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1051842 - in /activemq/trunk: activemq-core/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java activemq-web-console/src/main/webapp/WEB-INF/web.xml activemq-web/src/main/java/org/apache/activemq/web/AuditFilter.java
Date Wed, 22 Dec 2010 11:17:14 GMT
Author: dejanb
Date: Wed Dec 22 11:17:13 2010
New Revision: 1051842

URL: http://svn.apache.org/viewvc?rev=1051842&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3100 - audit logging for web console

Added:
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/AuditFilter.java
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java
    activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/web.xml

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java?rev=1051842&r1=1051841&r2=1051842&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/AnnotatedMBean.java
Wed Dec 22 11:17:13 2010
@@ -172,7 +172,7 @@ public class AnnotatedMBean extends Stan
                     caller += principal.getName() + " ";
                 }
             }
-            LOG.info(caller.trim() + " called " + this.getMBeanInfo().getClassName() + "."
+ s  + Arrays.toString(objects) + "");
+            LOG.info(caller.trim() + " called " + this.getMBeanInfo().getClassName() + "."
+ s  + Arrays.toString(objects));
         }
         return super.invoke(s, objects, strings);
     }

Modified: activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/web.xml?rev=1051842&r1=1051841&r2=1051842&view=diff
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/web.xml (original)
+++ activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/web.xml Wed Dec 22 11:17:13
2010
@@ -108,6 +108,16 @@
     <url-pattern>/*</url-pattern>
   </filter-mapping>
 
+  <!-- enable audit logging -->
+  <filter>
+    <filter-name>audit</filter-name>
+    <filter-class>org.apache.activemq.web.AuditFilter</filter-class>
+  </filter>
+  <filter-mapping>
+    <filter-name>audit</filter-name>
+    <url-pattern>*.action</url-pattern>
+  </filter-mapping>
+
 
   <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
   <!--              Spring listener.                 						 -->

Added: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/AuditFilter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/AuditFilter.java?rev=1051842&view=auto
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/AuditFilter.java (added)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/AuditFilter.java Wed
Dec 22 11:17:13 2010
@@ -0,0 +1,60 @@
+/**
+ * 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.activemq.web;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Enumeration;
+
+public class AuditFilter implements Filter {
+
+    private static final Log LOG = LogFactory.getLog("org.apache.activemq.audit");
+
+    private boolean audit;
+
+    public void init(FilterConfig filterConfig) throws ServletException {
+       audit = "true".equalsIgnoreCase(System.getProperty("org.apache.activemq.audit"));
+    }
+
+    public void destroy() {
+    }
+
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
+        if (audit && request instanceof HttpServletRequest) {
+
+            HttpServletRequest http = (HttpServletRequest)request;
+            Enumeration params = http.getParameterNames();
+            String formattedParams = "";
+            while (params.hasMoreElements()) {
+                String paramName = (String)params.nextElement();
+                String paramValue = http.getParameter(paramName);
+                formattedParams += paramName + "='" + paramValue + "' ";
+            }
+            String user = "anonymous";
+            if (http.getRemoteUser() != null) {
+                user = http.getRemoteUser();
+            }
+            LOG.info(user + " requested " + http.getRequestURI() + " [" + formattedParams
+ "] from " + http.getRemoteAddr());
+        }
+        chain.doFilter(request, response);
+    }
+}



Mime
View raw message