NIHVIVO-2694 Make sure that the BasicAuthenticator and the AuthenticatorStub comply to the contract on throwing LoginNotPermitted exceptions.
This commit is contained in:
parent
19f9e10ffb
commit
78c19dde80
3 changed files with 12 additions and 2 deletions
|
@ -92,6 +92,9 @@ public abstract class Authenticator {
|
|||
* Behavior when userAccount is null depends on the particular
|
||||
* Authenticator. An answer of "true" presumably means that the user will be
|
||||
* permitted to login and create an account on the fly.
|
||||
*
|
||||
* Note that this method may rely on the HttpServletRequest object that was
|
||||
* provided to the factory when this instance was created.
|
||||
*/
|
||||
public abstract boolean isUserPermittedToLogin(UserAccount userAccount);
|
||||
|
||||
|
|
|
@ -142,7 +142,10 @@ public class BasicAuthenticator extends Authenticator {
|
|||
|
||||
@Override
|
||||
public void recordLoginAgainstUserAccount(UserAccount userAccount,
|
||||
AuthenticationSource authSource) {
|
||||
AuthenticationSource authSource) throws LoginNotPermitted {
|
||||
if (!isUserPermittedToLogin(userAccount)) {
|
||||
throw new LoginNotPermitted();
|
||||
}
|
||||
if (userAccount == null) {
|
||||
log.error("Trying to record the login of a null user. ");
|
||||
return;
|
||||
|
|
|
@ -137,7 +137,11 @@ public class AuthenticatorStub extends Authenticator {
|
|||
|
||||
@Override
|
||||
public void recordLoginAgainstUserAccount(UserAccount userAccount,
|
||||
AuthenticationSource authSource) {
|
||||
AuthenticationSource authSource) throws LoginNotPermitted {
|
||||
if (!isUserPermittedToLogin(userAccount)) {
|
||||
throw new LoginNotPermitted();
|
||||
}
|
||||
|
||||
recordedLogins.add(userAccount.getEmailAddress());
|
||||
|
||||
LoginStatusBean lsb = new LoginStatusBean(userAccount.getUri(),
|
||||
|
|
Loading…
Add table
Reference in a new issue