我正在创建LogoutRequest并使用以下代码设置ID,并收到如下所述的错误。 我还附上了完整的代码片段,以使内容更加清晰。 注意:-如果我未设置ID,则出现异常提示“不存在必需属性:ID”
Error :-
Exception details:
System.Xml.XmlException: ID4262: The SAML NameIdentifier 'username' is of format 'urn:oasis:names:tc:SAML:2.0:nameid-format:entity' and its value is not a valid URI.
I have tried with different SAML NameID Format :
A. urn:oasis:names:tc:SAML:2.0:nameid-format:transient
B. urn:oasis:names:tc:SAML:2.0:nameid-format:persistent
Complete code
LogoutRequest logoutReq = new LogoutRequestBuilder().buildObject();
String randId = UUID.randomUUID().toString();
logoutReq.setID(randId);
logoutReq.setDestination("logoutUrl");
DateTime issueInstant = new DateTime();
logoutReq.setIssueInstant(issueInstant);
logoutReq.setNotOnOrAfter(new DateTime(issueInstant.getMillis() + 300000L));
//Setting issuer
IssuerBuilder issuerBuilder = new IssuerBuilder();
Issuer issuer = issuerBuilder.buildObject();
issuer.setValue("requestEntityID");
logoutReq.setIssuer(issuer);
NameID nameId = new NameIDBuilder().buildObject();
nameId.setFormat("urn:oasis:names:tc:SAML:2.0:nameid-format:entity");
nameId.setValue("userName");
logoutReq.setNameID(nameId);
SessionIndex sessionIndex = new SessionIndexBuilder().buildObject();
sessionIndex.setSessionIndex("idpSessionIndex");
logoutReq.getSessionIndexes().add(sessionIndex);
logoutReq.setReason("Single Logout");