From 01c3aee959e31abe1ac11ec73ca1e5fb2c0785ea Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 18 Aug 2012 21:33:10 +0000 Subject: [PATCH] preserve stack trace git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1374660 13f79535-47bb-0310-9956-ffa450edef68 --- .../services/DefaultRepositoriesService.java | 2 +- .../security/ArchivaServletAuthenticator.java | 19 ++++++++++--------- .../security/DefaultUserRepositories.java | 12 +++++------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java index 99dc202b9..4bfe578c4 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java @@ -318,7 +318,7 @@ public class DefaultRepositoriesService } catch ( UserNotFoundException e ) { - throw new ArchivaRestServiceException( "user " + userName + " not found", null ); + throw new ArchivaRestServiceException( "user " + userName + " not found", e ); } // check karma on source : read 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 index 01c1087cd..74e4567bc 100644 --- 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 @@ -19,9 +19,6 @@ package org.apache.archiva.security; * under the License. */ -import javax.inject.Inject; -import javax.servlet.http.HttpServletRequest; - import org.apache.archiva.redback.authentication.AuthenticationException; import org.apache.archiva.redback.authentication.AuthenticationResult; import org.apache.archiva.redback.authorization.AuthorizationException; @@ -38,10 +35,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; + /** * */ -@Service("servletAuthenticator") +@Service( "servletAuthenticator" ) public class ArchivaServletAuthenticator implements ServletAuthenticator { @@ -76,8 +76,8 @@ public class ArchivaServletAuthenticator { if ( authzResult.getException() != null ) { - log.info( "Authorization Denied [ip=" + request.getRemoteAddr() + ",permission=" + permission - + ",repo=" + repositoryId + "] : " + authzResult.getException().getMessage() ); + log.info( "Authorization Denied [ip=" + request.getRemoteAddr() + ",permission=" + permission + ",repo=" + + repositoryId + "] : " + authzResult.getException().getMessage() ); throw new UnauthorizedException( "Access denied for repository " + repositoryId ); } @@ -95,7 +95,8 @@ public class ArchivaServletAuthenticator User user = securitySystem.getUserManager().findUser( principal ); if ( user == null ) { - throw new UnauthorizedException( "The security system had an internal error - please check your system logs" ); + throw new UnauthorizedException( + "The security system had an internal error - please check your system logs" ); } if ( user.isLocked() ) { @@ -109,11 +110,11 @@ public class ArchivaServletAuthenticator } catch ( UserNotFoundException e ) { - throw new UnauthorizedException( e.getMessage() ); + throw new UnauthorizedException( e.getMessage(), e ); } catch ( AuthorizationException e ) { - throw new UnauthorizedException( e.getMessage() ); + throw new UnauthorizedException( e.getMessage(), e ); } } 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 index 2f50d3350..1d6d3fb96 100644 --- 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 @@ -23,9 +23,6 @@ import com.google.common.collect.Lists; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; -import org.apache.archiva.redback.users.User; -import org.apache.archiva.redback.users.UserNotFoundException; -import org.apache.archiva.security.common.ArchivaRoleConstants; import org.apache.archiva.redback.authentication.AuthenticationResult; import org.apache.archiva.redback.authorization.AuthorizationException; import org.apache.archiva.redback.role.RoleManager; @@ -33,6 +30,9 @@ import org.apache.archiva.redback.role.RoleManagerException; import org.apache.archiva.redback.system.DefaultSecuritySession; import org.apache.archiva.redback.system.SecuritySession; import org.apache.archiva.redback.system.SecuritySystem; +import org.apache.archiva.redback.users.User; +import org.apache.archiva.redback.users.UserNotFoundException; +import org.apache.archiva.security.common.ArchivaRoleConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -43,10 +43,8 @@ import java.util.List; /** * DefaultUserRepositories - * - * */ -@Service( "userRepositories" ) +@Service("userRepositories") public class DefaultUserRepositories implements UserRepositories { @@ -153,7 +151,7 @@ public class DefaultUserRepositories } catch ( UserNotFoundException e ) { - throw new PrincipalNotFoundException( "Unable to find principal " + principal + "" ); + throw new PrincipalNotFoundException( "Unable to find principal " + principal + "", e ); } if ( user.isLocked() )