Added null check when adding credentials to Set (#2649)

Added null check when adding credentials to Set returned from getPrivateCredentials().  Fixes #2648

Signed-off-by: Sean Kavanagh <sean.p.kavanagh6@gmail.com>
This commit is contained in:
Sean Kavanagh 2018-06-11 18:39:21 -04:00 committed by Olivier Lamy
parent eed55854e5
commit 83b2abebb7
1 changed files with 6 additions and 2 deletions

View File

@ -86,14 +86,18 @@ public abstract class AbstractLoginModule implements LoginModule
public void setJAASInfo (Subject subject)
{
subject.getPrincipals().add(this.principal);
subject.getPrivateCredentials().add(this.user.getCredential());
if (this.user.getCredential() != null) {
subject.getPrivateCredentials().add(this.user.getCredential());
}
subject.getPrincipals().addAll(roles);
}
public void unsetJAASInfo (Subject subject)
{
subject.getPrincipals().remove(this.principal);
subject.getPrivateCredentials().remove(this.user.getCredential());
if (this.user.getCredential() != null) {
subject.getPrivateCredentials().remove(this.user.getCredential());
}
subject.getPrincipals().removeAll(this.roles);
}