KEYCLOAK-5254 Fix NPE - NameID format is optional
This commit is contained in:
parent
685acb786a
commit
9098105a64
2 changed files with 9 additions and 5 deletions
|
@ -85,18 +85,20 @@ public class SAML2LogoutRequestBuilder implements SamlProtocolExtensionsAwareBui
|
||||||
}
|
}
|
||||||
|
|
||||||
public Document buildDocument() throws ProcessingException, ConfigurationException, ParsingException {
|
public Document buildDocument() throws ProcessingException, ConfigurationException, ParsingException {
|
||||||
Document document = new SAML2Request().convert(createLogoutRequest());
|
Document document = SAML2Request.convert(createLogoutRequest());
|
||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LogoutRequestType createLogoutRequest() throws ConfigurationException {
|
private LogoutRequestType createLogoutRequest() throws ConfigurationException {
|
||||||
LogoutRequestType lort = new SAML2Request().createLogoutRequest(issuer);
|
LogoutRequestType lort = SAML2Request.createLogoutRequest(issuer);
|
||||||
|
|
||||||
NameIDType nameID = new NameIDType();
|
NameIDType nameID = new NameIDType();
|
||||||
nameID.setValue(userPrincipal);
|
nameID.setValue(userPrincipal);
|
||||||
//Deal with NameID Format
|
//Deal with NameID Format
|
||||||
String nameIDFormat = userPrincipalFormat;
|
String nameIDFormat = userPrincipalFormat;
|
||||||
|
if (nameIDFormat != null) {
|
||||||
nameID.setFormat(URI.create(nameIDFormat));
|
nameID.setFormat(URI.create(nameIDFormat));
|
||||||
|
}
|
||||||
lort.setNameID(nameID);
|
lort.setNameID(nameID);
|
||||||
|
|
||||||
if (issuer != null) {
|
if (issuer != null) {
|
||||||
|
|
|
@ -99,8 +99,10 @@ public class CreateLogoutRequestStepBuilder extends SamlDocumentStepBuilder<Logo
|
||||||
.issuer(issuer)
|
.issuer(issuer)
|
||||||
.sessionIndex(sessionIndex());
|
.sessionIndex(sessionIndex());
|
||||||
|
|
||||||
if (nameId() != null) {
|
final NameIDType nameIdValue = nameId();
|
||||||
builder = builder.userPrincipal(nameId().getValue(), nameId().getFormat().toString());
|
|
||||||
|
if (nameIdValue != null) {
|
||||||
|
builder = builder.userPrincipal(nameIdValue.getValue(), nameIdValue.getFormat() == null ? null : nameIdValue.getFormat().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
String documentAsString = DocumentUtil.getDocumentAsString(builder.buildDocument());
|
String documentAsString = DocumentUtil.getDocumentAsString(builder.buildDocument());
|
||||||
|
|
Loading…
Reference in a new issue