portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r553804 - in /portals/jetspeed-2/trunk: applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/ applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/ applications/j2-admin/src/webapp/WEB-INF/ components/p...
Date Fri, 06 Jul 2007 09:15:53 GMT
Author: taylor
Date: Fri Jul  6 02:15:49 2007
New Revision: 553804

URL: http://svn.apache.org/viewvc?view=rev&rev=553804
Log:
https://issues.apache.org/jira/browse/JS2-724
Auditing Activity logging implemented.

Added:
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/impl/
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/impl/ActivityBean.java
    portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/impl/AuditActivityImpl.java
    portals/jetspeed-2/trunk/components/statistics/src/test/org/apache/jetspeed/audit/
    portals/jetspeed-2/trunk/components/statistics/src/test/org/apache/jetspeed/audit/TestAuditActivity.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/audit/
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/audit/AuditActivity.java
Modified:
    portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/ChangePasswordPortlet.java
    portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
    portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/jetspeed-portlet.xml
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginErrorServlet.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginRedirectorServlet.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/filter/PortalFilter.java
    portals/jetspeed-2/trunk/components/statistics/maven.xml
    portals/jetspeed-2/trunk/etc/schema/phase1-schema.xml
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/statistics.xml

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/ChangePasswordPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/ChangePasswordPortlet.java?view=diff&rev=553804&r1=553803&r2=553804
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/ChangePasswordPortlet.java (original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/ChangePasswordPortlet.java Fri Jul  6 02:15:49 2007
@@ -25,6 +25,7 @@
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 
@@ -32,6 +33,8 @@
 import org.apache.jetspeed.PortalReservedParameters;
 import javax.security.auth.Subject;
 
+import org.apache.jetspeed.audit.AuditActivity;
+import org.apache.jetspeed.portlets.security.users.UserDetailsPortlet;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.security.InvalidNewPasswordException;
 import org.apache.jetspeed.security.InvalidPasswordException;
@@ -50,6 +53,7 @@
 public class ChangePasswordPortlet extends GenericServletPortlet
 {
     private UserManager manager;
+    private AuditActivity audit;
     
     public static final String CURRENT_PASSWORD = "currentPassword";
     public static final String NEW_PASSWORD = "newPassword";
@@ -69,6 +73,11 @@
         {
             throw new PortletException("Failed to find the User Manager on portlet initialization");
         }
+        audit = (AuditActivity)getPortletContext().getAttribute(CommonPortletServices.CPS_AUDIT_ACTIVITY);
+        if (null == audit)
+        {
+            throw new PortletException("Failed to find the Audit Activity on portlet initialization");            
+        }        
     }
     
     public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
@@ -134,6 +143,7 @@
                 String currPassword = actionRequest.getParameter(CURRENT_PASSWORD);
                 String newPassword = actionRequest.getParameter(NEW_PASSWORD);
                 String newPasswordAgain = actionRequest.getParameter(NEW_PASSWORD_AGAIN);
+                String userName = actionRequest.getUserPrincipal().getName();
             
                 if (currPassword == null || currPassword.length() == 0)
                 {
@@ -159,8 +169,8 @@
                 {
                     try
                     {
-                        String userName = actionRequest.getUserPrincipal().getName();
                         manager.setPassword(userName, currPassword, newPassword);
+                        audit.logUserActivity(userName, getIPAddress(actionRequest), AuditActivity.PASSWORD_CHANGE_SUCCESS, UserDetailsPortlet.USER_ADMINISTRATION);
 
                         // refresh/update Subject in session to reflect the changed PasswordCredential
                         Subject subject = manager.getUser(userName).getSubject();
@@ -188,6 +198,7 @@
                 if ( errorMessages.size() > 0 )
                 {
                     actionRequest.getPortletSession().setAttribute(ERROR_MESSAGES,errorMessages);
+                    audit.logUserActivity(userName, getIPAddress(actionRequest), AuditActivity.PASSWORD_CHANGE_FAILURE, errorMessages.toString());                    
                 }
                 else
                 {
@@ -196,4 +207,13 @@
             }
         }
     }
+
+    protected String getIPAddress(PortletRequest request)
+    {
+        RequestContext context = (RequestContext)request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+        if (context == null)
+            return "";
+        return context.getRequest().getRemoteAddr();
+    }
+    
 }

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java?view=diff&rev=553804&r1=553803&r2=553804
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java (original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java Fri Jul  6 02:15:49 2007
@@ -41,8 +41,10 @@
 import javax.security.auth.Subject;
 
 import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.administration.PortalConfiguration;
 import org.apache.jetspeed.administration.PortalConfigurationConstants;
+import org.apache.jetspeed.audit.AuditActivity;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.container.JetspeedPortletContext;
 import org.apache.jetspeed.om.common.UserAttribute;
@@ -55,6 +57,7 @@
 import org.apache.jetspeed.portlets.security.SecurityUtil;
 import org.apache.jetspeed.profiler.Profiler;
 import org.apache.jetspeed.profiler.rules.PrincipalRule;
+import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.security.Group;
 import org.apache.jetspeed.security.GroupManager;
 import org.apache.jetspeed.security.InvalidNewPasswordException;
@@ -123,6 +126,8 @@
     /** the id of the groups control */
     private static final String GROUPS_CONTROL = "jetspeedGroups";
     
+    public static final String USER_ADMINISTRATION = "J2 User Administration";
+    
     private PageManager pageManager;
     private UserManager userManager;
     private RoleManager roleManager;
@@ -133,6 +138,7 @@
     private Collection paUserAttributes;
     private boolean initPrefsAndAttr;
     private PortalConfiguration configuration;
+    private AuditActivity audit;
     
     private LinkedHashMap userTabMap;
     private LinkedHashMap anonymousUserTabMap;
@@ -179,6 +185,12 @@
             throw new PortletException("Failed to find the Portal Configuration on portlet initialization");
         }
         
+        audit = (AuditActivity)getPortletContext().getAttribute(CommonPortletServices.CPS_AUDIT_ACTIVITY);
+        if (null == audit)
+        {
+            throw new PortletException("Failed to find the Audit Activity on portlet initialization");            
+        }
+        
         paIdentifier = ((MutablePortletApplication)((JetspeedPortletContext)config.getPortletContext())
                 .getApplication()).getApplicationIdentifier();
     }
@@ -652,8 +664,8 @@
                 {
                     Folder folder = pageManager.getFolder(subsite);                    
                     pageManager.removeFolder(folder);
-                }
-                            
+                }                
+                audit.logAdminUserActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_DELETE, USER_ADMINISTRATION);            
                 // remove selected user from USERS_TOPIC
                 PortletMessaging.cancel(actionRequest,SecurityResources.TOPIC_USERS, SecurityResources.MESSAGE_SELECTED);
                 // TODO: send message to site manager portlet
@@ -698,6 +710,7 @@
                 if ( password != null && password.trim().length() > 0 )
                 {
                     userManager.setPassword(userName, null, password);
+                    audit.logAdminCredentialActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.PASSWORD_RESET, USER_ADMINISTRATION);                                                                                            
                     passwordSet = true;
                 }
                 PasswordCredential credential = getCredential(actionRequest, userName);
@@ -710,6 +723,7 @@
                         if (updateRequired != credential.isUpdateRequired())
                         {
                             userManager.setPasswordUpdateRequired(userName,updateRequired);
+                            audit.logAdminCredentialActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.PASSWORD_UPDATE_REQUIRED, USER_ADMINISTRATION);                                                                                                                        
                         }
                     }
                     String enabledStr = actionRequest.getParameter("user_cred_enabled");
@@ -719,6 +733,8 @@
                         if (enabled != credential.isEnabled())
                         {
                             userManager.setPasswordEnabled(userName,enabled);
+                            String activity = (enabled) ? AuditActivity.PASSWORD_ENABLED : AuditActivity.PASSWORD_DISABLED;
+                            audit.logAdminCredentialActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, activity, USER_ADMINISTRATION);                                                                                                                                                                                
                         }
                     }
                     String expiredFlagStr = actionRequest.getParameter("user_expired_flag");
@@ -727,15 +743,18 @@
                         if ( !passwordSet && expiredFlagStr.equals("expired"))
                         {
                             java.sql.Date today = new java.sql.Date(new Date().getTime());
-                            userManager.setPasswordExpiration(userName,today);
+                            userManager.setPasswordExpiration(userName,today);                            
+                            audit.logAdminCredentialActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.PASSWORD_EXPIRE, USER_ADMINISTRATION);                                                                                                                                                                                                            
                         }
                         else if (expiredFlagStr.equals("extend"))
                         {
                             userManager.setPasswordExpiration(userName,null);
+                            audit.logAdminCredentialActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.PASSWORD_EXTEND, USER_ADMINISTRATION);                                                                                                                                                                                                                                        
                         }
                         else if (expiredFlagStr.equals("unlimited"))
                         {
                             userManager.setPasswordExpiration(userName,InternalCredential.MAX_DATE);
+                            audit.logAdminCredentialActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.PASSWORD_UNLIMITED, USER_ADMINISTRATION);                                                                                                                                                                                                                                                                    
                         }
                     }
                 }
@@ -776,6 +795,7 @@
                 if (value != null)
                 {
                     user.getUserAttributes().put(attr.getName(), value);
+                    audit.logAdminAttributeActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_ADD_ATTRIBUTE, attr.getName(), value, USER_ADMINISTRATION);                                
                 }
             }
         }
@@ -800,6 +820,7 @@
                     String userAttrName = userAttrNames[i];
                     String value = actionRequest.getParameter(userAttrName + ":value");
                     user.getUserAttributes().put(userAttrName, value);
+                    audit.logAdminAttributeActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_UPDATE_ATTRIBUTE, userAttrName, value, USER_ADMINISTRATION);                                                    
                 }                
             }        
         }
@@ -818,6 +839,7 @@
             {
                 Preferences attributes = user.getUserAttributes();
                 attributes.put(userAttrName, userAttrValue);
+                audit.logAdminAttributeActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_ADD_ATTRIBUTE, userAttrName, userAttrValue, USER_ADMINISTRATION);                                                
             }
         }
     }
@@ -840,6 +862,7 @@
                     try
                     {
                         attributes.remove(userAttrNames[ix]);
+                        audit.logAdminAttributeActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_DELETE_ATTRIBUTE, userAttrNames[ix], "", USER_ADMINISTRATION);                                                                        
                     }
                     catch (Exception e) 
                     {
@@ -868,6 +891,7 @@
                         if (roleManager.roleExists(roleNames[ix]))
                         {
                             roleManager.removeRoleFromUser(userName, roleNames[ix]);
+                            audit.logAdminAttributeActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_DELETE_ROLE, roleNames[ix], "", USER_ADMINISTRATION);                                                                                                    
                         }
                     }
                     catch (SecurityException e)
@@ -892,6 +916,7 @@
                 try
                 {
                     roleManager.addRoleToUser(userName, roleName);
+                    audit.logAdminAttributeActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_ADD_ROLE, roleName, "", USER_ADMINISTRATION);                                                                                                                        
                 }
                 catch (SecurityException e)
                 {
@@ -919,6 +944,7 @@
                         if (groupManager.groupExists(groupNames[ix]))
                         {
                             groupManager.removeUserFromGroup(userName, groupNames[ix]);
+                            audit.logAdminAttributeActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_DELETE_GROUP, groupNames[ix], "", USER_ADMINISTRATION);                                                                                                                                
                         }
                     }
                     catch (SecurityException e)
@@ -943,6 +969,7 @@
                 try
                 {
                     groupManager.addUserToGroup(userName, groupName);
+                    audit.logAdminAttributeActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_ADD_GROUP, groupName, "", USER_ADMINISTRATION);                                                                                                                                            
                 }
                 catch (SecurityException e)
                 {
@@ -1051,7 +1078,8 @@
                     String ruleName = actionRequest.getParameter("select_rule");
                     profiler.setRuleForPrincipal(userPrincipal, 
                             profiler.getRule(ruleName),
-                            locatorName);                                                         
+                            locatorName);              
+                    audit.logAdminAttributeActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_ADD_PROFILE, ruleName, locatorName, USER_ADMINISTRATION);                                                                                                                                            
                 }
                 catch (Exception e)
                 {
@@ -1086,6 +1114,7 @@
                             if (rule.getLocatorName().equals(locatorNames[ix]))
                             {
                                 profiler.deletePrincipalRule(rule);
+                                audit.logAdminAttributeActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_DELETE_PROFILE, rule.getProfilingRule().getId(), rule.getLocatorName(), USER_ADMINISTRATION);                                                                                                                                                        
                             }
                         }
                     }
@@ -1111,9 +1140,11 @@
                     throw new SecurityException(SecurityException.PASSWORD_REQUIRED);
                 }
                 userManager.addUser(userName, password);
+                audit.logAdminUserActivity(actionRequest.getRemoteUser(), getIPAddress(actionRequest), userName, AuditActivity.USER_CREATE, USER_ADMINISTRATION);            
+                
                 PortletMessaging.publish(actionRequest, SecurityResources.TOPIC_USERS, SecurityResources.MESSAGE_REFRESH, "true");
                 PortletMessaging.publish(actionRequest, SecurityResources.TOPIC_USERS, SecurityResources.MESSAGE_SELECTED, userName);
-                                
+                                                
                 User user = userManager.getUser(userName);
                 
                 PasswordCredential credential = getCredential(user);
@@ -1167,6 +1198,7 @@
                     Principal principal = SecurityUtil.getPrincipal(user.getSubject(), UserPrincipal.class);                         
                     profiler.setRuleForPrincipal(principal, profiler.getRule(rule), "page");
                 }                
+                                
             }
             catch (SecurityException sex)
             {
@@ -1188,4 +1220,11 @@
     }
     */    
     
+    protected String getIPAddress(PortletRequest request)
+    {
+        RequestContext context = (RequestContext)request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+        if (context == null)
+            return "";
+        return context.getRequest().getRemoteAddr();
+    }
 }

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/jetspeed-portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/jetspeed-portlet.xml?view=diff&rev=553804&r1=553803&r2=553804
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/jetspeed-portlet.xml (original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/jetspeed-portlet.xml Fri Jul  6 02:15:49 2007
@@ -134,6 +134,7 @@
         <js:service name='PortletTrackingManager'/>     
         <js:service name='PortalConfiguration'/>
         <js:service name='ImporterManager'/>
+        <js:service name='AuditActivity'/>
 	</js:services>
 
 </portlet-app>

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginErrorServlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginErrorServlet.java?view=diff&rev=553804&r1=553803&r2=553804
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginErrorServlet.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginErrorServlet.java Fri Jul  6 02:15:49 2007
@@ -24,6 +24,9 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.audit.AuditActivity;
+
 /**
  * LoginErrorServlet
  * 
@@ -52,6 +55,12 @@
             retryCount = new Integer(retryCount.intValue() + 1);
         session.setAttribute(LoginConstants.RETRYCOUNT, retryCount);
 
+        String username = (String)session.getAttribute(LoginConstants.USERNAME);        
+        AuditActivity audit = (AuditActivity)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.audit.AuditActivity");
+        if (audit != null)
+        {
+            audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_FAILURE, "Active Authentication");
+        }        
         response.sendRedirect(response.encodeURL(destination));
     }
 

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginRedirectorServlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginRedirectorServlet.java?view=diff&rev=553804&r1=553803&r2=553804
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginRedirectorServlet.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/LoginRedirectorServlet.java Fri Jul  6 02:15:49 2007
@@ -26,7 +26,7 @@
 
 import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.PortalReservedParameters;
-import org.apache.jetspeed.administration.PortalAuthenticationConfiguration;
+import org.apache.jetspeed.audit.AuditActivity;
 
 /**
  * LoginRedirectorServlet
@@ -48,11 +48,18 @@
         else
             session.removeAttribute(LoginConstants.DESTINATION);
 
+        String username = (String)session.getAttribute(LoginConstants.USERNAME);
+        
         session.removeAttribute(LoginConstants.USERNAME);
         session.removeAttribute(LoginConstants.PASSWORD);
         session.removeAttribute(LoginConstants.RETRYCOUNT);
         session.removeAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE);
-                
+
+        AuditActivity audit = (AuditActivity)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.audit.AuditActivity");
+        if (audit != null)
+        {
+            audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_SUCCESS, "Active Authentication");
+        }
         response.sendRedirect(response.encodeURL(destination));
     }
 
@@ -60,5 +67,5 @@
             HttpServletResponse response) throws IOException, ServletException
     {
         doGet(request, response);
-    }
+    }    
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/filter/PortalFilter.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/filter/PortalFilter.java?view=diff&rev=553804&r1=553803&r2=553804
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/filter/PortalFilter.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/login/filter/PortalFilter.java Fri Jul  6 02:15:49 2007
@@ -35,6 +35,7 @@
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.administration.PortalAuthenticationConfiguration;
 import org.apache.jetspeed.administration.PortalConfiguration;
+import org.apache.jetspeed.audit.AuditActivity;
 import org.apache.jetspeed.login.LoginConstants;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.security.SecurityException;
@@ -68,12 +69,14 @@
             String password = request.getParameter(LoginConstants.PASSWORD);            
             if (username != null)
             {
-                UserManager userManager = (UserManager)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.security.UserManager");                
+                UserManager userManager = (UserManager)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.security.UserManager");
+                AuditActivity audit = (AuditActivity)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.audit.AuditActivity");                
                 boolean success = userManager.authenticate(username, password);
                 if (success)
                 {
+                    audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_SUCCESS, "PortalFilter");
                     PortalAuthenticationConfiguration authenticationConfiguration = (PortalAuthenticationConfiguration)
-                        Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.administration.PortalAuthenticationConfiguration");   
+                        Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.administration.PortalAuthenticationConfiguration");
                     if (authenticationConfiguration.isCreateNewSessionOnLogin())
                     {
                         request.getSession().invalidate();
@@ -108,6 +111,7 @@
                 }
                 else
                 {
+                    audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_FAILURE, "PortalFilter");                    
                     request.getSession().setAttribute(LoginConstants.ERRORCODE, LoginConstants.ERROR_INVALID_PASSWORD);                    
                 }
             }

Modified: portals/jetspeed-2/trunk/components/statistics/maven.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/statistics/maven.xml?view=diff&rev=553804&r1=553803&r2=553804
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/maven.xml (original)
+++ portals/jetspeed-2/trunk/components/statistics/maven.xml Fri Jul  6 02:15:49 2007
@@ -17,6 +17,6 @@
 -->
 <project default="java:jar" xmlns:j="jelly:core" xmlns:define="jelly:define">
 
-    <property name="testcase" value="org.apache.jetspeed.statistics.TestStatistics" />
+    <property name="testcase" value="org.apache.jetspeed.audit.TestAuditActivity" />
 
 </project>

Added: portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/impl/ActivityBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/impl/ActivityBean.java?view=auto&rev=553804
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/impl/ActivityBean.java (added)
+++ portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/impl/ActivityBean.java Fri Jul  6 02:15:49 2007
@@ -0,0 +1,122 @@
+/*
+ * 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.jetspeed.audit.impl;
+
+import java.sql.Timestamp;
+
+public class ActivityBean
+{
+    private String activity;
+    private String category;
+    private String admin;
+    private String userName;
+    private Timestamp timestamp;
+    private String ipAddress;
+    private String name;
+    private String value;
+    private String description;
+    
+    public String getActivity()
+    {
+        return activity;
+    }
+    
+    public void setActivity(String activity)
+    {
+        this.activity = activity;
+    }
+    
+    public String getAdmin()
+    {
+        return admin;
+    }
+    
+    public void setAdmin(String admin)
+    {
+        this.admin = admin;
+    }
+    
+    public String getCategory()
+    {
+        return category;
+    }
+    
+    public void setCategory(String category)
+    {
+        this.category = category;
+    }
+    
+    public String getDescription()
+    {
+        return description;
+    }
+    
+    public void setDescription(String description)
+    {
+        this.description = description;
+    }
+    
+    public String getIpAddress()
+    {
+        return ipAddress;
+    }
+    
+    public void setIpAddress(String ipAddress)
+    {
+        this.ipAddress = ipAddress;
+    }
+    
+    public String getName()
+    {
+        return name;
+    }
+    
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+    
+    public Timestamp getTimestamp()
+    {
+        return timestamp;
+    }
+    
+    public void setTimestamp(Timestamp timestamp)
+    {
+        this.timestamp = timestamp;
+    }
+    
+    public String getUserName()
+    {
+        return userName;
+    }
+    
+    public void setUserName(String userName)
+    {
+        this.userName = userName;
+    }
+    
+    public String getValue()
+    {
+        return value;
+    }
+    
+    public void setValue(String value)
+    {
+        this.value = value;
+    }    
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/impl/AuditActivityImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/impl/AuditActivityImpl.java?view=auto&rev=553804
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/impl/AuditActivityImpl.java (added)
+++ portals/jetspeed-2/trunk/components/statistics/src/java/org/apache/jetspeed/audit/impl/AuditActivityImpl.java Fri Jul  6 02:15:49 2007
@@ -0,0 +1,173 @@
+/*
+ * 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.jetspeed.audit.impl;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.audit.AuditActivity;
+import org.springframework.orm.ojb.support.PersistenceBrokerDaoSupport;
+
+/**
+ * <p>
+ * Gathers information about security auditing activity  
+ * </p>
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: $
+ */
+public class AuditActivityImpl extends PersistenceBrokerDaoSupport implements AuditActivity
+{
+    protected final static Log log = LogFactory.getLog(AuditActivityImpl.class);
+    
+    protected DataSource ds;
+    protected String anonymousUser = "guest";
+    protected boolean enabled = true;
+
+    public AuditActivityImpl(DataSource dataSource)
+    {
+        this.ds = dataSource;        
+    }
+    
+    public void setEnabled(boolean enabled)
+    {
+        this.enabled = enabled;
+    }
+    
+    public boolean getEnabled()
+    {
+        return this.enabled;
+    }
+    
+    public DataSource getDataSource()
+    {
+        return ds;
+    }
+    
+    public void logAdminAttributeActivity(String adminName, String ipAddress, String targetUser, String activity, String name, String value, String description)
+    {
+        if (enabled)
+        {
+            logAdminActivity(adminName, ipAddress, targetUser, activity, description, AuditActivity.CAT_ADMIN_ATTRIBUTE_MAINTENANCE, name, value);
+        }
+    }
+
+    public void logAdminCredentialActivity(String adminName, String ipAddress, String targetUser, String activity, String description)
+    {
+        if (enabled)
+        {
+            logAdminActivity(adminName, ipAddress, targetUser, activity, description, AuditActivity.CAT_ADMIN_CREDENTIAL_MAINTENANCE, "", "");
+        }
+    }
+
+    public void logAdminUserActivity(String adminName, String ipAddress, String targetUser, String activity, String description)
+    {
+        if (enabled)
+        {
+            logAdminActivity(adminName, ipAddress, targetUser, activity, description, AuditActivity.CAT_ADMIN_USER_MAINTENANCE, "", "");
+        }
+    }
+    
+    protected void logAdminActivity(String adminName, String ipAddress, String targetUser, String activity, String description, String category, String name, String value)
+    {
+        Connection con = null;
+        PreparedStatement stm = null;        
+        try
+        {
+            Timestamp timestamp = new Timestamp(System.currentTimeMillis());
+            con = ds.getConnection();
+            stm  = con.prepareStatement("INSERT INTO ADMIN_ACTIVITY (ACTIVITY, CATEGORY, ADMIN, USER_NAME, TIME_STAMP, IPADDRESS, ATTR_NAME, ATTR_VALUE, DESCRIPTION) VALUES(?,?,?,?,?,?,?,?,?)");
+            stm.setString(1, activity);
+            stm.setString(2, category);
+            stm.setString(3, adminName);
+            stm.setString(4, targetUser);
+            stm.setTimestamp(5, timestamp);
+            stm.setString(6, ipAddress);
+            stm.setString(7, name);
+            stm.setString(8, value);
+            stm.setString(9, description);            
+            stm.execute();            
+        } 
+        catch (SQLException e)
+        {
+            log.error(e);
+        } 
+        finally
+        {
+            try
+            {
+                if (stm != null) stm.close();
+            } 
+            catch (SQLException se) 
+            {}
+            releaseConnection(con);
+        }
+    }
+
+    public void logUserActivity(String userName, String ipAddress, String activity, String description)
+    {
+        if (enabled)
+        {
+            Connection con = null;
+            PreparedStatement stm = null;        
+            try
+            {
+                Timestamp timestamp = new Timestamp(System.currentTimeMillis());
+                con = ds.getConnection();
+                stm  = con.prepareStatement("INSERT INTO USER_ACTIVITY (ACTIVITY, CATEGORY, USER_NAME, TIME_STAMP, IPADDRESS, DESCRIPTION) VALUES(?,?,?,?,?,?)");
+                stm.setString(1, activity);
+                stm.setString(2, AuditActivity.CAT_USER_AUTHENTICATION);
+                stm.setString(3, userName);
+                stm.setTimestamp(4, timestamp);
+                stm.setString(5, ipAddress);
+                stm.setString(6, description);
+                stm.executeUpdate();
+            } 
+            catch (SQLException e)
+            {
+                // todo log to standard Jetspeed logger
+                e.printStackTrace();
+            } 
+            finally
+            {
+                try
+                {
+                    if (stm != null) stm.close();
+                } 
+                catch (SQLException se) 
+                {}
+                releaseConnection(con);
+            }
+        }
+    }    
+    
+    void releaseConnection(Connection con)
+    {
+        try
+        {
+            if (con != null) con.close();
+        } catch (SQLException e)
+        {
+        }
+    }
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/statistics/src/test/org/apache/jetspeed/audit/TestAuditActivity.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/statistics/src/test/org/apache/jetspeed/audit/TestAuditActivity.java?view=auto&rev=553804
==============================================================================
--- portals/jetspeed-2/trunk/components/statistics/src/test/org/apache/jetspeed/audit/TestAuditActivity.java (added)
+++ portals/jetspeed-2/trunk/components/statistics/src/test/org/apache/jetspeed/audit/TestAuditActivity.java Fri Jul  6 02:15:49 2007
@@ -0,0 +1,336 @@
+/*
+ * 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.jetspeed.audit;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.jetspeed.audit.impl.ActivityBean;
+import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
+
+/**
+ * Test Audit Activity
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: $
+ */
+public class TestAuditActivity extends DatasourceEnabledSpringTestCase
+{
+
+    private AuditActivity audit = null;
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        ctx.close();
+        super.tearDown();
+    }
+
+    /**
+     * Start the tests.
+     * 
+     * @param args
+     *            the arguments. Not used
+     */
+    public static void main(String args[])
+    {
+        junit.awtui.TestRunner.main(new String[]
+        { TestAuditActivity.class.getName()});
+
+    }
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        
+        this.audit = (AuditActivity) ctx.getBean("org.apache.jetspeed.audit.AuditActivity");
+        assertNotNull("audit activity service not found ", this.audit);
+    }
+    
+    public void clearDBs()
+    {
+        try
+        {
+            Connection con = audit.getDataSource().getConnection();
+
+            PreparedStatement psmt = con
+                    .prepareStatement("DELETE FROM ADMIN_ACTIVITY");
+            psmt.execute();
+            psmt.close();
+            psmt = con.prepareStatement("DELETE FROM USER_ACTIVITY");
+            psmt.execute();
+            psmt.close();
+            if (con != null) con.close();
+        } catch (SQLException e)
+        {
+            fail("problem with database connection:" + e.toString());
+        }
+    }
+
+    public int count(String query)
+    {
+        int val = -1;
+        try
+        {
+            Connection con = audit.getDataSource().getConnection();
+
+            PreparedStatement psmt = con.prepareStatement(query);
+            ResultSet rs = psmt.executeQuery();
+
+            if (rs.next())
+            {
+                val = rs.getInt(1);
+            }
+            psmt.close();
+            if (con != null) con.close();
+        } catch (SQLException e)
+        {
+            fail("problem with database connection:" + e.toString());
+        }
+        return val;
+    }
+
+    public int countAdminActivity()
+    {
+        return count("SELECT count(*) from ADMIN_ACTIVITY");
+    }
+
+    public int countUserActivity()
+    {
+        return count("SELECT count(*) from USER_ACTIVITY");
+    }
+ 
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(TestAuditActivity.class);
+    }
+
+    public void testUserActivity() throws Exception
+    {
+        assertNotNull("Audit Activity service is null", audit);
+        clearDBs();
+
+        audit.setEnabled(true);
+        assertTrue(audit.getEnabled());
+        
+        // Log User Activity
+        audit.logUserActivity(USER, IP1, AuditActivity.AUTHENTICATION_SUCCESS, MSG_AUTHENTICATION_SUCCESS);
+        audit.logUserActivity(USER, IP1, AuditActivity.AUTHENTICATION_FAILURE, MSG_AUTHENTICATION_FAILURE);
+        
+        int userCount = this.countUserActivity();
+        assertEquals(userCount, 2);
+        
+        ActivityBean userBean = lookupUserActivity(USER_QUERY, AuditActivity.AUTHENTICATION_SUCCESS);
+        assertEquals(userBean.getActivity(), AuditActivity.AUTHENTICATION_SUCCESS);
+        assertEquals(userBean.getCategory(), AuditActivity.CAT_USER_AUTHENTICATION);
+        assertEquals(userBean.getUserName(), USER);
+        assertNotNull(userBean.getTimestamp());
+        assertEquals(userBean.getIpAddress(), IP1);
+        assertEquals(userBean.getDescription(), MSG_AUTHENTICATION_SUCCESS);
+        
+        userBean = lookupUserActivity(USER_QUERY, AuditActivity.AUTHENTICATION_FAILURE);
+        assertEquals(userBean.getActivity(), AuditActivity.AUTHENTICATION_FAILURE);
+        assertEquals(userBean.getCategory(), AuditActivity.CAT_USER_AUTHENTICATION);
+        assertEquals(userBean.getUserName(), USER);
+        assertNotNull(userBean.getTimestamp());
+        assertEquals(userBean.getIpAddress(), IP1);
+        assertEquals(userBean.getDescription(), MSG_AUTHENTICATION_FAILURE);        
+        
+        // Log Admin Activity
+        audit.logAdminUserActivity(ADMIN_USER, IP1, USER, AuditActivity.USER_CREATE, MSG_ADDING_USER);
+        audit.logAdminCredentialActivity(ADMIN_USER, IP1, USER, AuditActivity.PASSWORD_CHANGE_SUCCESS, MSG_CHANGING_PW);
+        audit.logAdminAttributeActivity(ADMIN_USER, IP1, USER, AuditActivity.USER_ADD_ATTRIBUTE, ATTRIBUTE_NAME_1, ATTRIBUTE_VALUE_1, MSG_ATTRIBUTE);
+        
+        int adminCount = this.countAdminActivity();
+        assertEquals(adminCount, 3);
+        
+        ActivityBean adminBean = lookupAdminActivity(ADMIN_QUERY, AuditActivity.USER_CREATE);
+        assertEquals(adminBean.getActivity(), AuditActivity.USER_CREATE);
+        assertEquals(adminBean.getCategory(), AuditActivity.CAT_ADMIN_USER_MAINTENANCE);
+        assertEquals(adminBean.getAdmin(), ADMIN_USER);
+        assertEquals(adminBean.getUserName(), USER);
+        assertNotNull(adminBean.getTimestamp());
+        assertEquals(adminBean.getIpAddress(), IP1);
+        assertEquals(adminBean.getDescription(), MSG_ADDING_USER);
+        assertTrue(adminBean.getName() == null || adminBean.getName().equals(""));
+        assertTrue(adminBean.getValue() == null || adminBean.getValue().equals(""));
+
+        adminBean = lookupAdminActivity(ADMIN_QUERY, AuditActivity.PASSWORD_CHANGE_SUCCESS);
+        assertEquals(adminBean.getActivity(), AuditActivity.PASSWORD_CHANGE_SUCCESS);
+        assertEquals(adminBean.getCategory(), AuditActivity.CAT_ADMIN_CREDENTIAL_MAINTENANCE);
+        assertEquals(adminBean.getAdmin(), ADMIN_USER);
+        assertEquals(adminBean.getUserName(), USER);
+        assertNotNull(adminBean.getTimestamp());
+        assertEquals(adminBean.getIpAddress(), IP1);
+        assertEquals(adminBean.getDescription(), MSG_CHANGING_PW);
+        assertTrue(adminBean.getName() == null || adminBean.getName().equals(""));
+        assertTrue(adminBean.getValue() == null || adminBean.getValue().equals(""));
+
+        adminBean = lookupAdminActivity(ADMIN_QUERY, AuditActivity.USER_ADD_ATTRIBUTE);
+        assertEquals(adminBean.getActivity(), AuditActivity.USER_ADD_ATTRIBUTE);
+        assertEquals(adminBean.getCategory(), AuditActivity.CAT_ADMIN_ATTRIBUTE_MAINTENANCE);
+        assertEquals(adminBean.getAdmin(), ADMIN_USER);
+        assertEquals(adminBean.getUserName(), USER);
+        assertNotNull(adminBean.getTimestamp());
+        assertEquals(adminBean.getIpAddress(), IP1);
+        assertEquals(adminBean.getDescription(), MSG_ATTRIBUTE);
+        assertEquals(adminBean.getName(), ATTRIBUTE_NAME_1);
+        assertEquals(adminBean.getValue(), ATTRIBUTE_VALUE_1);
+        
+        audit.setEnabled(false);
+        assertFalse(audit.getEnabled());
+        audit.logAdminAttributeActivity(ADMIN_USER, IP1, USER, AuditActivity.USER_ADD_ATTRIBUTE, ATTRIBUTE_NAME_1, ATTRIBUTE_VALUE_1, MSG_ATTRIBUTE);        
+        adminCount = this.countAdminActivity();
+        assertEquals(adminCount, 3);        
+    }
+    
+    private static String USER_QUERY = "SELECT * FROM USER_ACTIVITY WHERE ACTIVITY = ?";
+    private static String ADMIN_QUERY = "SELECT * FROM ADMIN_ACTIVITY WHERE ACTIVITY = ?";
+    
+    private static String MSG_AUTHENTICATION_SUCCESS = "logging on via Jetspeed Portal";
+    private static String MSG_AUTHENTICATION_FAILURE = "failure logging on via Jetspeed Portal";
+    private static String MSG_ADDING_USER = "adding new user";
+    private static String MSG_CHANGING_PW = "changing password";
+    private static String MSG_ATTRIBUTE = "Attribute added for user";
+    
+    private static String ADMIN_USER = "admin";
+    private static String USER = "nelson";
+    private static String IP1 = "123.234.145.156";
+    private static String ATTRIBUTE_NAME_1 = "attribute1";
+    private static String ATTRIBUTE_VALUE_1 = "value1";
+    
+
+    private ActivityBean lookupUserActivity(String query, String keyActivity) throws SQLException
+    {
+        Connection con = null;
+        PreparedStatement pstmt = null;
+        ResultSet rs = null;        
+        try
+        {
+            con = audit.getDataSource().getConnection();
+            pstmt = con.prepareStatement(query);
+            pstmt.setString(1, keyActivity);
+            rs = pstmt.executeQuery();
+            rs.next();
+            ActivityBean bean = new ActivityBean();
+            bean.setActivity(rs.getString(1));
+            bean.setCategory(rs.getString(2));
+            bean.setUserName(rs.getString(3));
+            bean.setTimestamp(rs.getTimestamp(4));
+            bean.setIpAddress(rs.getString(5));
+            bean.setDescription(rs.getString(6));
+            return bean;
+        }
+        catch (SQLException e)
+        {
+            throw e;
+        }
+        finally
+        {
+            if (pstmt != null)
+            {
+                pstmt.close();
+            }
+            if (rs != null)
+            {
+                rs.close();
+            }            
+            if (con != null)
+            {
+                try
+                {
+                    con.close();
+                }
+                catch (SQLException ee)
+                {}
+            }
+        }        
+    }
+
+    private ActivityBean lookupAdminActivity(String query, String keyActivity) throws SQLException
+    {
+        Connection con = null;
+        PreparedStatement pstmt = null;
+        ResultSet rs = null;
+        try
+        {
+            con = audit.getDataSource().getConnection();
+            pstmt = con.prepareStatement(query);
+            pstmt.setString(1, keyActivity);
+            rs = pstmt.executeQuery();
+            rs.next();
+            ActivityBean bean = new ActivityBean();
+            bean.setActivity(rs.getString(1));
+            bean.setCategory(rs.getString(2));
+            bean.setAdmin(rs.getString(3));
+            bean.setUserName(rs.getString(4));
+            bean.setTimestamp(rs.getTimestamp(5));
+            bean.setIpAddress(rs.getString(6));
+            bean.setName(rs.getString(7));
+            bean.setValue(rs.getString(8));
+            bean.setDescription(rs.getString(9));
+            return bean;
+        }
+        catch (SQLException e)
+        {
+            throw e;
+        }
+        finally
+        {
+            if (pstmt != null)
+            {
+                pstmt.close();
+            }
+            if (rs != null)
+            {
+                rs.close();
+            }
+            if (con != null)
+            {
+                try
+                {
+                    con.close();
+                }
+                catch (SQLException ee)
+                {}
+            }
+        }        
+    }    
+
+    protected String[] getConfigurations()
+    {
+        return new String[]
+        { "statistics.xml", "transaction.xml", "boot/datasource.xml"};
+    }
+
+    protected String[] getBootConfigurations()
+    {
+        return new String[]
+        { "boot/datasource.xml"};
+    }
+    
+}
\ No newline at end of file

Modified: portals/jetspeed-2/trunk/etc/schema/phase1-schema.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/etc/schema/phase1-schema.xml?view=diff&rev=553804&r1=553803&r2=553804
==============================================================================
--- portals/jetspeed-2/trunk/etc/schema/phase1-schema.xml (original)
+++ portals/jetspeed-2/trunk/etc/schema/phase1-schema.xml Fri Jul  6 02:15:49 2007
@@ -123,19 +123,23 @@
 	</table>    
 	
 	<table name='ADMIN_ACTIVITY'>
-		<column name='USER_NAME' type='VARCHAR' size="80"/>
+		<column name='ACTIVITY' type='VARCHAR' size="40"/>
+		<column name='CATEGORY' type='VARCHAR' size='40'/>
 		<column name='ADMIN' type='VARCHAR' size="80"/>
+		<column name='USER_NAME' type='VARCHAR' size="80"/>
 		<column name='TIME_STAMP' type='TIMESTAMP'/>
 		<column name='IPADDRESS' type='VARCHAR' size="80"/>
-		<column name='ACTIVITY' type='VARCHAR' size="40"/>
+		<column name='ATTR_NAME' type='VARCHAR' size='40'/>
+		<column name='ATTR_VALUE' type='VARCHAR' size='80'/>
 		<column name='DESCRIPTION' type='VARCHAR' size="128"/>			    
 	</table>
 
 	<table name='USER_ACTIVITY'>
-		<column name='USER_NAME' type='VARCHAR' size="80"/>
+		<column name='ACTIVITY' type='VARCHAR' size="40"/>
+		<column name='CATEGORY' type='VARCHAR' size='40'/>	
+		<column name='USER_NAME' type='VARCHAR' size="80"/>		
 		<column name='TIME_STAMP' type='TIMESTAMP'/>
 		<column name='IPADDRESS' type='VARCHAR' size="80"/>
-		<column name='ACTIVITY' type='VARCHAR' size="40"/>
 		<column name='DESCRIPTION' type='VARCHAR' size="128"/>			    
 	</table>
 	

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java?view=diff&rev=553804&r1=553803&r2=553804
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java Fri Jul  6 02:15:49 2007
@@ -53,4 +53,5 @@
     public final static String CPS_IMPORTER_MANAGER = "cps:ImporterManager";
     public final static String CPS_DECORATOR_CACHE = "cps:decorationContentCache";
     public final static String CPS_PORTLET_CACHE = "cps:portletContentCache";
+    public final static String CPS_AUDIT_ACTIVITY = "cps:AuditActivity";
 }

Added: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/audit/AuditActivity.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/audit/AuditActivity.java?view=auto&rev=553804
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/audit/AuditActivity.java (added)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/audit/AuditActivity.java Fri Jul  6 02:15:49 2007
@@ -0,0 +1,132 @@
+/* 
+ * 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.jetspeed.audit;
+
+import javax.sql.DataSource;
+
+/**
+ * Gathers information about security auditing activity
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id: $
+ */
+public interface AuditActivity
+{
+    // user activities
+    public static final String AUTHENTICATION_SUCCESS = "login-success";
+    public static final String AUTHENTICATION_FAILURE = "login-failure";
+    public static final String PASSWORD_CHANGE_SUCCESS = "password-success";
+    public static final String PASSWORD_CHANGE_FAILURE = "password-failure";
+    
+    // admin activities
+    public static final String USER_CREATE = "user-create";
+    public static final String USER_UPDATE = "user-update";
+    public static final String USER_DELETE = "user-delete";
+    public static final String USER_DISABLE = "user-disable";
+    public static final String USER_EXTEND = "user-extend";    
+    public static final String USER_EXTEND_UNLIMITED = "user-extend-unlimited";    
+
+    public static final String PASSWORD_EXPIRE = "password-expire";
+    public static final String PASSWORD_RESET = "password-reset";
+    public static final String PASSWORD_ACTIVATE  = "password-activate";
+    public static final String PASSWORD_ENABLED  = "password-enabled";
+    public static final String PASSWORD_DISABLED  = "password-disabled";        
+    public static final String PASSWORD_UPDATE_REQUIRED = "password-update-req";
+    public static final String PASSWORD_EXTEND = "password-extend";
+    public static final String PASSWORD_UNLIMITED = "password-unlimited";
+    
+    public static final String USER_ADD_ROLE = "user-add-role";
+    public static final String USER_DELETE_ROLE = "user-delete-role";
+    public static final String USER_ADD_GROUP = "user-add-group";
+    public static final String USER_DELETE_GROUP = "user-delete-group";
+    public static final String USER_ADD_PROFILE = "user-add-profile";
+    public static final String USER_DELETE_PROFILE = "user-delete-profile";
+
+    public static final String USER_ADD_ATTRIBUTE = "user-add-attr";
+    public static final String USER_DELETE_ATTRIBUTE = "user-delete-attr";
+    public static final String USER_UPDATE_ATTRIBUTE = "user-update-attr";
+    
+    // General Categories
+    public static final String CAT_USER_AUTHENTICATION = "authentication";
+    public static final String CAT_ADMIN_USER_MAINTENANCE = "user";
+    public static final String CAT_ADMIN_CREDENTIAL_MAINTENANCE = "credential";
+    public static final String CAT_ADMIN_ATTRIBUTE_MAINTENANCE = "attribute";
+    
+    /**
+     * Enable or disable the service at runtime
+     * 
+     * @param enabled
+     */
+    public void setEnabled(boolean enabled);
+    
+    /**
+     * Get the enabled state of this service
+     * @return
+     */
+    public boolean getEnabled();
+    
+    /**
+     * Log user security-audit-related activity
+     * 
+     * @param username
+     * @param ipaddress
+     * @param activity
+     * @param description
+     */
+    public void logUserActivity(String username, String ipaddress, String activity, String description);
+
+    /**
+     * Log auditable activity by an administrator on behalf of another user
+     * 
+     * @param username
+     * @param ipaddress
+     * @param targetUser
+     * @param activity
+     * @param description
+     */
+    public void logAdminUserActivity(String username, String ipaddress, String targetUser, String activity, String description);
+
+    /**
+     * Log auditable activity by an administrator on credentials on behalf of a user
+     * 
+     * @param adminName
+     * @param ipaddress
+     * @param targetUser
+     * @param activity
+     * @param description
+     */
+    public void logAdminCredentialActivity(String username, String ipaddress, String targetUser, String activity, String description);
+    
+    /**
+     * Log auditable activity by an administrator on attirbutes on behalf of a user
+     * 
+     * @param username
+     * @param ipaddress
+     * @param targetUser
+     * @param activity
+     * @param name
+     * @param value
+     * @param description
+     */
+    public void logAdminAttributeActivity(String username, String ipaddress, String targetUser, String activity, String name, String value, String description);
+    
+    /**
+     * @return DataSource in use by the logger useful for writing decent tests
+     */
+    public DataSource getDataSource();
+    
+} 
\ No newline at end of file

Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml?view=diff&rev=553804&r1=553803&r2=553804
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/jetspeed-services.xml Fri Jul  6 02:15:49 2007
@@ -123,6 +123,9 @@
           <entry key="portletContentCache">
           	<ref bean="portletContentCache"/>
           </entry>          
+          <entry key="AuditActivity">
+          	<ref bean="org.apache.jetspeed.audit.AuditActivity"/>
+          </entry>          
 <!-- first uncomment the below service bean in security-spi-atn.xml
          <entry key="PasswordEncodingService">
            <ref bean="org.apache.jetspeed.security.PasswordEncodingService" />

Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/statistics.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/statistics.xml?view=diff&rev=553804&r1=553803&r2=553804
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/statistics.xml (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/statistics.xml Fri Jul  6 02:15:49 2007
@@ -49,5 +49,14 @@
 		
 		<!-- jetspeedDSEntry -->
       	<constructor-arg  index='8' ><ref bean="JetspeedDS" /></constructor-arg>
-	</bean>
+	</bean>
+	
+    <!-- Audit Activity Implementation -->
+    <bean id="org.apache.jetspeed.audit.AuditActivity" 
+          class="org.apache.jetspeed.audit.impl.AuditActivityImpl"
+          >
+      	<constructor-arg  index='0' ><ref bean="JetspeedDS" /></constructor-arg>
+		<property name="enabled"><value type='boolean'>true</value></property>          
+	</bean>
+		
 </beans>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message