Skip to content
Snippets Groups Projects
Commit bf23c512 authored by brinn's avatar brinn
Browse files

LMS-327

change:
- add call to userStore.check() to the constructor
- throw an IllegalArgumentException if information about a user cannot be obtained from the store

SVN: 5510
parent fbc7bcdc
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment