From 8e9db1be96c6a166e06dad6cb620205fccb3275a Mon Sep 17 00:00:00 2001 From: Pulkit Gupta Date: Thu, 20 Oct 2016 13:36:25 +0530 Subject: [PATCH] fixed null pointer exception when principal is null --- .../org/keycloak/adapters/saml/CatalinaSamlSessionStore.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adapters/saml/tomcat/tomcat-core/src/main/java/org/keycloak/adapters/saml/CatalinaSamlSessionStore.java b/adapters/saml/tomcat/tomcat-core/src/main/java/org/keycloak/adapters/saml/CatalinaSamlSessionStore.java index d72bbfd59c..281dd5901f 100755 --- a/adapters/saml/tomcat/tomcat-core/src/main/java/org/keycloak/adapters/saml/CatalinaSamlSessionStore.java +++ b/adapters/saml/tomcat/tomcat-core/src/main/java/org/keycloak/adapters/saml/CatalinaSamlSessionStore.java @@ -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"); }