fixed null pointer exception when principal is null

This commit is contained in:
Pulkit Gupta 2016-10-20 13:36:25 +05:30
parent 9f5acccc4f
commit 8e9db1be96

View file

@ -153,14 +153,14 @@ public class CatalinaSamlSessionStore implements SamlSessionStore {
}
GenericPrincipal principal = (GenericPrincipal) session.getPrincipal();
if (samlSession.getPrincipal().getName().equals(principal.getName()))
// in clustered environment in JBossWeb, principal is not serialized or saved
if (principal == null) {
principal = principalFactory.createPrincipal(request.getContext().getRealm(), samlSession.getPrincipal(), samlSession.getRoles());
session.setPrincipal(principal);
session.setAuthType("KEYCLOAK-SAML");
} else {
}
else if (samlSession.getPrincipal().getName().equals(principal.getName())){
if (!principal.getUserPrincipal().getName().equals(samlSession.getPrincipal().getName())) {
throw new RuntimeException("Unknown State");
}