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
This commit is contained in:
Olivier Lamy 2012-12-04 15:26:25 +00:00
parent 1d47163f9d
commit dd93a29b34
1 changed files with 15 additions and 0 deletions

View File

@ -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<ErrorMessage> errorMessages = new ArrayList<ErrorMessage>();
for ( Map.Entry<String, String> entry : securitySession.getAuthenticationResult().getExceptionsMap().entrySet() )
{
errorMessages.add( new ErrorMessage( entry.getValue() ) );
}
throw new RedbackServiceException( errorMessages );
}
return null;
}
catch ( AuthenticationException e )