diff --git a/authentication/source/java/ch/systemsx/cisd/authentication/file/FileAuthenticationService.java b/authentication/source/java/ch/systemsx/cisd/authentication/file/FileAuthenticationService.java index 28b4791bee50936cd863701e01983a7092e29bc4..38da1e6f54962238d7af27550c05828d729ff71a 100644 --- a/authentication/source/java/ch/systemsx/cisd/authentication/file/FileAuthenticationService.java +++ b/authentication/source/java/ch/systemsx/cisd/authentication/file/FileAuthenticationService.java @@ -68,6 +68,7 @@ public class FileAuthenticationService implements IAuthenticationService public FileAuthenticationService(IUserStore userStore) { this.userStore = userStore; + userStore.check(); } private String getToken() @@ -76,7 +77,7 @@ public class FileAuthenticationService implements IAuthenticationService } /** - * Returns the path of the password file, which we consider to be the token. + * Returns the id of the password store, which we consider to be the token. */ public String authenticateApplication() { @@ -102,7 +103,12 @@ public class FileAuthenticationService implements IAuthenticationService operationLog.warn(String.format(TOKEN_FAILURE_MSG_TEMPLATE, token, applicationToken)); return null; } - return userStore.tryGetUser(user).asPrincial(); + final UserEntry userOrNull = userStore.tryGetUser(user); + if (userOrNull == null) + { + throw new IllegalArgumentException("Cannot find user '" + user + "'."); + } + return userOrNull.asPrincial(); } public void check() throws EnvironmentFailureException, ConfigurationFailureException