From 9875b41e5a1163b5abc3690c9086723a3eb6e33d Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Wed, 9 Dec 2009 11:03:55 +0000 Subject: [PATCH] [MRM-1296] audit logging report o added action class & jsp file for audit log report o implement security restriction git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1296@888768 13f79535-47bb-0310-9956-ffa450edef68 --- .../security/ArchivaRoleConstants.java | 2 + .../resources/META-INF/redback/redback.xml | 11 ++ .../reports/ViewAuditLogReportAction.java | 159 ++++++++++++++++++ .../src/main/resources/struts.xml | 10 ++ .../webapp/WEB-INF/jsp/decorators/default.jsp | 9 +- .../WEB-INF/jsp/reports/auditLogReport.jsp | 88 ++++++++++ 6 files changed, 277 insertions(+), 2 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java index 7c6f7b76d..396f9250a 100644 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java @@ -65,6 +65,8 @@ public class ArchivaRoleConstants public static final String OPERATION_REPOSITORY_UPLOAD = "archiva-upload-repository"; public static final String OPERATION_REPOSITORY_DELETE = "archiva-delete-artifact"; + + public static final String OPERATION_VIEW_AUDIT_LOG = "archiva-view-audit-logs"; // Role templates public static final String TEMPLATE_REPOSITORY_MANAGER = "archiva-repository-manager"; diff --git a/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml b/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml index 235537e05..55b30e09e 100644 --- a/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml +++ b/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/redback/redback.xml @@ -65,6 +65,11 @@ archiva-access-repository Access Archiva Repository + + archiva-view-audit-logs + archiva-view-audit-logs + View Archiva Audit Logs + archiva-guest archiva-guest @@ -219,6 +224,12 @@ archiva-upload-repository ${resource} + + archiva-view-audit-logs + Archiva View Audit Logs + archiva-view-audit-logs + ${resource} + archiva-repository-observer diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java new file mode 100644 index 000000000..8aae78e7b --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java @@ -0,0 +1,159 @@ +package org.apache.maven.archiva.web.action.reports; + +/* + * 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. + */ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.maven.archiva.security.AccessDeniedException; +import org.apache.maven.archiva.security.ArchivaSecurityException; +import org.apache.maven.archiva.security.PrincipalNotFoundException; +import org.apache.maven.archiva.security.UserRepositories; +import org.apache.maven.archiva.web.action.PlexusActionSupport; +import org.apache.struts2.interceptor.ServletRequestAware; +import org.codehaus.redback.integration.interceptor.SecureAction; +import org.codehaus.redback.integration.interceptor.SecureActionBundle; +import org.codehaus.redback.integration.interceptor.SecureActionException; + +import com.opensymphony.xwork2.Preparable; + +/** + * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="viewAuditLogReport" instantiation-strategy="per-lookup" + */ +public class ViewAuditLogReportAction + extends PlexusActionSupport + implements SecureAction, ServletRequestAware, Preparable +{ + protected HttpServletRequest request; + + /** + * @plexus.requirement + */ + private UserRepositories userRepositories; + + private String repository; + + private List repositories; + + private String groupId; + + private String artifactId; + + private int rowCount = 30; + + public int getRowCount() + { + return rowCount; + } + + public void setRowCount( int rowCount ) + { + this.rowCount = rowCount; + } + + public SecureActionBundle getSecureActionBundle() + throws SecureActionException + { + return null; + } + + public void setServletRequest( HttpServletRequest request ) + { + this.request = request; + } + + public void prepare() + throws Exception + { + repositories = getObservableRepositories(); + + + } + + public String execute() + throws Exception + { + return SUCCESS; + } + + private List getObservableRepositories() + { + try + { + return userRepositories.getObservableRepositoryIds( getPrincipal() ); + } + catch ( PrincipalNotFoundException e ) + { + log.warn( e.getMessage(), e ); + } + catch ( AccessDeniedException e ) + { + log.warn( e.getMessage(), e ); + } + catch ( ArchivaSecurityException e ) + { + log.warn( e.getMessage(), e ); + } + return Collections.emptyList(); + } + + public String getRepository() + { + return repository; + } + + public void setRepository( String repository ) + { + this.repository = repository; + } + + public List getRepositories() + { + return repositories; + } + + public void setRepositories( List repositories ) + { + this.repositories = repositories; + } + + public String getGroupId() + { + return groupId; + } + + public void setGroupId( String groupId ) + { + this.groupId = groupId; + } + + public String getArtifactId() + { + return artifactId; + } + + public void setArtifactId( String artifactId ) + { + this.artifactId = artifactId; + } +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml index 8df1acfdd..138843335 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml @@ -523,6 +523,16 @@ + + + /WEB-INF/jsp/reports/auditLogReport.jsp + + + + /WEB-INF/jsp/reports/auditLogReport.jsp + /WEB-INF/jsp/reports/auditLogReport.jsp + + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp index 52ec32bbe..5e5dffa13 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp @@ -80,7 +80,7 @@ - +
Manage
    @@ -88,6 +88,11 @@ Reports + +
  • + Audit Log Reports +
  • +
  • User Management @@ -112,7 +117,7 @@
  • Delete Artifact
  • -
    + <%-- TODO: future options here. * Repository Statistics. * Web Services Statistics. diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp new file mode 100644 index 000000000..bf4629712 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp @@ -0,0 +1,88 @@ +<%-- + ~ 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. + --%> + +<%@ taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + Audit Log Report + + + + + + + + + +

    Audit Log Report

    + +
    + + + +
    + + + + + + + + <%-- + + --%> + + + <%-- + + --%> + + + + +
    +
    + +
    + + + -- 2.39.5