diff --git a/authentication/source/java/ch/systemsx/cisd/authentication/IAuthenticationService.java b/authentication/source/java/ch/systemsx/cisd/authentication/IAuthenticationService.java index 85b7eb0d72f866828bcbbf12201fd6899bd750b3..08eb97ff2534cdc892eb18195829f706ba20c014 100644 --- a/authentication/source/java/ch/systemsx/cisd/authentication/IAuthenticationService.java +++ b/authentication/source/java/ch/systemsx/cisd/authentication/IAuthenticationService.java @@ -28,7 +28,7 @@ public interface IAuthenticationService extends ISelfTestable /** * Attempts authentication of the application with credentials passed in the constructor and - * retuns the application token. Implementations should log what is going on, whether the + * returns the application token. Implementations should log what is going on, whether the * application could register itself successfully or not. * <p> * The returned application token can then be used to authenticate an user (via @@ -60,8 +60,10 @@ public interface IAuthenticationService extends ISelfTestable * not <code>null</code>) to perform this lookup. * </p> * - * @return a <code>Principal</code> object if given <var>user</var> could be found, - * <code>null</code> otherwise. + * @return The <code>Principal</code> object for the given <var>user</var>. + * @throws IllegalArgumentException If either the <var>applicationToken</var> is invalid or the + * <var>user</var> cannot be found. */ - public Principal getPrincipal(String applicationToken, String user); + public Principal getPrincipal(String applicationToken, String user) + throws IllegalArgumentException; } \ No newline at end of file diff --git a/authentication/source/java/ch/systemsx/cisd/authentication/crowd/CrowdAuthenticationService.java b/authentication/source/java/ch/systemsx/cisd/authentication/crowd/CrowdAuthenticationService.java index 0227302535f3a9a67d1d543ff1b1982f8740eba4..d72d0a9d899562723519635732d9f5f3486ab0f0 100644 --- a/authentication/source/java/ch/systemsx/cisd/authentication/crowd/CrowdAuthenticationService.java +++ b/authentication/source/java/ch/systemsx/cisd/authentication/crowd/CrowdAuthenticationService.java @@ -273,11 +273,10 @@ public class CrowdAuthenticationService implements IAuthenticationService } if (principal == null) { - throw new EnvironmentFailureException("CROWD: Principal information for user '" - + user + "' could not be obtained."); + throw new IllegalArgumentException("Cannot find user '" + user + "'."); } return principal; - } catch (EnvironmentFailureException ex) + } catch (IllegalArgumentException ex) { throw ex; } catch (Exception ex) // SAXException, IOException diff --git a/authentication/sourceTest/java/ch/systemsx/cisd/authentication/crowd/CrowdAuthenticationServiceTest.java b/authentication/sourceTest/java/ch/systemsx/cisd/authentication/crowd/CrowdAuthenticationServiceTest.java index 9724f008664cefd3852e6b64ce189d6af5dbb3dd..68460daa17b50b23b77cc50b07697aaa6e5138a2 100644 --- a/authentication/sourceTest/java/ch/systemsx/cisd/authentication/crowd/CrowdAuthenticationServiceTest.java +++ b/authentication/sourceTest/java/ch/systemsx/cisd/authentication/crowd/CrowdAuthenticationServiceTest.java @@ -28,7 +28,6 @@ import org.testng.annotations.Test; import ch.systemsx.cisd.authentication.IAuthenticationService; import ch.systemsx.cisd.authentication.Principal; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.logging.BufferedAppender; import ch.systemsx.cisd.common.utilities.OSUtilities; @@ -250,10 +249,9 @@ public class CrowdAuthenticationServiceTest { authenticationService.getPrincipal(APPLICATION_TOKEN, USER); fail("EnvironmentFailureException expected"); - } catch (EnvironmentFailureException e) + } catch (IllegalArgumentException e) { - assertEquals("CROWD: Principal information for user '" + USER - + "' could not be obtained.", e.getMessage()); + assertEquals("Cannot find user '" + USER + "'.", e.getMessage()); } assertEquals(