From c7e5fea75ad6eb4c122584a5e48efc3dbd9a8417 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 3 Sep 2011 08:15:36 +0000 Subject: get RID of org.apache.maven.archiva packages : security package git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1164822 13f79535-47bb-0310-9956-ffa450edef68 --- .../managed/DefaultManagedRepositoryAdmin.java | 2 +- .../managed/ManagedRepositoryAdminTest.java | 2 +- .../api/services/ManagedRepositoriesService.java | 3 +- .../rest/api/services/RepositoriesService.java | 6 +- .../archiva/security/AccessDeniedException.java | 39 +++ .../archiva/security/ArchivaRoleConstants.java | 86 +++++++ .../archiva/security/ArchivaSecurityException.java | 41 ++++ .../security/ArchivaServletAuthenticator.java | 131 +++++++++++ .../security/ArchivaStandardRolesCheck.java | 109 +++++++++ .../apache/archiva/security/ArchivaXworkUser.java | 64 +++++ .../archiva/security/DefaultUserRepositories.java | 233 ++++++++++++++++++ .../security/PrincipalNotFoundException.java | 39 +++ .../archiva/security/ServletAuthenticator.java | 79 +++++++ .../apache/archiva/security/UserRepositories.java | 88 +++++++ .../archiva/security/AccessDeniedException.java | 39 --- .../archiva/security/ArchivaRoleConstants.java | 86 ------- .../archiva/security/ArchivaSecurityException.java | 41 ---- .../security/ArchivaServletAuthenticator.java | 131 ----------- .../security/ArchivaStandardRolesCheck.java | 109 --------- .../maven/archiva/security/ArchivaXworkUser.java | 64 ----- .../archiva/security/DefaultUserRepositories.java | 233 ------------------ .../security/PrincipalNotFoundException.java | 39 --- .../archiva/security/ServletAuthenticator.java | 79 ------- .../maven/archiva/security/UserRepositories.java | 88 ------- .../src/main/resources/META-INF/spring-context.xml | 2 +- .../archiva/security/AbstractSecurityTest.java | 166 +++++++++++++ .../security/ArchivaServletAuthenticatorTest.java | 258 ++++++++++++++++++++ .../security/DefaultUserRepositoriesTest.java | 107 +++++++++ .../apache/archiva/security/RoleManagerTest.java | 57 +++++ .../archiva/security/AbstractSecurityTest.java | 166 ------------- .../security/ArchivaServletAuthenticatorTest.java | 262 --------------------- .../security/DefaultUserRepositoriesTest.java | 107 --------- .../maven/archiva/security/RoleManagerTest.java | 57 ----- .../src/test/resources/spring-context.xml | 4 +- .../org/apache/archiva/web/rss/RssFeedServlet.java | 12 +- .../web/startup/SecuritySynchronization.java | 2 +- .../apache/archiva/web/tags/DependencyTree.java | 4 +- .../archiva/web/action/AbstractActionSupport.java | 2 +- .../web/action/AbstractRepositoryBasedAction.java | 8 +- .../archiva/web/action/DeleteArtifactAction.java | 9 +- .../maven/archiva/web/action/UploadAction.java | 8 +- .../archiva/web/action/admin/SchedulerAction.java | 2 +- .../web/action/admin/SystemStatusAction.java | 2 +- .../appearance/EditOrganisationInfoAction.java | 2 +- .../proxy/AbstractProxyConnectorAction.java | 2 +- .../admin/legacy/LegacyArtifactPathAction.java | 2 +- .../ConfigureNetworkProxyAction.java | 2 +- .../admin/networkproxies/NetworkProxiesAction.java | 2 +- .../AbstractRepositoriesAdminAction.java | 7 +- .../admin/repositories/RepositoriesAction.java | 2 +- .../admin/scanning/RepositoryScanningAction.java | 2 +- .../web/action/reports/GenerateReportAction.java | 2 +- .../action/reports/ViewAuditLogReportAction.java | 8 +- .../archiva/security/UserRepositoriesStub.java | 77 ++++++ .../archiva/security/UserRepositoriesStub.java | 77 ------ .../archiva/web/action/AbstractActionTestCase.java | 3 +- .../maven/archiva/web/action/SearchActionTest.java | 2 +- .../AddManagedRepositoryActionTest.java | 2 +- .../DeleteManagedRepositoryActionTest.java | 5 +- .../EditManagedRepositoryActionTest.java | 2 +- .../action/reports/GenerateReportActionTest.java | 2 +- .../test/resources/spring-context-rss-servlet.xml | 2 +- .../src/test/resources/spring-context.xml | 2 +- .../archiva/webdav/ArchivaDavResourceFactory.java | 2 +- .../archiva/webdav/ArchivaDavSessionProvider.java | 2 +- .../maven/archiva/webdav/RepositoryServlet.java | 2 +- .../archiva/webdav/util/WebdavMethodUtil.java | 2 +- .../webdav/ArchivaDavSessionProviderTest.java | 2 +- .../archiva/webdav/MockServletAuthenticator.java | 2 +- .../webdav/RepositoryServletSecurityTest.java | 4 +- .../web/xmlrpc/security/XmlRpcAuthenticator.java | 6 +- .../xmlrpc/security/XmlRpcUserRepositories.java | 6 +- .../xmlrpc/security/XmlRpcAuthenticatorTest.java | 2 +- .../services/AdministrationServiceImplTest.java | 2 +- 74 files changed, 1642 insertions(+), 1661 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/AccessDeniedException.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaRoleConstants.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaSecurityException.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaServletAuthenticator.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaStandardRolesCheck.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaXworkUser.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/DefaultUserRepositories.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/PrincipalNotFoundException.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ServletAuthenticator.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/UserRepositories.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/AccessDeniedException.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaSecurityException.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaStandardRolesCheck.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/PrincipalNotFoundException.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/UserRepositories.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/AbstractSecurityTest.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/ArchivaServletAuthenticatorTest.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/DefaultUserRepositoriesTest.java create mode 100644 archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/RoleManagerTest.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/AbstractSecurityTest.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java delete mode 100644 archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/RoleManagerTest.java create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/security/UserRepositoriesStub.java delete mode 100644 archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/security/UserRepositoriesStub.java diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java index 6adab675e..2ddcdb860 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java @@ -37,7 +37,7 @@ import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.plexus.redback.role.RoleManagerException; import org.codehaus.plexus.redback.users.User; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java index 534f17117..ef1f73066 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java @@ -23,7 +23,7 @@ import org.apache.archiva.admin.mock.MockAuditListener; import org.apache.archiva.audit.AuditEvent; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.plexus.redback.users.User; import org.codehaus.plexus.redback.users.memory.SimpleUser; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java index cb592a2a9..f530bbf5a 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java @@ -21,8 +21,7 @@ package org.apache.archiva.rest.api.services; import org.apache.archiva.admin.repository.RepositoryAdminException; import org.apache.archiva.rest.api.model.ManagedRepository; -import org.apache.archiva.rest.api.model.RemoteRepository; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.codehaus.plexus.redback.authorization.RedbackAuthorization; import javax.ws.rs.Consumes; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java index e2ce30181..1324388b6 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java @@ -19,15 +19,11 @@ package org.apache.archiva.rest.api.services; * under the License. */ -import org.apache.archiva.admin.repository.RepositoryAdminException; -import org.apache.archiva.rest.api.model.ManagedRepository; import org.apache.archiva.rest.api.model.RemoteRepository; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.codehaus.plexus.redback.authorization.RedbackAuthorization; -import javax.ws.rs.Consumes; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/AccessDeniedException.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/AccessDeniedException.java new file mode 100644 index 000000000..fe57169cf --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/AccessDeniedException.java @@ -0,0 +1,39 @@ +package org.apache.archiva.security; + +/* + * 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. + */ + +/** + * AccessDeniedException + * + * @version $Id$ + */ +public class AccessDeniedException + extends ArchivaSecurityException +{ + public AccessDeniedException( String message, Throwable cause ) + { + super( message, cause ); + } + + public AccessDeniedException( String message ) + { + super( message ); + } +} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaRoleConstants.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaRoleConstants.java new file mode 100644 index 000000000..1f8ca53b4 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaRoleConstants.java @@ -0,0 +1,86 @@ +package org.apache.archiva.security; + +/* + * 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. + */ + +public class ArchivaRoleConstants +{ + public static final String DELIMITER = " - "; + + // globalish roles + public static final String SYSTEM_ADMINISTRATOR_ROLE = "System Administrator"; + + public static final String USER_ADMINISTRATOR_ROLE = "User Administrator"; + + public static final String GLOBAL_REPOSITORY_MANAGER_ROLE = "Global Repository Manager"; + + public static final String GLOBAL_REPOSITORY_OBSERVER_ROLE = "Global Repository Observer"; + + public static final String REGISTERED_USER_ROLE = "Registered User"; + + public static final String GUEST_ROLE = "Guest"; + + // dynamic role prefixes + public static final String REPOSITORY_MANAGER_ROLE_PREFIX = "Repository Manager"; + + public static final String REPOSITORY_OBSERVER_ROLE_PREFIX = "Repository Observer"; + + // operations + public static final String OPERATION_MANAGE_USERS = "archiva-manage-users"; + + public static final String OPERATION_MANAGE_CONFIGURATION = "archiva-manage-configuration"; + + public static final String OPERATION_ACTIVE_GUEST = "archiva-guest"; + + public static final String OPERATION_RUN_INDEXER = "archiva-run-indexer"; + + public static final String OPERATION_REGENERATE_INDEX = "archiva-regenerate-index"; + + public static final String OPERATION_ACCESS_REPORT = "archiva-access-reports"; + + public static final String OPERATION_ADD_REPOSITORY = "archiva-add-repository"; + + public static final String OPERATION_REPOSITORY_ACCESS = "archiva-read-repository"; + + public static final String OPERATION_DELETE_REPOSITORY = "archiva-delete-repository"; + + public static final String OPERATION_EDIT_REPOSITORY = "archiva-edit-repository"; + + 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"; + + public static final String TEMPLATE_REPOSITORY_OBSERVER = "archiva-repository-observer"; + + public static final String TEMPLATE_GLOBAL_REPOSITORY_OBSERVER = "archiva-global-repository-observer"; + + public static final String TEMPLATE_SYSTEM_ADMIN = "archiva-system-administrator"; + + public static final String TEMPLATE_GUEST = "archiva-guest"; + + public static String toRepositoryObserverRoleName( String repoId ) + { + return REPOSITORY_OBSERVER_ROLE_PREFIX + " - " + repoId; + } +} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaSecurityException.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaSecurityException.java new file mode 100644 index 000000000..07a4355db --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaSecurityException.java @@ -0,0 +1,41 @@ +package org.apache.archiva.security; + +/* + * 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 org.apache.maven.archiva.common.ArchivaException; + +/** + * ArchivaSecurityException + * + * @version $Id$ + */ +public class ArchivaSecurityException + extends ArchivaException +{ + public ArchivaSecurityException( String message, Throwable cause ) + { + super( message, cause ); + } + + public ArchivaSecurityException( String message ) + { + super( message ); + } +} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaServletAuthenticator.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaServletAuthenticator.java new file mode 100644 index 000000000..8d00acb7e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaServletAuthenticator.java @@ -0,0 +1,131 @@ +package org.apache.archiva.security; + +/* + * 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 javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; + +import org.codehaus.plexus.redback.authentication.AuthenticationException; +import org.codehaus.plexus.redback.authentication.AuthenticationResult; +import org.codehaus.plexus.redback.authorization.AuthorizationException; +import org.codehaus.plexus.redback.authorization.AuthorizationResult; +import org.codehaus.plexus.redback.authorization.UnauthorizedException; +import org.codehaus.plexus.redback.policy.AccountLockedException; +import org.codehaus.plexus.redback.policy.MustChangePasswordException; +import org.codehaus.plexus.redback.system.DefaultSecuritySession; +import org.codehaus.plexus.redback.system.SecuritySession; +import org.codehaus.plexus.redback.system.SecuritySystem; +import org.codehaus.plexus.redback.users.User; +import org.codehaus.plexus.redback.users.UserNotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +/** + * @version + * plexus.component role="org.apache.archiva.security.ServletAuthenticator" role-hint="default" + */ +@Service("servletAuthenticator") +public class ArchivaServletAuthenticator + implements ServletAuthenticator +{ + private Logger log = LoggerFactory.getLogger( ArchivaServletAuthenticator.class ); + + /** + * plexus.requirement + */ + @Inject + private SecuritySystem securitySystem; + + public boolean isAuthenticated( HttpServletRequest request, AuthenticationResult result ) + throws AuthenticationException, AccountLockedException, MustChangePasswordException + { + if ( result != null && !result.isAuthenticated() ) + { + throw new AuthenticationException( "User Credentials Invalid" ); + } + + return true; + } + + public boolean isAuthorized( HttpServletRequest request, SecuritySession securitySession, String repositoryId, + String permission ) + throws AuthorizationException, UnauthorizedException + { + // TODO: also check for permission to proxy the resource when MRM-579 is implemented + + AuthorizationResult authzResult = securitySystem.authorize( securitySession, permission, repositoryId ); + + if ( !authzResult.isAuthorized() ) + { + if ( authzResult.getException() != null ) + { + log.info( "Authorization Denied [ip=" + request.getRemoteAddr() + ",permission=" + permission + + ",repo=" + repositoryId + "] : " + authzResult.getException().getMessage() ); + + throw new UnauthorizedException( "Access denied for repository " + repositoryId ); + } + throw new UnauthorizedException( "User account is locked" ); + } + + return true; + } + + public boolean isAuthorized( String principal, String repoId, String permission ) + throws UnauthorizedException + { + try + { + User user = securitySystem.getUserManager().findUser( principal ); + if ( user == null ) + { + throw new UnauthorizedException( "The security system had an internal error - please check your system logs" ); + } + if ( user.isLocked() ) + { + throw new UnauthorizedException( "User account is locked." ); + } + + AuthenticationResult authn = new AuthenticationResult( true, principal, null ); + SecuritySession securitySession = new DefaultSecuritySession( authn, user ); + + return securitySystem.isAuthorized( securitySession, permission, repoId ); + } + catch ( UserNotFoundException e ) + { + throw new UnauthorizedException( e.getMessage() ); + } + catch ( AuthorizationException e ) + { + throw new UnauthorizedException( e.getMessage() ); + } + } + + + public SecuritySystem getSecuritySystem() + { + return securitySystem; + } + + public void setSecuritySystem( SecuritySystem securitySystem ) + { + this.securitySystem = securitySystem; + } +} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaStandardRolesCheck.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaStandardRolesCheck.java new file mode 100644 index 000000000..15b3e9120 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaStandardRolesCheck.java @@ -0,0 +1,109 @@ +package org.apache.archiva.security; + +/* + * 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.List; + +import org.codehaus.plexus.redback.rbac.RBACManager; +import org.codehaus.plexus.redback.system.check.EnvironmentCheck; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.inject.Inject; +import javax.inject.Named; + +/** + * ArchivaStandardRolesCheck tests for the existance of expected / standard roles and permissions. + * + * @version $Id$ + * + * plexus.component role="org.codehaus.plexus.redback.system.check.EnvironmentCheck" + * role-hint="required-roles" + */ +@Service("environmentCheck#archiva-required-roles") +public class ArchivaStandardRolesCheck + implements EnvironmentCheck +{ + private Logger log = LoggerFactory.getLogger( ArchivaStandardRolesCheck.class ); + + /** + * plexus.requirement role-hint="cached" + */ + @Inject @Named(value = "rBACManager#cached") + private RBACManager rbacManager; + + /** + * boolean detailing if this environment check has been executed + */ + private boolean checked = false; + + public void validateEnvironment( List violations ) + { + if ( !checked ) + { + String expectedRoles[] = new String[] { + ArchivaRoleConstants.SYSTEM_ADMINISTRATOR_ROLE, + ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE, + ArchivaRoleConstants.GLOBAL_REPOSITORY_OBSERVER_ROLE, + ArchivaRoleConstants.GUEST_ROLE, + ArchivaRoleConstants.REGISTERED_USER_ROLE, + ArchivaRoleConstants.USER_ADMINISTRATOR_ROLE }; + + log.info( "Checking the existance of required roles." ); + + for ( String roleName : expectedRoles ) + { + if ( !rbacManager.roleExists( roleName ) ) + { + violations.add( "Unable to validate the existances of the '" + roleName + "' role." ); + } + } + + String expectedOperations[] = new String[] { + ArchivaRoleConstants.OPERATION_MANAGE_USERS, + ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, + ArchivaRoleConstants.OPERATION_REGENERATE_INDEX, + ArchivaRoleConstants.OPERATION_RUN_INDEXER, + ArchivaRoleConstants.OPERATION_ACCESS_REPORT, + ArchivaRoleConstants.OPERATION_ADD_REPOSITORY, + ArchivaRoleConstants.OPERATION_DELETE_REPOSITORY, + ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS, + ArchivaRoleConstants.OPERATION_EDIT_REPOSITORY, + ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD, + ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS, + "archiva-guest" }; + + log.info( "Checking the existance of required operations." ); + + for ( String operation : expectedOperations ) + { + if ( !rbacManager.operationExists( operation ) ) + { + violations.add( "Unable to validate the existances of the '" + operation + "' operation." ); + } + } + + checked = true; + } + + } + +} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaXworkUser.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaXworkUser.java new file mode 100644 index 000000000..65726bc58 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ArchivaXworkUser.java @@ -0,0 +1,64 @@ +package org.apache.archiva.security; + +/* + * 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.Map; + +import org.codehaus.plexus.redback.system.SecuritySession; +import org.codehaus.plexus.redback.system.SecuritySystemConstants; +import org.codehaus.plexus.redback.users.User; +import org.codehaus.plexus.redback.users.UserManager; + +/** + * ArchivaXworkUser + * + * @version $Id$ + */ +public final class ArchivaXworkUser +{ + private ArchivaXworkUser() + { + // no touchy + } + + public static String getActivePrincipal( Map sessionMap ) + { + if ( sessionMap == null ) + { + return UserManager.GUEST_USERNAME; + } + + SecuritySession securitySession = + (SecuritySession) sessionMap.get( SecuritySystemConstants.SECURITY_SESSION_KEY ); + + if ( securitySession == null ) + { + return UserManager.GUEST_USERNAME; + } + + User user = securitySession.getUser(); + if ( user == null ) + { + return UserManager.GUEST_USERNAME; + } + + return (String) user.getPrincipal(); + } +} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/DefaultUserRepositories.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/DefaultUserRepositories.java new file mode 100644 index 000000000..983670f84 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/DefaultUserRepositories.java @@ -0,0 +1,233 @@ +package org.apache.archiva.security; + +/* + * 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 com.google.common.collect.Lists; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.codehaus.plexus.redback.authentication.AuthenticationResult; +import org.codehaus.plexus.redback.authorization.AuthorizationException; +import org.codehaus.plexus.redback.role.RoleManager; +import org.codehaus.plexus.redback.role.RoleManagerException; +import org.codehaus.plexus.redback.system.DefaultSecuritySession; +import org.codehaus.plexus.redback.system.SecuritySession; +import org.codehaus.plexus.redback.system.SecuritySystem; +import org.codehaus.plexus.redback.users.User; +import org.codehaus.plexus.redback.users.UserNotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.inject.Inject; +import java.util.ArrayList; +import java.util.List; + +/** + * DefaultUserRepositories + * + * @version $Id$ + * plexus.component role="org.apache.archiva.security.UserRepositories" role-hint="default" + */ +@Service( "userRepositories" ) +public class DefaultUserRepositories + implements UserRepositories +{ + /** + * plexus.requirement + */ + @Inject + private SecuritySystem securitySystem; + + /** + * plexus.requirement role-hint="default" + */ + @Inject + private RoleManager roleManager; + + /** + * plexus.requirement + */ + @Inject + private ArchivaConfiguration archivaConfiguration; + + private Logger log = LoggerFactory.getLogger( DefaultUserRepositories.class ); + + public List getObservableRepositoryIds( String principal ) + throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException + { + String operation = ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS; + + return getAccessibleRepositoryIds( principal, operation ); + } + + public List getManagableRepositoryIds( String principal ) + throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException + { + String operation = ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD; + + return getAccessibleRepositoryIds( principal, operation ); + } + + private List getAccessibleRepositoryIds( String principal, String operation ) + throws ArchivaSecurityException, AccessDeniedException, PrincipalNotFoundException + { + SecuritySession securitySession = createSession( principal ); + + List repoIds = new ArrayList(); + + List repos = archivaConfiguration.getConfiguration().getManagedRepositories(); + + for ( ManagedRepositoryConfiguration repo : repos ) + { + try + { + String repoId = repo.getId(); + if ( securitySystem.isAuthorized( securitySession, operation, repoId ) ) + { + repoIds.add( repoId ); + } + } + catch ( AuthorizationException e ) + { + // swallow. + if ( log.isDebugEnabled() ) + { + log.debug( "Not authorizing '{}' for repository '{}': {}", + Lists.newArrayList( principal, repo.getId(), e.getMessage() ) ); + } + } + } + + return repoIds; + } + + private SecuritySession createSession( String principal ) + throws ArchivaSecurityException, AccessDeniedException + { + User user; + try + { + user = securitySystem.getUserManager().findUser( principal ); + if ( user == null ) + { + throw new ArchivaSecurityException( + "The security system had an internal error - please check your system logs" ); + } + } + catch ( UserNotFoundException e ) + { + throw new PrincipalNotFoundException( "Unable to find principal " + principal + "" ); + } + + if ( user.isLocked() ) + { + throw new AccessDeniedException( "User " + principal + "(" + user.getFullName() + ") is locked." ); + } + + AuthenticationResult authn = new AuthenticationResult( true, principal, null ); + return new DefaultSecuritySession( authn, user ); + } + + public void createMissingRepositoryRoles( String repoId ) + throws ArchivaSecurityException + { + try + { + if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) ) + { + roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ); + } + + if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) ) + { + roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ); + } + } + catch ( RoleManagerException e ) + { + throw new ArchivaSecurityException( "Unable to create roles for configured repositories: " + e.getMessage(), + e ); + } + } + + public boolean isAuthorizedToUploadArtifacts( String principal, String repoId ) + throws PrincipalNotFoundException, ArchivaSecurityException + { + try + { + SecuritySession securitySession = createSession( principal ); + + return securitySystem.isAuthorized( securitySession, ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD, + repoId ); + + } + catch ( AuthorizationException e ) + { + throw new ArchivaSecurityException( e.getMessage() ); + } + } + + public boolean isAuthorizedToDeleteArtifacts( String principal, String repoId ) + throws AccessDeniedException, ArchivaSecurityException + { + try + { + SecuritySession securitySession = createSession( principal ); + + return securitySystem.isAuthorized( securitySession, ArchivaRoleConstants.OPERATION_REPOSITORY_DELETE, + repoId ); + + } + catch ( AuthorizationException e ) + { + throw new ArchivaSecurityException( e.getMessage() ); + } + } + + public SecuritySystem getSecuritySystem() + { + return securitySystem; + } + + public void setSecuritySystem( SecuritySystem securitySystem ) + { + this.securitySystem = securitySystem; + } + + public RoleManager getRoleManager() + { + return roleManager; + } + + public void setRoleManager( RoleManager roleManager ) + { + this.roleManager = roleManager; + } + + public ArchivaConfiguration getArchivaConfiguration() + { + return archivaConfiguration; + } + + public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration ) + { + this.archivaConfiguration = archivaConfiguration; + } +} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/PrincipalNotFoundException.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/PrincipalNotFoundException.java new file mode 100644 index 000000000..bc5ea07a7 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/PrincipalNotFoundException.java @@ -0,0 +1,39 @@ +package org.apache.archiva.security; + +/* + * 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. + */ + +/** + * PrincipalNotFoundException + * + * @version $Id$ + */ +public class PrincipalNotFoundException + extends ArchivaSecurityException +{ + public PrincipalNotFoundException( String message, Throwable cause ) + { + super( message, cause ); + } + + public PrincipalNotFoundException( String message ) + { + super( message ); + } +} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ServletAuthenticator.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ServletAuthenticator.java new file mode 100644 index 000000000..58c4171c8 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/ServletAuthenticator.java @@ -0,0 +1,79 @@ +package org.apache.archiva.security; + +/* + * 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 javax.servlet.http.HttpServletRequest; + +import org.codehaus.plexus.redback.authentication.AuthenticationException; +import org.codehaus.plexus.redback.authentication.AuthenticationResult; +import org.codehaus.plexus.redback.authorization.AuthorizationException; +import org.codehaus.plexus.redback.authorization.UnauthorizedException; +import org.codehaus.plexus.redback.policy.AccountLockedException; +import org.codehaus.plexus.redback.policy.MustChangePasswordException; +import org.codehaus.plexus.redback.system.SecuritySession; + +/** + * @version + */ +public interface ServletAuthenticator +{ + /** + * Authentication check for users. + * + * @param request + * @param result + * @return + * @throws AuthenticationException + * @throws AccountLockedException + * @throws MustChangePasswordException + */ + boolean isAuthenticated( HttpServletRequest request, AuthenticationResult result ) + throws AuthenticationException, AccountLockedException, MustChangePasswordException; + + /** + * Authorization check for valid users. + * + * @param request + * @param securitySession + * @param repositoryId + * @param isWriteRequest + * @return + * @throws AuthorizationException + * @throws UnauthorizedException + */ + boolean isAuthorized( HttpServletRequest request, SecuritySession securitySession, String repositoryId, + String permission ) throws AuthorizationException, UnauthorizedException; + + /** + * Authorization check specific for user guest, which doesn't go through + * HttpBasicAuthentication#getAuthenticationResult( HttpServletRequest request, HttpServletResponse response ) + * since no credentials are attached to the request. + * + * See also MRM-911 + * + * @param principal + * @param repoId + * @param isWriteRequest + * @return + * @throws UnauthorizedException + */ + boolean isAuthorized( String principal, String repoId, String permission ) + throws UnauthorizedException; +} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/UserRepositories.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/UserRepositories.java new file mode 100644 index 000000000..0535303f1 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/archiva/security/UserRepositories.java @@ -0,0 +1,88 @@ +package org.apache.archiva.security; + +/* + * 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.List; + +/** + * UserRepositories + * + * @version $Id$ + */ +public interface UserRepositories +{ + /** + * Get the list of observable repository ids for the user specified. + * + * @param principal the principle to obtain the observable repository ids from. + * @return the list of observable repository ids. + * @throws PrincipalNotFoundException + * @throws AccessDeniedException + * @throws ArchivaSecurityException + */ + List getObservableRepositoryIds( String principal ) + throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException; + + /** + * Get the list of writable repository ids for the user specified. + * + * @param principal the principle to obtain the observable repository ids from. + * @return the list of observable repository ids. + * @throws PrincipalNotFoundException + * @throws AccessDeniedException + * @throws ArchivaSecurityException + */ + List getManagableRepositoryIds( String principal ) + throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException; + + /** + * Create any missing repository roles for the provided repository id. + * + * @param repoId the repository id to work off of. + * @throws ArchivaSecurityException if there was a problem creating the repository roles. + */ + void createMissingRepositoryRoles( String repoId ) + throws ArchivaSecurityException; + + /** + * Check if user is authorized to upload artifacts in the repository. + * + * @param principal + * @param repoId + * @return + * @throws PrincipalNotFoundException + * @throws ArchivaSecurityException + */ + boolean isAuthorizedToUploadArtifacts( String principal, String repoId) + throws PrincipalNotFoundException, ArchivaSecurityException; + + /** + * Check if user is authorized to delete artifacts in the repository. + * + * @param principal + * @param repoId + * @return + * @throws ArchivaSecurityException + * @throws AccessDeniedException + */ + boolean isAuthorizedToDeleteArtifacts( String principal, String repoId ) + throws AccessDeniedException, ArchivaSecurityException; + +} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/AccessDeniedException.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/AccessDeniedException.java deleted file mode 100644 index 6784aa60c..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/AccessDeniedException.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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. - */ - -/** - * AccessDeniedException - * - * @version $Id$ - */ -public class AccessDeniedException - extends ArchivaSecurityException -{ - public AccessDeniedException( String message, Throwable cause ) - { - super( message, cause ); - } - - public AccessDeniedException( String message ) - { - super( message ); - } -} 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 deleted file mode 100644 index 396f9250a..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaRoleConstants.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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. - */ - -public class ArchivaRoleConstants -{ - public static final String DELIMITER = " - "; - - // globalish roles - public static final String SYSTEM_ADMINISTRATOR_ROLE = "System Administrator"; - - public static final String USER_ADMINISTRATOR_ROLE = "User Administrator"; - - public static final String GLOBAL_REPOSITORY_MANAGER_ROLE = "Global Repository Manager"; - - public static final String GLOBAL_REPOSITORY_OBSERVER_ROLE = "Global Repository Observer"; - - public static final String REGISTERED_USER_ROLE = "Registered User"; - - public static final String GUEST_ROLE = "Guest"; - - // dynamic role prefixes - public static final String REPOSITORY_MANAGER_ROLE_PREFIX = "Repository Manager"; - - public static final String REPOSITORY_OBSERVER_ROLE_PREFIX = "Repository Observer"; - - // operations - public static final String OPERATION_MANAGE_USERS = "archiva-manage-users"; - - public static final String OPERATION_MANAGE_CONFIGURATION = "archiva-manage-configuration"; - - public static final String OPERATION_ACTIVE_GUEST = "archiva-guest"; - - public static final String OPERATION_RUN_INDEXER = "archiva-run-indexer"; - - public static final String OPERATION_REGENERATE_INDEX = "archiva-regenerate-index"; - - public static final String OPERATION_ACCESS_REPORT = "archiva-access-reports"; - - public static final String OPERATION_ADD_REPOSITORY = "archiva-add-repository"; - - public static final String OPERATION_REPOSITORY_ACCESS = "archiva-read-repository"; - - public static final String OPERATION_DELETE_REPOSITORY = "archiva-delete-repository"; - - public static final String OPERATION_EDIT_REPOSITORY = "archiva-edit-repository"; - - 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"; - - public static final String TEMPLATE_REPOSITORY_OBSERVER = "archiva-repository-observer"; - - public static final String TEMPLATE_GLOBAL_REPOSITORY_OBSERVER = "archiva-global-repository-observer"; - - public static final String TEMPLATE_SYSTEM_ADMIN = "archiva-system-administrator"; - - public static final String TEMPLATE_GUEST = "archiva-guest"; - - public static String toRepositoryObserverRoleName( String repoId ) - { - return REPOSITORY_OBSERVER_ROLE_PREFIX + " - " + repoId; - } -} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaSecurityException.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaSecurityException.java deleted file mode 100644 index 9621eebad..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaSecurityException.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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 org.apache.maven.archiva.common.ArchivaException; - -/** - * ArchivaSecurityException - * - * @version $Id$ - */ -public class ArchivaSecurityException - extends ArchivaException -{ - public ArchivaSecurityException( String message, Throwable cause ) - { - super( message, cause ); - } - - public ArchivaSecurityException( String message ) - { - super( message ); - } -} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java deleted file mode 100644 index a73c9e4a6..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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 javax.inject.Inject; -import javax.servlet.http.HttpServletRequest; - -import org.codehaus.plexus.redback.authentication.AuthenticationException; -import org.codehaus.plexus.redback.authentication.AuthenticationResult; -import org.codehaus.plexus.redback.authorization.AuthorizationException; -import org.codehaus.plexus.redback.authorization.AuthorizationResult; -import org.codehaus.plexus.redback.authorization.UnauthorizedException; -import org.codehaus.plexus.redback.policy.AccountLockedException; -import org.codehaus.plexus.redback.policy.MustChangePasswordException; -import org.codehaus.plexus.redback.system.DefaultSecuritySession; -import org.codehaus.plexus.redback.system.SecuritySession; -import org.codehaus.plexus.redback.system.SecuritySystem; -import org.codehaus.plexus.redback.users.User; -import org.codehaus.plexus.redback.users.UserNotFoundException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -/** - * @version - * plexus.component role="org.apache.maven.archiva.security.ServletAuthenticator" role-hint="default" - */ -@Service("servletAuthenticator") -public class ArchivaServletAuthenticator - implements ServletAuthenticator -{ - private Logger log = LoggerFactory.getLogger( ArchivaServletAuthenticator.class ); - - /** - * plexus.requirement - */ - @Inject - private SecuritySystem securitySystem; - - public boolean isAuthenticated( HttpServletRequest request, AuthenticationResult result ) - throws AuthenticationException, AccountLockedException, MustChangePasswordException - { - if ( result != null && !result.isAuthenticated() ) - { - throw new AuthenticationException( "User Credentials Invalid" ); - } - - return true; - } - - public boolean isAuthorized( HttpServletRequest request, SecuritySession securitySession, String repositoryId, - String permission ) - throws AuthorizationException, UnauthorizedException - { - // TODO: also check for permission to proxy the resource when MRM-579 is implemented - - AuthorizationResult authzResult = securitySystem.authorize( securitySession, permission, repositoryId ); - - if ( !authzResult.isAuthorized() ) - { - if ( authzResult.getException() != null ) - { - log.info( "Authorization Denied [ip=" + request.getRemoteAddr() + ",permission=" + permission - + ",repo=" + repositoryId + "] : " + authzResult.getException().getMessage() ); - - throw new UnauthorizedException( "Access denied for repository " + repositoryId ); - } - throw new UnauthorizedException( "User account is locked" ); - } - - return true; - } - - public boolean isAuthorized( String principal, String repoId, String permission ) - throws UnauthorizedException - { - try - { - User user = securitySystem.getUserManager().findUser( principal ); - if ( user == null ) - { - throw new UnauthorizedException( "The security system had an internal error - please check your system logs" ); - } - if ( user.isLocked() ) - { - throw new UnauthorizedException( "User account is locked." ); - } - - AuthenticationResult authn = new AuthenticationResult( true, principal, null ); - SecuritySession securitySession = new DefaultSecuritySession( authn, user ); - - return securitySystem.isAuthorized( securitySession, permission, repoId ); - } - catch ( UserNotFoundException e ) - { - throw new UnauthorizedException( e.getMessage() ); - } - catch ( AuthorizationException e ) - { - throw new UnauthorizedException( e.getMessage() ); - } - } - - - public SecuritySystem getSecuritySystem() - { - return securitySystem; - } - - public void setSecuritySystem( SecuritySystem securitySystem ) - { - this.securitySystem = securitySystem; - } -} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaStandardRolesCheck.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaStandardRolesCheck.java deleted file mode 100644 index 955455279..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaStandardRolesCheck.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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.List; - -import org.codehaus.plexus.redback.rbac.RBACManager; -import org.codehaus.plexus.redback.system.check.EnvironmentCheck; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import javax.inject.Inject; -import javax.inject.Named; - -/** - * ArchivaStandardRolesCheck tests for the existance of expected / standard roles and permissions. - * - * @version $Id$ - * - * plexus.component role="org.codehaus.plexus.redback.system.check.EnvironmentCheck" - * role-hint="required-roles" - */ -@Service("environmentCheck#archiva-required-roles") -public class ArchivaStandardRolesCheck - implements EnvironmentCheck -{ - private Logger log = LoggerFactory.getLogger( ArchivaStandardRolesCheck.class ); - - /** - * plexus.requirement role-hint="cached" - */ - @Inject @Named(value = "rBACManager#cached") - private RBACManager rbacManager; - - /** - * boolean detailing if this environment check has been executed - */ - private boolean checked = false; - - public void validateEnvironment( List violations ) - { - if ( !checked ) - { - String expectedRoles[] = new String[] { - ArchivaRoleConstants.SYSTEM_ADMINISTRATOR_ROLE, - ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE, - ArchivaRoleConstants.GLOBAL_REPOSITORY_OBSERVER_ROLE, - ArchivaRoleConstants.GUEST_ROLE, - ArchivaRoleConstants.REGISTERED_USER_ROLE, - ArchivaRoleConstants.USER_ADMINISTRATOR_ROLE }; - - log.info( "Checking the existance of required roles." ); - - for ( String roleName : expectedRoles ) - { - if ( !rbacManager.roleExists( roleName ) ) - { - violations.add( "Unable to validate the existances of the '" + roleName + "' role." ); - } - } - - String expectedOperations[] = new String[] { - ArchivaRoleConstants.OPERATION_MANAGE_USERS, - ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, - ArchivaRoleConstants.OPERATION_REGENERATE_INDEX, - ArchivaRoleConstants.OPERATION_RUN_INDEXER, - ArchivaRoleConstants.OPERATION_ACCESS_REPORT, - ArchivaRoleConstants.OPERATION_ADD_REPOSITORY, - ArchivaRoleConstants.OPERATION_DELETE_REPOSITORY, - ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS, - ArchivaRoleConstants.OPERATION_EDIT_REPOSITORY, - ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD, - ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS, - "archiva-guest" }; - - log.info( "Checking the existance of required operations." ); - - for ( String operation : expectedOperations ) - { - if ( !rbacManager.operationExists( operation ) ) - { - violations.add( "Unable to validate the existances of the '" + operation + "' operation." ); - } - } - - checked = true; - } - - } - -} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java deleted file mode 100644 index 317631825..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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.Map; - -import org.codehaus.plexus.redback.system.SecuritySession; -import org.codehaus.plexus.redback.system.SecuritySystemConstants; -import org.codehaus.plexus.redback.users.User; -import org.codehaus.plexus.redback.users.UserManager; - -/** - * ArchivaXworkUser - * - * @version $Id$ - */ -public final class ArchivaXworkUser -{ - private ArchivaXworkUser() - { - // no touchy - } - - public static String getActivePrincipal( Map sessionMap ) - { - if ( sessionMap == null ) - { - return UserManager.GUEST_USERNAME; - } - - SecuritySession securitySession = - (SecuritySession) sessionMap.get( SecuritySystemConstants.SECURITY_SESSION_KEY ); - - if ( securitySession == null ) - { - return UserManager.GUEST_USERNAME; - } - - User user = securitySession.getUser(); - if ( user == null ) - { - return UserManager.GUEST_USERNAME; - } - - return (String) user.getPrincipal(); - } -} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java deleted file mode 100644 index c4603e411..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/DefaultUserRepositories.java +++ /dev/null @@ -1,233 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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 com.google.common.collect.Lists; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.codehaus.plexus.redback.authentication.AuthenticationResult; -import org.codehaus.plexus.redback.authorization.AuthorizationException; -import org.codehaus.plexus.redback.role.RoleManager; -import org.codehaus.plexus.redback.role.RoleManagerException; -import org.codehaus.plexus.redback.system.DefaultSecuritySession; -import org.codehaus.plexus.redback.system.SecuritySession; -import org.codehaus.plexus.redback.system.SecuritySystem; -import org.codehaus.plexus.redback.users.User; -import org.codehaus.plexus.redback.users.UserNotFoundException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.List; - -/** - * DefaultUserRepositories - * - * @version $Id$ - * plexus.component role="org.apache.maven.archiva.security.UserRepositories" role-hint="default" - */ -@Service( "userRepositories" ) -public class DefaultUserRepositories - implements UserRepositories -{ - /** - * plexus.requirement - */ - @Inject - private SecuritySystem securitySystem; - - /** - * plexus.requirement role-hint="default" - */ - @Inject - private RoleManager roleManager; - - /** - * plexus.requirement - */ - @Inject - private ArchivaConfiguration archivaConfiguration; - - private Logger log = LoggerFactory.getLogger( DefaultUserRepositories.class ); - - public List getObservableRepositoryIds( String principal ) - throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException - { - String operation = ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS; - - return getAccessibleRepositoryIds( principal, operation ); - } - - public List getManagableRepositoryIds( String principal ) - throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException - { - String operation = ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD; - - return getAccessibleRepositoryIds( principal, operation ); - } - - private List getAccessibleRepositoryIds( String principal, String operation ) - throws ArchivaSecurityException, AccessDeniedException, PrincipalNotFoundException - { - SecuritySession securitySession = createSession( principal ); - - List repoIds = new ArrayList(); - - List repos = archivaConfiguration.getConfiguration().getManagedRepositories(); - - for ( ManagedRepositoryConfiguration repo : repos ) - { - try - { - String repoId = repo.getId(); - if ( securitySystem.isAuthorized( securitySession, operation, repoId ) ) - { - repoIds.add( repoId ); - } - } - catch ( AuthorizationException e ) - { - // swallow. - if ( log.isDebugEnabled() ) - { - log.debug( "Not authorizing '{}' for repository '{}': {}", - Lists.newArrayList( principal, repo.getId(), e.getMessage() ) ); - } - } - } - - return repoIds; - } - - private SecuritySession createSession( String principal ) - throws ArchivaSecurityException, AccessDeniedException - { - User user; - try - { - user = securitySystem.getUserManager().findUser( principal ); - if ( user == null ) - { - throw new ArchivaSecurityException( - "The security system had an internal error - please check your system logs" ); - } - } - catch ( UserNotFoundException e ) - { - throw new PrincipalNotFoundException( "Unable to find principal " + principal + "" ); - } - - if ( user.isLocked() ) - { - throw new AccessDeniedException( "User " + principal + "(" + user.getFullName() + ") is locked." ); - } - - AuthenticationResult authn = new AuthenticationResult( true, principal, null ); - return new DefaultSecuritySession( authn, user ); - } - - public void createMissingRepositoryRoles( String repoId ) - throws ArchivaSecurityException - { - try - { - if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) ) - { - roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ); - } - - if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) ) - { - roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ); - } - } - catch ( RoleManagerException e ) - { - throw new ArchivaSecurityException( "Unable to create roles for configured repositories: " + e.getMessage(), - e ); - } - } - - public boolean isAuthorizedToUploadArtifacts( String principal, String repoId ) - throws PrincipalNotFoundException, ArchivaSecurityException - { - try - { - SecuritySession securitySession = createSession( principal ); - - return securitySystem.isAuthorized( securitySession, ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD, - repoId ); - - } - catch ( AuthorizationException e ) - { - throw new ArchivaSecurityException( e.getMessage() ); - } - } - - public boolean isAuthorizedToDeleteArtifacts( String principal, String repoId ) - throws AccessDeniedException, ArchivaSecurityException - { - try - { - SecuritySession securitySession = createSession( principal ); - - return securitySystem.isAuthorized( securitySession, ArchivaRoleConstants.OPERATION_REPOSITORY_DELETE, - repoId ); - - } - catch ( AuthorizationException e ) - { - throw new ArchivaSecurityException( e.getMessage() ); - } - } - - public SecuritySystem getSecuritySystem() - { - return securitySystem; - } - - public void setSecuritySystem( SecuritySystem securitySystem ) - { - this.securitySystem = securitySystem; - } - - public RoleManager getRoleManager() - { - return roleManager; - } - - public void setRoleManager( RoleManager roleManager ) - { - this.roleManager = roleManager; - } - - public ArchivaConfiguration getArchivaConfiguration() - { - return archivaConfiguration; - } - - public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration ) - { - this.archivaConfiguration = archivaConfiguration; - } -} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/PrincipalNotFoundException.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/PrincipalNotFoundException.java deleted file mode 100644 index e08bd77b8..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/PrincipalNotFoundException.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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. - */ - -/** - * PrincipalNotFoundException - * - * @version $Id$ - */ -public class PrincipalNotFoundException - extends ArchivaSecurityException -{ - public PrincipalNotFoundException( String message, Throwable cause ) - { - super( message, cause ); - } - - public PrincipalNotFoundException( String message ) - { - super( message ); - } -} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java deleted file mode 100644 index 0dfdb0001..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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 javax.servlet.http.HttpServletRequest; - -import org.codehaus.plexus.redback.authentication.AuthenticationException; -import org.codehaus.plexus.redback.authentication.AuthenticationResult; -import org.codehaus.plexus.redback.authorization.AuthorizationException; -import org.codehaus.plexus.redback.authorization.UnauthorizedException; -import org.codehaus.plexus.redback.policy.AccountLockedException; -import org.codehaus.plexus.redback.policy.MustChangePasswordException; -import org.codehaus.plexus.redback.system.SecuritySession; - -/** - * @version - */ -public interface ServletAuthenticator -{ - /** - * Authentication check for users. - * - * @param request - * @param result - * @return - * @throws AuthenticationException - * @throws AccountLockedException - * @throws MustChangePasswordException - */ - boolean isAuthenticated( HttpServletRequest request, AuthenticationResult result ) - throws AuthenticationException, AccountLockedException, MustChangePasswordException; - - /** - * Authorization check for valid users. - * - * @param request - * @param securitySession - * @param repositoryId - * @param isWriteRequest - * @return - * @throws AuthorizationException - * @throws UnauthorizedException - */ - boolean isAuthorized( HttpServletRequest request, SecuritySession securitySession, String repositoryId, - String permission ) throws AuthorizationException, UnauthorizedException; - - /** - * Authorization check specific for user guest, which doesn't go through - * HttpBasicAuthentication#getAuthenticationResult( HttpServletRequest request, HttpServletResponse response ) - * since no credentials are attached to the request. - * - * See also MRM-911 - * - * @param principal - * @param repoId - * @param isWriteRequest - * @return - * @throws UnauthorizedException - */ - boolean isAuthorized( String principal, String repoId, String permission ) - throws UnauthorizedException; -} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/UserRepositories.java b/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/UserRepositories.java deleted file mode 100644 index 35a5b1903..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/UserRepositories.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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.List; - -/** - * UserRepositories - * - * @version $Id$ - */ -public interface UserRepositories -{ - /** - * Get the list of observable repository ids for the user specified. - * - * @param principal the principle to obtain the observable repository ids from. - * @return the list of observable repository ids. - * @throws PrincipalNotFoundException - * @throws AccessDeniedException - * @throws ArchivaSecurityException - */ - List getObservableRepositoryIds( String principal ) - throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException; - - /** - * Get the list of writable repository ids for the user specified. - * - * @param principal the principle to obtain the observable repository ids from. - * @return the list of observable repository ids. - * @throws PrincipalNotFoundException - * @throws AccessDeniedException - * @throws ArchivaSecurityException - */ - List getManagableRepositoryIds( String principal ) - throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException; - - /** - * Create any missing repository roles for the provided repository id. - * - * @param repoId the repository id to work off of. - * @throws ArchivaSecurityException if there was a problem creating the repository roles. - */ - void createMissingRepositoryRoles( String repoId ) - throws ArchivaSecurityException; - - /** - * Check if user is authorized to upload artifacts in the repository. - * - * @param principal - * @param repoId - * @return - * @throws PrincipalNotFoundException - * @throws ArchivaSecurityException - */ - boolean isAuthorizedToUploadArtifacts( String principal, String repoId) - throws PrincipalNotFoundException, ArchivaSecurityException; - - /** - * Check if user is authorized to delete artifacts in the repository. - * - * @param principal - * @param repoId - * @return - * @throws ArchivaSecurityException - * @throws AccessDeniedException - */ - boolean isAuthorizedToDeleteArtifacts( String principal, String repoId ) - throws AccessDeniedException, ArchivaSecurityException; - -} diff --git a/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/spring-context.xml index 5678a3a0d..3f0c8e586 100644 --- a/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-security/src/main/resources/META-INF/spring-context.xml @@ -28,6 +28,6 @@ default-lazy-init="true"> - + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/AbstractSecurityTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/AbstractSecurityTest.java new file mode 100644 index 000000000..6f6fceac9 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/AbstractSecurityTest.java @@ -0,0 +1,166 @@ +package org.apache.archiva.security; + +/* + * 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 com.google.common.collect.Lists; +import junit.framework.TestCase; +import net.sf.ehcache.CacheManager; +import org.apache.commons.io.FileUtils; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.codehaus.plexus.redback.rbac.RBACManager; +import org.codehaus.plexus.redback.rbac.RbacObjectNotFoundException; +import org.codehaus.plexus.redback.rbac.UserAssignment; +import org.codehaus.plexus.redback.role.RoleManager; +import org.codehaus.plexus.redback.system.SecuritySystem; +import org.codehaus.plexus.redback.users.User; +import org.codehaus.plexus.redback.users.UserManager; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import javax.inject.Inject; +import javax.inject.Named; +import java.io.File; + +/** + * AbstractSecurityTest + * + * @version $Id: AbstractSecurityTest + */ +@RunWith( SpringJUnit4ClassRunner.class ) +@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } ) +public abstract class AbstractSecurityTest + extends TestCase +{ + + protected Logger log = LoggerFactory.getLogger( getClass() ); + + protected static final String USER_GUEST = "guest"; + + protected static final String USER_ADMIN = "admin"; + + protected static final String USER_ALPACA = "alpaca"; + + @Inject + @Named( value = "securitySystem#testable" ) + protected SecuritySystem securitySystem; + + @Inject + @Named( value = "rBACManager#memory" ) + protected RBACManager rbacManager; + + @Inject + protected RoleManager roleManager; + + @Inject + @Named( value = "archivaConfiguration#default" ) + private ArchivaConfiguration archivaConfiguration; + + @Inject + protected UserRepositories userRepos; + + protected void setupRepository( String repoId ) + throws Exception + { + // Add repo to configuration. + ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration(); + repoConfig.setId( repoId ); + repoConfig.setName( "Testable repo <" + repoId + ">" ); + repoConfig.setLocation( new File( "./target/test-repo/" + repoId ).getPath() ); + if ( !archivaConfiguration.getConfiguration().getManagedRepositoriesAsMap().containsKey( repoId ) ) + { + archivaConfiguration.getConfiguration().addManagedRepository( repoConfig ); + } + + // Add repo roles to security. + userRepos.createMissingRepositoryRoles( repoId ); + } + + protected void assignRepositoryObserverRole( String principal, String repoId ) + throws Exception + { + roleManager.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId, principal ); + } + + protected User createUser( String principal, String fullname ) + { + UserManager userManager = securitySystem.getUserManager(); + + User user = userManager.createUser( principal, fullname, principal + "@testable.archiva.apache.org" ); + securitySystem.getPolicy().setEnabled( false ); + userManager.addUser( user ); + securitySystem.getPolicy().setEnabled( true ); + + return user; + } + + @Override + @Before + public void setUp() + throws Exception + { + super.setUp(); + + File srcConfig = new File( "./src/test/resources/repository-archiva.xml" ); + File destConfig = new File( "./target/test-conf/archiva.xml" ); + + destConfig.getParentFile().mkdirs(); + destConfig.delete(); + + FileUtils.copyFile( srcConfig, destConfig ); + + // Some basic asserts. + assertNotNull( securitySystem ); + assertNotNull( rbacManager ); + assertNotNull( roleManager ); + assertNotNull( userRepos ); + assertNotNull( archivaConfiguration ); + + // Setup Admin User. + User adminUser = createUser( USER_ADMIN, "Admin User" ); + roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_SYSTEM_ADMIN, adminUser.getPrincipal().toString() ); + + // Setup Guest User. + User guestUser = createUser( USER_GUEST, "Guest User" ); + roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, guestUser.getPrincipal().toString() ); + } + + protected void restoreGuestInitialValues( String userId ) + throws Exception + { + UserAssignment userAssignment = null; + try + { + userAssignment = rbacManager.getUserAssignment( userId ); + } + catch ( RbacObjectNotFoundException e ) + { + log.info( "ignore RbacObjectNotFoundException for id {} during restoreGuestInitialValues", userId ); + return; + } + userAssignment.setRoleNames( Lists.newArrayList( "Guest" ) ); + rbacManager.saveUserAssignment( userAssignment ); + CacheManager.getInstance().clearAll(); + } +} diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/ArchivaServletAuthenticatorTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/ArchivaServletAuthenticatorTest.java new file mode 100644 index 000000000..e6ed541d1 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/ArchivaServletAuthenticatorTest.java @@ -0,0 +1,258 @@ +package org.apache.archiva.security; + +/* + * 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 org.codehaus.plexus.redback.authentication.AuthenticationException; +import org.codehaus.plexus.redback.authentication.AuthenticationResult; +import org.codehaus.plexus.redback.authorization.UnauthorizedException; +import org.codehaus.plexus.redback.system.DefaultSecuritySession; +import org.codehaus.plexus.redback.system.SecuritySession; +import org.codehaus.plexus.redback.users.User; +import org.codehaus.plexus.redback.users.UserManager; +import org.easymock.MockControl; +import org.junit.Before; +import org.junit.Test; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.servlet.http.HttpServletRequest; + +/** + * ArchivaServletAuthenticatorTest + */ +public class ArchivaServletAuthenticatorTest + extends AbstractSecurityTest +{ + @Inject + @Named( value = "servletAuthenticator#test" ) + private ServletAuthenticator servletAuth; + + private MockControl httpServletRequestControl; + + private HttpServletRequest request; + + @Before + public void setUp() + throws Exception + { + super.setUp(); + + httpServletRequestControl = MockControl.createControl( HttpServletRequest.class ); + request = (HttpServletRequest) httpServletRequestControl.getMock(); + + setupRepository( "corporate" ); + } + + protected String getPlexusConfigLocation() + { + return "org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.xml"; + } + + protected void assignRepositoryManagerRole( String principal, String repoId ) + throws Exception + { + roleManager.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId, principal ); + } + + @Test + public void testIsAuthenticatedUserExists() + throws Exception + { + AuthenticationResult result = new AuthenticationResult( true, "user", null ); + boolean isAuthenticated = servletAuth.isAuthenticated( request, result ); + + assertTrue( isAuthenticated ); + } + + @Test + public void testIsAuthenticatedUserDoesNotExist() + throws Exception + { + AuthenticationResult result = new AuthenticationResult( false, "non-existing-user", null ); + try + { + servletAuth.isAuthenticated( request, result ); + fail( "Authentication exception should have been thrown." ); + } + catch ( AuthenticationException e ) + { + assertEquals( "User Credentials Invalid", e.getMessage() ); + } + } + + @Test + public void testIsAuthorizedUserHasWriteAccess() + throws Exception + { + createUser( USER_ALPACA, "Al 'Archiva' Paca" ); + + assignRepositoryManagerRole( USER_ALPACA, "corporate" ); + + UserManager userManager = securitySystem.getUserManager(); + User user = userManager.findUser( USER_ALPACA ); + + AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null ); + + SecuritySession session = new DefaultSecuritySession( result, user ); + boolean isAuthorized = + servletAuth.isAuthorized( request, session, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ); + + assertTrue( isAuthorized ); + + restoreGuestInitialValues( USER_ALPACA ); + } + + @Test + public void testIsAuthorizedUserHasNoWriteAccess() + throws Exception + { + createUser( USER_ALPACA, "Al 'Archiva' Paca" ); + + assignRepositoryObserverRole( USER_ALPACA, "corporate" ); + + httpServletRequestControl.expectAndReturn( request.getRemoteAddr(), "192.168.111.111" ); + + UserManager userManager = securitySystem.getUserManager(); + User user = userManager.findUser( USER_ALPACA ); + + AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null ); + + SecuritySession session = new DefaultSecuritySession( result, user ); + + httpServletRequestControl.replay(); + + try + { + servletAuth.isAuthorized( request, session, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ); + fail( "UnauthorizedException should have been thrown." ); + } + catch ( UnauthorizedException e ) + { + assertEquals( "Access denied for repository corporate", e.getMessage() ); + } + + httpServletRequestControl.verify(); + + restoreGuestInitialValues( USER_ALPACA ); + } + + @Test + public void testIsAuthorizedUserHasReadAccess() + throws Exception + { + createUser( USER_ALPACA, "Al 'Archiva' Paca" ); + + assignRepositoryObserverRole( USER_ALPACA, "corporate" ); + + UserManager userManager = securitySystem.getUserManager(); + User user = userManager.findUser( USER_ALPACA ); + + AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null ); + + SecuritySession session = new DefaultSecuritySession( result, user ); + boolean isAuthorized = + servletAuth.isAuthorized( request, session, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ); + + assertTrue( isAuthorized ); + + restoreGuestInitialValues( USER_ALPACA ); + } + + @Test + public void testIsAuthorizedUserHasNoReadAccess() + throws Exception + { + createUser( USER_ALPACA, "Al 'Archiva' Paca" ); + + UserManager userManager = securitySystem.getUserManager(); + User user = userManager.findUser( USER_ALPACA ); + + AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null ); + + SecuritySession session = new DefaultSecuritySession( result, user ); + try + { + servletAuth.isAuthorized( request, session, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ); + fail( "UnauthorizedException should have been thrown." ); + } + catch ( UnauthorizedException e ) + { + assertEquals( "Access denied for repository corporate", e.getMessage() ); + } + + restoreGuestInitialValues( USER_ALPACA ); + } + + @Test + public void testIsAuthorizedGuestUserHasWriteAccess() + throws Exception + { + assignRepositoryManagerRole( USER_GUEST, "corporate" ); + boolean isAuthorized = + servletAuth.isAuthorized( USER_GUEST, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ); + + assertTrue( isAuthorized ); + + // cleanup previously add karma + restoreGuestInitialValues(USER_GUEST); + + } + + @Test + public void testIsAuthorizedGuestUserHasNoWriteAccess() + throws Exception + { + assignRepositoryObserverRole( USER_GUEST, "corporate" ); + + boolean isAuthorized = + servletAuth.isAuthorized( USER_GUEST, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ); + assertFalse( isAuthorized ); + + // cleanup previously add karma + restoreGuestInitialValues(USER_GUEST); + + } + + @Test + public void testIsAuthorizedGuestUserHasReadAccess() + throws Exception + { + assignRepositoryObserverRole( USER_GUEST, "corporate" ); + + boolean isAuthorized = + servletAuth.isAuthorized( USER_GUEST, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ); + + assertTrue( isAuthorized ); + + // cleanup previously add karma + restoreGuestInitialValues(USER_GUEST); + } + + @Test + public void testIsAuthorizedGuestUserHasNoReadAccess() + throws Exception + { + boolean isAuthorized = + servletAuth.isAuthorized( USER_GUEST, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ); + + assertFalse( isAuthorized ); + } + +} diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/DefaultUserRepositoriesTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/DefaultUserRepositoriesTest.java new file mode 100644 index 000000000..9d2c0ce0b --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/DefaultUserRepositoriesTest.java @@ -0,0 +1,107 @@ +package org.apache.archiva.security; + +/* + * 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 org.apache.commons.lang.StringUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.util.List; + +/** + * DefaultUserRepositoriesTest + * + * @version $Id$ + */ +public class DefaultUserRepositoriesTest + extends AbstractSecurityTest +{ + + + @Before + public void setUp() + throws Exception + { + super.setUp(); + restoreGuestInitialValues( USER_ALPACA ); + restoreGuestInitialValues( USER_GUEST ); + restoreGuestInitialValues( USER_ADMIN ); + } + + @Test + public void testGetObservableRepositoryIds() + throws Exception + { + // create some users. + createUser( USER_ALPACA, "Al 'Archiva' Paca" ); + + assertEquals( "Expected users", 3, securitySystem.getUserManager().getUsers().size() ); + + // some unassigned repo observer roles. + setupRepository( "central" ); + setupRepository( "corporate" ); + setupRepository( "internal" ); + setupRepository( "snapshots" ); + setupRepository( "secret" ); + + // some assigned repo observer roles. + assignRepositoryObserverRole( USER_ALPACA, "corporate" ); + assignRepositoryObserverRole( USER_ALPACA, "central" ); + assignRepositoryObserverRole( USER_GUEST, "corporate" ); + // the global repo observer role. + assignGlobalRepositoryObserverRole( USER_ADMIN ); + + assertRepoIds( new String[]{ "central", "corporate" }, userRepos.getObservableRepositoryIds( USER_ALPACA ) ); + assertRepoIds( new String[]{ "coporate" }, userRepos.getObservableRepositoryIds( USER_GUEST ) ); + assertRepoIds( new String[]{ "central", "internal", "corporate", "snapshots", "secret" }, + userRepos.getObservableRepositoryIds( USER_ADMIN ) ); + + } + + @After + public void tearDown() + throws Exception + { + super.tearDown(); + restoreGuestInitialValues( USER_ALPACA ); + restoreGuestInitialValues( USER_GUEST ); + restoreGuestInitialValues( USER_ADMIN ); + } + + private void assertRepoIds( String[] expectedRepoIds, List observableRepositoryIds ) + { + assertNotNull( "Observable Repository Ids cannot be null.", observableRepositoryIds ); + + if ( expectedRepoIds.length != observableRepositoryIds.size() ) + { + fail( "Size of Observable Repository Ids wrong, expected <" + expectedRepoIds.length + "> but got <" + + observableRepositoryIds.size() + "> instead. \nExpected: [" + + StringUtils.join( expectedRepoIds, "," ) + "]\nActual: [" + + StringUtils.join( observableRepositoryIds.iterator(), "," ) + "]" ); + } + } + + private void assignGlobalRepositoryObserverRole( String principal ) + throws Exception + { + roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_GLOBAL_REPOSITORY_OBSERVER, principal ); + } +} diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/RoleManagerTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/RoleManagerTest.java new file mode 100644 index 000000000..8e0799faf --- /dev/null +++ b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/RoleManagerTest.java @@ -0,0 +1,57 @@ +package org.apache.archiva.security; + +/* + * 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 junit.framework.TestCase; +import org.codehaus.plexus.redback.role.RoleManager; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import javax.inject.Inject; + +/** + * RoleProfilesTest + * + * @version $Id: RoleManagerTest.java 4330 2007-05-10 17:28:56Z jmcconnell $ + */ +@RunWith( SpringJUnit4ClassRunner.class ) +@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } ) +public class RoleManagerTest + extends TestCase +{ + + @Inject + RoleManager roleManager; + + @Test + public void testExpectedRoles() + throws Exception + { + assertNotNull( roleManager ); + + assertTrue( roleManager.roleExists( "system-administrator" ) ); + assertTrue( roleManager.roleExists( "user-administrator" ) ); + assertTrue( roleManager.roleExists( "archiva-global-repository-observer" ) ); + assertTrue( roleManager.roleExists( "archiva-guest" ) ); + assertTrue( roleManager.roleExists( "guest" ) ); + } +} diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/AbstractSecurityTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/AbstractSecurityTest.java deleted file mode 100644 index 6308f075a..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/AbstractSecurityTest.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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 com.google.common.collect.Lists; -import junit.framework.TestCase; -import net.sf.ehcache.CacheManager; -import org.apache.commons.io.FileUtils; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.codehaus.plexus.redback.rbac.RBACManager; -import org.codehaus.plexus.redback.rbac.RbacObjectNotFoundException; -import org.codehaus.plexus.redback.rbac.UserAssignment; -import org.codehaus.plexus.redback.role.RoleManager; -import org.codehaus.plexus.redback.system.SecuritySystem; -import org.codehaus.plexus.redback.users.User; -import org.codehaus.plexus.redback.users.UserManager; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import javax.inject.Inject; -import javax.inject.Named; -import java.io.File; - -/** - * AbstractSecurityTest - * - * @version $Id: AbstractSecurityTest - */ -@RunWith( SpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } ) -public abstract class AbstractSecurityTest - extends TestCase -{ - - protected Logger log = LoggerFactory.getLogger( getClass() ); - - protected static final String USER_GUEST = "guest"; - - protected static final String USER_ADMIN = "admin"; - - protected static final String USER_ALPACA = "alpaca"; - - @Inject - @Named( value = "securitySystem#testable" ) - protected SecuritySystem securitySystem; - - @Inject - @Named( value = "rBACManager#memory" ) - protected RBACManager rbacManager; - - @Inject - protected RoleManager roleManager; - - @Inject - @Named( value = "archivaConfiguration#default" ) - private ArchivaConfiguration archivaConfiguration; - - @Inject - protected UserRepositories userRepos; - - protected void setupRepository( String repoId ) - throws Exception - { - // Add repo to configuration. - ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration(); - repoConfig.setId( repoId ); - repoConfig.setName( "Testable repo <" + repoId + ">" ); - repoConfig.setLocation( new File( "./target/test-repo/" + repoId ).getPath() ); - if ( !archivaConfiguration.getConfiguration().getManagedRepositoriesAsMap().containsKey( repoId ) ) - { - archivaConfiguration.getConfiguration().addManagedRepository( repoConfig ); - } - - // Add repo roles to security. - userRepos.createMissingRepositoryRoles( repoId ); - } - - protected void assignRepositoryObserverRole( String principal, String repoId ) - throws Exception - { - roleManager.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId, principal ); - } - - protected User createUser( String principal, String fullname ) - { - UserManager userManager = securitySystem.getUserManager(); - - User user = userManager.createUser( principal, fullname, principal + "@testable.archiva.apache.org" ); - securitySystem.getPolicy().setEnabled( false ); - userManager.addUser( user ); - securitySystem.getPolicy().setEnabled( true ); - - return user; - } - - @Override - @Before - public void setUp() - throws Exception - { - super.setUp(); - - File srcConfig = new File( "./src/test/resources/repository-archiva.xml" ); - File destConfig = new File( "./target/test-conf/archiva.xml" ); - - destConfig.getParentFile().mkdirs(); - destConfig.delete(); - - FileUtils.copyFile( srcConfig, destConfig ); - - // Some basic asserts. - assertNotNull( securitySystem ); - assertNotNull( rbacManager ); - assertNotNull( roleManager ); - assertNotNull( userRepos ); - assertNotNull( archivaConfiguration ); - - // Setup Admin User. - User adminUser = createUser( USER_ADMIN, "Admin User" ); - roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_SYSTEM_ADMIN, adminUser.getPrincipal().toString() ); - - // Setup Guest User. - User guestUser = createUser( USER_GUEST, "Guest User" ); - roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, guestUser.getPrincipal().toString() ); - } - - protected void restoreGuestInitialValues( String userId ) - throws Exception - { - UserAssignment userAssignment = null; - try - { - userAssignment = rbacManager.getUserAssignment( userId ); - } - catch ( RbacObjectNotFoundException e ) - { - log.info( "ignore RbacObjectNotFoundException for id {} during restoreGuestInitialValues", userId ); - return; - } - userAssignment.setRoleNames( Lists.newArrayList( "Guest" ) ); - rbacManager.saveUserAssignment( userAssignment ); - CacheManager.getInstance().clearAll(); - } -} diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.java deleted file mode 100644 index a24bb8228..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.java +++ /dev/null @@ -1,262 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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 com.google.common.collect.Lists; -import net.sf.ehcache.CacheManager; -import org.codehaus.plexus.redback.authentication.AuthenticationException; -import org.codehaus.plexus.redback.authentication.AuthenticationResult; -import org.codehaus.plexus.redback.authorization.UnauthorizedException; -import org.codehaus.plexus.redback.rbac.UserAssignment; -import org.codehaus.plexus.redback.system.DefaultSecuritySession; -import org.codehaus.plexus.redback.system.SecuritySession; -import org.codehaus.plexus.redback.users.User; -import org.codehaus.plexus.redback.users.UserManager; -import org.easymock.MockControl; -import org.junit.Before; -import org.junit.Test; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.servlet.http.HttpServletRequest; -import java.util.Arrays; - -/** - * ArchivaServletAuthenticatorTest - */ -public class ArchivaServletAuthenticatorTest - extends AbstractSecurityTest -{ - @Inject - @Named( value = "servletAuthenticator#test" ) - private ServletAuthenticator servletAuth; - - private MockControl httpServletRequestControl; - - private HttpServletRequest request; - - @Before - public void setUp() - throws Exception - { - super.setUp(); - - httpServletRequestControl = MockControl.createControl( HttpServletRequest.class ); - request = (HttpServletRequest) httpServletRequestControl.getMock(); - - setupRepository( "corporate" ); - } - - protected String getPlexusConfigLocation() - { - return "org/apache/maven/archiva/security/ArchivaServletAuthenticatorTest.xml"; - } - - protected void assignRepositoryManagerRole( String principal, String repoId ) - throws Exception - { - roleManager.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId, principal ); - } - - @Test - public void testIsAuthenticatedUserExists() - throws Exception - { - AuthenticationResult result = new AuthenticationResult( true, "user", null ); - boolean isAuthenticated = servletAuth.isAuthenticated( request, result ); - - assertTrue( isAuthenticated ); - } - - @Test - public void testIsAuthenticatedUserDoesNotExist() - throws Exception - { - AuthenticationResult result = new AuthenticationResult( false, "non-existing-user", null ); - try - { - servletAuth.isAuthenticated( request, result ); - fail( "Authentication exception should have been thrown." ); - } - catch ( AuthenticationException e ) - { - assertEquals( "User Credentials Invalid", e.getMessage() ); - } - } - - @Test - public void testIsAuthorizedUserHasWriteAccess() - throws Exception - { - createUser( USER_ALPACA, "Al 'Archiva' Paca" ); - - assignRepositoryManagerRole( USER_ALPACA, "corporate" ); - - UserManager userManager = securitySystem.getUserManager(); - User user = userManager.findUser( USER_ALPACA ); - - AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null ); - - SecuritySession session = new DefaultSecuritySession( result, user ); - boolean isAuthorized = - servletAuth.isAuthorized( request, session, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ); - - assertTrue( isAuthorized ); - - restoreGuestInitialValues( USER_ALPACA ); - } - - @Test - public void testIsAuthorizedUserHasNoWriteAccess() - throws Exception - { - createUser( USER_ALPACA, "Al 'Archiva' Paca" ); - - assignRepositoryObserverRole( USER_ALPACA, "corporate" ); - - httpServletRequestControl.expectAndReturn( request.getRemoteAddr(), "192.168.111.111" ); - - UserManager userManager = securitySystem.getUserManager(); - User user = userManager.findUser( USER_ALPACA ); - - AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null ); - - SecuritySession session = new DefaultSecuritySession( result, user ); - - httpServletRequestControl.replay(); - - try - { - servletAuth.isAuthorized( request, session, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ); - fail( "UnauthorizedException should have been thrown." ); - } - catch ( UnauthorizedException e ) - { - assertEquals( "Access denied for repository corporate", e.getMessage() ); - } - - httpServletRequestControl.verify(); - - restoreGuestInitialValues( USER_ALPACA ); - } - - @Test - public void testIsAuthorizedUserHasReadAccess() - throws Exception - { - createUser( USER_ALPACA, "Al 'Archiva' Paca" ); - - assignRepositoryObserverRole( USER_ALPACA, "corporate" ); - - UserManager userManager = securitySystem.getUserManager(); - User user = userManager.findUser( USER_ALPACA ); - - AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null ); - - SecuritySession session = new DefaultSecuritySession( result, user ); - boolean isAuthorized = - servletAuth.isAuthorized( request, session, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ); - - assertTrue( isAuthorized ); - - restoreGuestInitialValues( USER_ALPACA ); - } - - @Test - public void testIsAuthorizedUserHasNoReadAccess() - throws Exception - { - createUser( USER_ALPACA, "Al 'Archiva' Paca" ); - - UserManager userManager = securitySystem.getUserManager(); - User user = userManager.findUser( USER_ALPACA ); - - AuthenticationResult result = new AuthenticationResult( true, USER_ALPACA, null ); - - SecuritySession session = new DefaultSecuritySession( result, user ); - try - { - servletAuth.isAuthorized( request, session, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ); - fail( "UnauthorizedException should have been thrown." ); - } - catch ( UnauthorizedException e ) - { - assertEquals( "Access denied for repository corporate", e.getMessage() ); - } - - restoreGuestInitialValues( USER_ALPACA ); - } - - @Test - public void testIsAuthorizedGuestUserHasWriteAccess() - throws Exception - { - assignRepositoryManagerRole( USER_GUEST, "corporate" ); - boolean isAuthorized = - servletAuth.isAuthorized( USER_GUEST, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ); - - assertTrue( isAuthorized ); - - // cleanup previously add karma - restoreGuestInitialValues(USER_GUEST); - - } - - @Test - public void testIsAuthorizedGuestUserHasNoWriteAccess() - throws Exception - { - assignRepositoryObserverRole( USER_GUEST, "corporate" ); - - boolean isAuthorized = - servletAuth.isAuthorized( USER_GUEST, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD ); - assertFalse( isAuthorized ); - - // cleanup previously add karma - restoreGuestInitialValues(USER_GUEST); - - } - - @Test - public void testIsAuthorizedGuestUserHasReadAccess() - throws Exception - { - assignRepositoryObserverRole( USER_GUEST, "corporate" ); - - boolean isAuthorized = - servletAuth.isAuthorized( USER_GUEST, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ); - - assertTrue( isAuthorized ); - - // cleanup previously add karma - restoreGuestInitialValues(USER_GUEST); - } - - @Test - public void testIsAuthorizedGuestUserHasNoReadAccess() - throws Exception - { - boolean isAuthorized = - servletAuth.isAuthorized( USER_GUEST, "corporate", ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS ); - - assertFalse( isAuthorized ); - } - -} diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java deleted file mode 100644 index 4c9707500..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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 org.apache.commons.lang.StringUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.util.List; - -/** - * DefaultUserRepositoriesTest - * - * @version $Id$ - */ -public class DefaultUserRepositoriesTest - extends AbstractSecurityTest -{ - - - @Before - public void setUp() - throws Exception - { - super.setUp(); - restoreGuestInitialValues( USER_ALPACA ); - restoreGuestInitialValues( USER_GUEST ); - restoreGuestInitialValues( USER_ADMIN ); - } - - @Test - public void testGetObservableRepositoryIds() - throws Exception - { - // create some users. - createUser( USER_ALPACA, "Al 'Archiva' Paca" ); - - assertEquals( "Expected users", 3, securitySystem.getUserManager().getUsers().size() ); - - // some unassigned repo observer roles. - setupRepository( "central" ); - setupRepository( "corporate" ); - setupRepository( "internal" ); - setupRepository( "snapshots" ); - setupRepository( "secret" ); - - // some assigned repo observer roles. - assignRepositoryObserverRole( USER_ALPACA, "corporate" ); - assignRepositoryObserverRole( USER_ALPACA, "central" ); - assignRepositoryObserverRole( USER_GUEST, "corporate" ); - // the global repo observer role. - assignGlobalRepositoryObserverRole( USER_ADMIN ); - - assertRepoIds( new String[]{ "central", "corporate" }, userRepos.getObservableRepositoryIds( USER_ALPACA ) ); - assertRepoIds( new String[]{ "coporate" }, userRepos.getObservableRepositoryIds( USER_GUEST ) ); - assertRepoIds( new String[]{ "central", "internal", "corporate", "snapshots", "secret" }, - userRepos.getObservableRepositoryIds( USER_ADMIN ) ); - - } - - @After - public void tearDown() - throws Exception - { - super.tearDown(); - restoreGuestInitialValues( USER_ALPACA ); - restoreGuestInitialValues( USER_GUEST ); - restoreGuestInitialValues( USER_ADMIN ); - } - - private void assertRepoIds( String[] expectedRepoIds, List observableRepositoryIds ) - { - assertNotNull( "Observable Repository Ids cannot be null.", observableRepositoryIds ); - - if ( expectedRepoIds.length != observableRepositoryIds.size() ) - { - fail( "Size of Observable Repository Ids wrong, expected <" + expectedRepoIds.length + "> but got <" - + observableRepositoryIds.size() + "> instead. \nExpected: [" - + StringUtils.join( expectedRepoIds, "," ) + "]\nActual: [" - + StringUtils.join( observableRepositoryIds.iterator(), "," ) + "]" ); - } - } - - private void assignGlobalRepositoryObserverRole( String principal ) - throws Exception - { - roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_GLOBAL_REPOSITORY_OBSERVER, principal ); - } -} diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/RoleManagerTest.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/RoleManagerTest.java deleted file mode 100644 index f1b3894f8..000000000 --- a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/RoleManagerTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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 junit.framework.TestCase; -import org.codehaus.plexus.redback.role.RoleManager; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import javax.inject.Inject; - -/** - * RoleProfilesTest - * - * @version $Id: RoleManagerTest.java 4330 2007-05-10 17:28:56Z jmcconnell $ - */ -@RunWith( SpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } ) -public class RoleManagerTest - extends TestCase -{ - - @Inject - RoleManager roleManager; - - @Test - public void testExpectedRoles() - throws Exception - { - assertNotNull( roleManager ); - - assertTrue( roleManager.roleExists( "system-administrator" ) ); - assertTrue( roleManager.roleExists( "user-administrator" ) ); - assertTrue( roleManager.roleExists( "archiva-global-repository-observer" ) ); - assertTrue( roleManager.roleExists( "archiva-guest" ) ); - assertTrue( roleManager.roleExists( "guest" ) ); - } -} diff --git a/archiva-modules/archiva-web/archiva-security/src/test/resources/spring-context.xml b/archiva-modules/archiva-web/archiva-security/src/test/resources/spring-context.xml index 24723b149..e35856f2b 100644 --- a/archiva-modules/archiva-web/archiva-security/src/test/resources/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-security/src/test/resources/spring-context.xml @@ -34,7 +34,7 @@ - + @@ -72,7 +72,7 @@ - + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java index a53251284..4a1afabda 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/rss/RssFeedServlet.java @@ -29,12 +29,12 @@ import org.apache.commons.codec.Decoder; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.security.AccessDeniedException; -import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.maven.archiva.security.ArchivaSecurityException; -import org.apache.maven.archiva.security.PrincipalNotFoundException; -import org.apache.maven.archiva.security.ServletAuthenticator; -import org.apache.maven.archiva.security.UserRepositories; +import org.apache.archiva.security.AccessDeniedException; +import org.apache.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaSecurityException; +import org.apache.archiva.security.PrincipalNotFoundException; +import org.apache.archiva.security.ServletAuthenticator; +import org.apache.archiva.security.UserRepositories; import org.codehaus.plexus.redback.authentication.AuthenticationException; import org.codehaus.plexus.redback.authentication.AuthenticationResult; import org.codehaus.plexus.redback.authorization.AuthorizationException; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java index 0d6956178..3f3402afc 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java @@ -25,7 +25,7 @@ import org.apache.maven.archiva.common.ArchivaException; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ConfigurationNames; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.codehaus.plexus.redback.rbac.RBACManager; import org.codehaus.plexus.redback.rbac.RbacManagerException; import org.codehaus.plexus.redback.rbac.UserAssignment; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/tags/DependencyTree.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/tags/DependencyTree.java index f468e9492..dca04351e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/tags/DependencyTree.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/tags/DependencyTree.java @@ -24,8 +24,8 @@ import org.apache.archiva.dependency.tree.maven2.DependencyTreeBuilder; import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.common.ArchivaException; import org.apache.maven.archiva.model.Keys; -import org.apache.maven.archiva.security.ArchivaXworkUser; -import org.apache.maven.archiva.security.UserRepositories; +import org.apache.archiva.security.ArchivaXworkUser; +import org.apache.archiva.security.UserRepositories; import org.apache.maven.artifact.Artifact; import org.apache.maven.shared.dependency.tree.DependencyNode; import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractActionSupport.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractActionSupport.java index 468b51087..aced6a79c 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractActionSupport.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractActionSupport.java @@ -27,7 +27,7 @@ import org.apache.archiva.audit.AuditListener; import org.apache.archiva.audit.Auditable; import org.apache.archiva.metadata.repository.RepositorySessionFactory; import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.security.ArchivaXworkUser; +import org.apache.archiva.security.ArchivaXworkUser; import org.apache.struts2.ServletActionContext; import org.apache.struts2.interceptor.SessionAware; import org.codehaus.plexus.redback.users.User; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractRepositoryBasedAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractRepositoryBasedAction.java index c75f30c52..5bfcc036e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractRepositoryBasedAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/AbstractRepositoryBasedAction.java @@ -19,10 +19,10 @@ package org.apache.maven.archiva.web.action; * under the License. */ -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.archiva.security.AccessDeniedException; +import org.apache.archiva.security.ArchivaSecurityException; +import org.apache.archiva.security.PrincipalNotFoundException; +import org.apache.archiva.security.UserRepositories; import javax.inject.Inject; import java.util.Collections; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java index e370066ec..d8e82635e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java @@ -19,7 +19,6 @@ package org.apache.maven.archiva.web.action; * under the License. */ -import com.google.common.collect.Lists; import com.opensymphony.xwork2.Preparable; import com.opensymphony.xwork2.Validateable; import org.apache.archiva.audit.AuditEvent; @@ -48,10 +47,10 @@ import org.apache.maven.archiva.repository.metadata.MetadataTools; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter; -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.archiva.security.AccessDeniedException; +import org.apache.archiva.security.ArchivaSecurityException; +import org.apache.archiva.security.PrincipalNotFoundException; +import org.apache.archiva.security.UserRepositories; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java index 46d09dd46..d314ad29e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java @@ -46,10 +46,10 @@ import org.apache.maven.archiva.repository.metadata.MetadataTools; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter; -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.archiva.security.AccessDeniedException; +import org.apache.archiva.security.ArchivaSecurityException; +import org.apache.archiva.security.PrincipalNotFoundException; +import org.apache.archiva.security.UserRepositories; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.codehaus.plexus.taskqueue.TaskQueueException; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java index 9871e4d5a..fe51db25f 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java @@ -22,7 +22,7 @@ package org.apache.maven.archiva.web.action.admin; import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.AbstractActionSupport; import org.codehaus.plexus.redback.rbac.Resource; import org.codehaus.plexus.taskqueue.TaskQueueException; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java index 6b5686033..87e2eb901 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java @@ -21,7 +21,7 @@ package org.apache.maven.archiva.web.action.admin; import org.apache.archiva.repository.scanner.RepositoryScanner; import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.AbstractActionSupport; import org.codehaus.plexus.cache.Cache; import org.codehaus.plexus.redback.rbac.Resource; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java index d721c7914..c1114977a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/appearance/EditOrganisationInfoAction.java @@ -24,7 +24,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; import org.apache.maven.archiva.configuration.OrganisationInformation; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.codehaus.plexus.redback.rbac.Resource; import org.codehaus.plexus.registry.RegistryException; import org.codehaus.redback.integration.interceptor.SecureAction; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java index bee78a0c9..70632e311 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java @@ -27,7 +27,7 @@ import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; import org.apache.maven.archiva.configuration.functors.ProxyConnectorSelectionPredicate; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.AbstractActionSupport; import org.codehaus.plexus.redback.rbac.Resource; import org.codehaus.plexus.registry.RegistryException; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java index fc6089c82..1269ae720 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/legacy/LegacyArtifactPathAction.java @@ -23,7 +23,7 @@ import com.opensymphony.xwork2.Preparable; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.LegacyArtifactPath; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.AbstractActionSupport; import org.apache.archiva.web.util.ContextUtils; import org.apache.struts2.interceptor.ServletRequestAware; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java index d9cb4b2ef..b8b2e2093 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java @@ -29,7 +29,7 @@ import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; import org.apache.maven.archiva.configuration.NetworkProxyConfiguration; import org.apache.maven.archiva.configuration.functors.NetworkProxySelectionPredicate; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.AbstractActionSupport; import org.codehaus.plexus.redback.rbac.Resource; import org.codehaus.plexus.registry.RegistryException; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java index 5bfdd510d..888edb846 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/NetworkProxiesAction.java @@ -22,7 +22,7 @@ package org.apache.maven.archiva.web.action.admin.networkproxies; import com.opensymphony.xwork2.Preparable; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.NetworkProxyConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.AbstractActionSupport; import org.codehaus.plexus.redback.rbac.Resource; import org.codehaus.redback.integration.interceptor.SecureAction; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractRepositoriesAdminAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractRepositoriesAdminAction.java index 7af73b904..15f320f10 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractRepositoriesAdminAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractRepositoriesAdminAction.java @@ -19,7 +19,6 @@ package org.apache.maven.archiva.web.action.admin.repositories; * under the License. */ -import org.apache.archiva.admin.AuditInformation; import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin; import org.apache.archiva.audit.Auditable; import org.apache.maven.archiva.configuration.ArchivaConfiguration; @@ -27,21 +26,17 @@ import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; import org.apache.maven.archiva.configuration.InvalidConfigurationException; import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.AbstractActionSupport; import org.codehaus.plexus.redback.rbac.Resource; -import org.codehaus.plexus.redback.users.User; import org.codehaus.plexus.registry.RegistryException; import org.codehaus.redback.integration.interceptor.SecureAction; import org.codehaus.redback.integration.interceptor.SecureActionBundle; import org.codehaus.redback.integration.interceptor.SecureActionException; -import org.codehaus.redback.rest.services.RedbackAuthenticationThreadLocal; -import org.codehaus.redback.rest.services.RedbackRequestInformation; import javax.inject.Inject; import java.io.IOException; import java.util.ArrayList; -import java.util.Date; import java.util.List; /** diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java index 490a0550a..861deb37b 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java @@ -30,7 +30,7 @@ import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.maven.archiva.configuration.functors.RepositoryConfigurationComparator; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.AbstractActionSupport; import org.apache.archiva.web.util.ContextUtils; import org.apache.struts2.interceptor.ServletRequestAware; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java index 04006431c..db4847087 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/scanning/RepositoryScanningAction.java @@ -33,7 +33,7 @@ import org.apache.maven.archiva.configuration.IndeterminateConfigurationExceptio import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; import org.apache.maven.archiva.configuration.functors.FiletypeSelectionPredicate; import org.apache.maven.archiva.configuration.functors.FiletypeToMapClosure; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.AbstractActionSupport; import org.codehaus.plexus.redback.rbac.Resource; import org.codehaus.plexus.registry.RegistryException; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java index 04e887912..981ad900e 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java @@ -30,7 +30,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DateUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.AbstractRepositoryBasedAction; import org.codehaus.plexus.redback.rbac.Resource; import org.codehaus.redback.integration.interceptor.SecureAction; 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 index 01617770c..059124174 100644 --- 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 @@ -25,10 +25,10 @@ import org.apache.archiva.audit.AuditManager; import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DateUtils; -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.archiva.security.AccessDeniedException; +import org.apache.archiva.security.ArchivaSecurityException; +import org.apache.archiva.security.PrincipalNotFoundException; +import org.apache.archiva.security.UserRepositories; import org.apache.maven.archiva.web.action.AbstractActionSupport; import org.apache.struts2.interceptor.ServletRequestAware; import org.codehaus.redback.integration.interceptor.SecureAction; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/security/UserRepositoriesStub.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/security/UserRepositoriesStub.java new file mode 100644 index 000000000..3e8cf50a4 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/security/UserRepositoriesStub.java @@ -0,0 +1,77 @@ +package org.apache.archiva.security; + +/* + * 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.Collections; +import java.util.List; + +/** + * UserRepositories stub used for testing. + * + * @version $Id$ + */ +public class UserRepositoriesStub + implements UserRepositories +{ + private List repoIds = Collections.singletonList( "test-repo" ); + + public void createMissingRepositoryRoles( String repoId ) + throws ArchivaSecurityException + { + } + + public List getObservableRepositoryIds( String principal ) + throws ArchivaSecurityException + { + return repoIds; + } + + public void setObservableRepositoryIds( List repoIds ) + { + this.repoIds = repoIds; + } + + public boolean isAuthorizedToUploadArtifacts( String principal, String repoId ) + throws ArchivaSecurityException + { + return false; + } + + public boolean isAuthorizedToDeleteArtifacts( String principal, String repoId ) + { + return false; + } + + public List getManagableRepositoryIds( String principal ) + throws ArchivaSecurityException + { + return null; + } + + public List getRepoIds() + { + return repoIds; + } + + public void setRepoIds( List repoIds ) + { + this.repoIds = repoIds; + } +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/security/UserRepositoriesStub.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/security/UserRepositoriesStub.java deleted file mode 100644 index eb6ab26ed..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/security/UserRepositoriesStub.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.apache.maven.archiva.security; - -/* - * 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.Collections; -import java.util.List; - -/** - * UserRepositories stub used for testing. - * - * @version $Id$ - */ -public class UserRepositoriesStub - implements UserRepositories -{ - private List repoIds = Collections.singletonList( "test-repo" ); - - public void createMissingRepositoryRoles( String repoId ) - throws ArchivaSecurityException - { - } - - public List getObservableRepositoryIds( String principal ) - throws ArchivaSecurityException - { - return repoIds; - } - - public void setObservableRepositoryIds( List repoIds ) - { - this.repoIds = repoIds; - } - - public boolean isAuthorizedToUploadArtifacts( String principal, String repoId ) - throws ArchivaSecurityException - { - return false; - } - - public boolean isAuthorizedToDeleteArtifacts( String principal, String repoId ) - { - return false; - } - - public List getManagableRepositoryIds( String principal ) - throws ArchivaSecurityException - { - return null; - } - - public List getRepoIds() - { - return repoIds; - } - - public void setRepoIds( List repoIds ) - { - this.repoIds = repoIds; - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java index cd3562ae6..20c9b49b7 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/AbstractActionTestCase.java @@ -36,10 +36,9 @@ import org.apache.archiva.metadata.model.Scm; import org.apache.archiva.metadata.repository.memory.TestMetadataResolver; import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet; import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectParent; -import org.apache.maven.archiva.security.UserRepositoriesStub; +import org.apache.archiva.security.UserRepositoriesStub; import org.apache.struts2.StrutsSpringTestCase; -import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java index ba8994c33..cb0c5aca0 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java @@ -31,7 +31,7 @@ import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory; import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.security.UserRepositories; +import org.apache.archiva.security.UserRepositories; import org.easymock.MockControl; import java.util.ArrayList; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java index 06a1b354a..747f719db 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryActionTest.java @@ -27,7 +27,7 @@ import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.commons.io.FileUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.archiva.web.validator.utils.ValidatorUtil; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.plexus.registry.Registry; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java index e86898d8f..736073f1f 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java @@ -35,17 +35,14 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.AbstractActionTestCase; import org.apache.maven.archiva.web.action.AuditEventArgumentsMatcher; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.plexus.redback.role.RoleManagerException; -import org.codehaus.plexus.redback.users.User; -import org.codehaus.plexus.redback.users.jdo.JdoUser; import org.codehaus.plexus.registry.RegistryException; import org.codehaus.redback.integration.interceptor.SecureActionBundle; import org.codehaus.redback.integration.interceptor.SecureActionException; -import org.codehaus.redback.rest.services.RedbackRequestInformation; import org.easymock.MockControl; import java.io.File; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java index 05c439513..4b9bc7d25 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/EditManagedRepositoryActionTest.java @@ -34,7 +34,7 @@ import org.apache.commons.io.FileUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.archiva.web.validator.utils.ValidatorUtil; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.plexus.registry.Registry; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.java index 6bc27bd8f..21ccd53b5 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/reports/GenerateReportActionTest.java @@ -29,7 +29,7 @@ import org.apache.archiva.metadata.repository.stats.RepositoryStatistics; import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager; import org.apache.archiva.reports.RepositoryProblemFacet; import org.apache.commons.io.IOUtils; -import org.apache.maven.archiva.security.UserRepositoriesStub; +import org.apache.archiva.security.UserRepositoriesStub; import org.apache.maven.archiva.web.action.AbstractActionTestCase; import org.easymock.MockControl; import org.junit.After; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml index 949aa6a6d..37834e217 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml @@ -34,7 +34,7 @@ - + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context.xml index 0c2f74e0e..8c2633875 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context.xml @@ -34,7 +34,7 @@ - + diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java index 1b905855d..5d97924f1 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java @@ -56,7 +56,7 @@ import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataMerge; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader; import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter; -import org.apache.maven.archiva.security.ServletAuthenticator; +import org.apache.archiva.security.ServletAuthenticator; import org.apache.maven.archiva.webdav.util.MimeTypes; import org.apache.maven.archiva.webdav.util.RepositoryPathUtil; import org.apache.maven.archiva.webdav.util.WebdavMethodUtil; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java index 536454dfe..01d3fe91c 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProvider.java @@ -23,7 +23,7 @@ import org.apache.jackrabbit.webdav.DavException; import org.apache.jackrabbit.webdav.DavServletRequest; import org.apache.jackrabbit.webdav.DavSessionProvider; import org.apache.jackrabbit.webdav.WebdavRequest; -import org.apache.maven.archiva.security.ServletAuthenticator; +import org.apache.archiva.security.ServletAuthenticator; import org.apache.maven.archiva.webdav.util.RepositoryPathUtil; import org.apache.maven.archiva.webdav.util.WebdavMethodUtil; import org.codehaus.plexus.redback.authentication.AuthenticationException; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java index fed837c75..59363bcf3 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/RepositoryServlet.java @@ -35,7 +35,7 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ConfigurationEvent; import org.apache.maven.archiva.configuration.ConfigurationListener; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.security.ServletAuthenticator; +import org.apache.archiva.security.ServletAuthenticator; import org.codehaus.redback.integration.filter.authentication.HttpAuthenticator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/WebdavMethodUtil.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/WebdavMethodUtil.java index fad10e294..70e055e6c 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/WebdavMethodUtil.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/util/WebdavMethodUtil.java @@ -20,7 +20,7 @@ package org.apache.maven.archiva.webdav.util; */ import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import java.util.ArrayList; import java.util.List; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProviderTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProviderTest.java index c553cb4b6..da5d15ac5 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProviderTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/ArchivaDavSessionProviderTest.java @@ -23,7 +23,7 @@ import junit.framework.TestCase; import org.apache.jackrabbit.webdav.DavSessionProvider; import org.apache.jackrabbit.webdav.WebdavRequest; import org.apache.jackrabbit.webdav.WebdavRequestImpl; -import org.apache.maven.archiva.security.ServletAuthenticator; +import org.apache.archiva.security.ServletAuthenticator; import org.codehaus.plexus.redback.authentication.AuthenticationDataSource; import org.codehaus.plexus.redback.authentication.AuthenticationException; import org.codehaus.plexus.redback.authentication.AuthenticationResult; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/MockServletAuthenticator.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/MockServletAuthenticator.java index 0f1b8ab6a..1debad2d4 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/MockServletAuthenticator.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/MockServletAuthenticator.java @@ -19,7 +19,7 @@ package org.apache.maven.archiva.webdav; * under the License. */ -import org.apache.maven.archiva.security.ArchivaServletAuthenticator; +import org.apache.archiva.security.ArchivaServletAuthenticator; import org.codehaus.plexus.redback.authorization.UnauthorizedException; public class MockServletAuthenticator diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java index bb60f61bc..b437b886c 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletSecurityTest.java @@ -35,8 +35,8 @@ import org.apache.jackrabbit.webdav.DavSessionProvider; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.maven.archiva.security.ServletAuthenticator; +import org.apache.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ServletAuthenticator; import org.codehaus.plexus.redback.authentication.AuthenticationException; import org.codehaus.plexus.redback.authentication.AuthenticationResult; import org.codehaus.plexus.redback.authorization.UnauthorizedException; diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java index 663a37e09..e3358e934 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java @@ -21,9 +21,9 @@ package org.apache.archiva.web.xmlrpc.security; import java.util.List; -import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.maven.archiva.security.ArchivaSecurityException; -import org.apache.maven.archiva.security.UserRepositories; +import org.apache.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaSecurityException; +import org.apache.archiva.security.UserRepositories; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl; diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcUserRepositories.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcUserRepositories.java index 996458e95..65bd79964 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcUserRepositories.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcUserRepositories.java @@ -21,9 +21,9 @@ package org.apache.archiva.web.xmlrpc.security; import java.util.List; -import org.apache.maven.archiva.security.ArchivaSecurityException; -import org.apache.maven.archiva.security.PrincipalNotFoundException; -import org.apache.maven.archiva.security.UserRepositories; +import org.apache.archiva.security.ArchivaSecurityException; +import org.apache.archiva.security.PrincipalNotFoundException; +import org.apache.archiva.security.UserRepositories; import org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping.AuthenticationHandler; public class XmlRpcUserRepositories diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java index a9f443a23..eda25e213 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java @@ -21,7 +21,7 @@ package org.apache.archiva.xmlrpc.security; import junit.framework.TestCase; import org.apache.archiva.web.xmlrpc.security.XmlRpcAuthenticator; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.apache.xmlrpc.XmlRpcRequest; import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl; import org.codehaus.plexus.redback.role.RoleManager; diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java index 886bbfc2b..04fcbace5 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java @@ -54,7 +54,7 @@ import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryConte import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryContent; import org.apache.maven.archiva.repository.content.PathParser; import org.apache.maven.archiva.repository.layout.LayoutException; -import org.apache.maven.archiva.security.ArchivaRoleConstants; +import org.apache.archiva.security.ArchivaRoleConstants; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.plexus.registry.Registry; import org.easymock.MockControl; -- cgit v1.2.3