From 9098105a6499fd9528fe00f3babfebfd33d9f2b5 Mon Sep 17 00:00:00 2001 From: Hynek Mlnarik Date: Thu, 14 Sep 2017 14:59:05 +0200 Subject: [PATCH] KEYCLOAK-5254 Fix NPE - NameID format is optional --- .../java/org/keycloak/saml/SAML2LogoutRequestBuilder.java | 8 +++++--- .../util/saml/CreateLogoutRequestStepBuilder.java | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/saml-core/src/main/java/org/keycloak/saml/SAML2LogoutRequestBuilder.java b/saml-core/src/main/java/org/keycloak/saml/SAML2LogoutRequestBuilder.java index d0e81ba49b..b1cd113e09 100755 --- a/saml-core/src/main/java/org/keycloak/saml/SAML2LogoutRequestBuilder.java +++ b/saml-core/src/main/java/org/keycloak/saml/SAML2LogoutRequestBuilder.java @@ -85,18 +85,20 @@ public class SAML2LogoutRequestBuilder implements SamlProtocolExtensionsAwareBui } public Document buildDocument() throws ProcessingException, ConfigurationException, ParsingException { - Document document = new SAML2Request().convert(createLogoutRequest()); + Document document = SAML2Request.convert(createLogoutRequest()); return document; } private LogoutRequestType createLogoutRequest() throws ConfigurationException { - LogoutRequestType lort = new SAML2Request().createLogoutRequest(issuer); + LogoutRequestType lort = SAML2Request.createLogoutRequest(issuer); NameIDType nameID = new NameIDType(); nameID.setValue(userPrincipal); //Deal with NameID Format String nameIDFormat = userPrincipalFormat; - nameID.setFormat(URI.create(nameIDFormat)); + if (nameIDFormat != null) { + nameID.setFormat(URI.create(nameIDFormat)); + } lort.setNameID(nameID); if (issuer != null) { diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/saml/CreateLogoutRequestStepBuilder.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/saml/CreateLogoutRequestStepBuilder.java index ee594d0a22..ceeb5fbbb4 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/saml/CreateLogoutRequestStepBuilder.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/saml/CreateLogoutRequestStepBuilder.java @@ -99,8 +99,10 @@ public class CreateLogoutRequestStepBuilder extends SamlDocumentStepBuilder