From commits-return-15254-apmail-activemq-commits-archive=activemq.apache.org@activemq.apache.org Wed Dec 22 11:17:36 2010 Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 11891 invoked from network); 22 Dec 2010 11:17:36 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Dec 2010 11:17:36 -0000 Received: (qmail 77254 invoked by uid 500); 22 Dec 2010 11:17:36 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 77194 invoked by uid 500); 22 Dec 2010 11:17:35 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 77181 invoked by uid 99); 22 Dec 2010 11:17:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Dec 2010 11:17:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Dec 2010 11:17:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2D7DF2388A43; Wed, 22 Dec 2010 11:17:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@activemq.apache.org From: dejanb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101222111714.2D7DF2388A43@eris.apache.org> 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 @@ /* + + + audit + org.apache.activemq.web.AuditFilter + + + audit + *.action + + 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); + } +}