From dd93a29b3481f7858cc8649c1523b1348990e3ec Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 4 Dec 2012 15:26:25 +0000 Subject: [PATCH] if any exception must be returned in rest response git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1416990 13f79535-47bb-0310-9956-ffa450edef68 --- .../rest/services/DefaultLoginService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java index 6aa65b59..53141056 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java @@ -29,6 +29,7 @@ import org.apache.archiva.redback.keys.memory.MemoryAuthenticationKey; import org.apache.archiva.redback.keys.memory.MemoryKeyManager; import org.apache.archiva.redback.policy.AccountLockedException; import org.apache.archiva.redback.policy.MustChangePasswordException; +import org.apache.archiva.redback.rest.api.model.ErrorMessage; import org.apache.archiva.redback.rest.api.model.LoginRequest; import org.apache.archiva.redback.rest.api.model.User; import org.apache.archiva.redback.rest.api.services.LoginService; @@ -46,7 +47,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; +import java.util.ArrayList; import java.util.Calendar; +import java.util.List; +import java.util.Map; import java.util.TimeZone; /** @@ -145,6 +149,17 @@ public class DefaultLoginService httpAuthenticator.authenticate( authDataSource, httpServletRequest.getSession( true ) ); return restUser; } + if ( securitySession.getAuthenticationResult() != null + && securitySession.getAuthenticationResult().getExceptionsMap() != null ) + { + List errorMessages = new ArrayList(); + for ( Map.Entry entry : securitySession.getAuthenticationResult().getExceptionsMap().entrySet() ) + { + errorMessages.add( new ErrorMessage( entry.getValue() ) ); + } + + throw new RedbackServiceException( errorMessages ); + } return null; } catch ( AuthenticationException e )