Java Code Examples for org.opensaml.saml2.core.LogoutRequest#setNotOnOrAfter()
The following examples show how to use
org.opensaml.saml2.core.LogoutRequest#setNotOnOrAfter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogoutRequestUnmarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException { LogoutRequest req = (LogoutRequest) samlObject; if (attribute.getLocalName().equals(LogoutRequest.REASON_ATTRIB_NAME)) { req.setReason(attribute.getValue()); } else if (attribute.getLocalName().equals(LogoutRequest.NOT_ON_OR_AFTER_ATTRIB_NAME) && !DatatypeHelper.isEmpty(attribute.getValue())) { req.setNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC())); } else { super.processAttribute(samlObject, attribute); } }
Example 2
Source File: LogoutRequestBuilder.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * Build the logout request * * @param subject name of the user * @param reason reason for generating logout request. * @return LogoutRequest object * @throws Exception */ public LogoutRequest buildLogoutRequest(String subject, String reason, String sessionIndexStr) throws Exception { log.info("Building logout request"); Util.doBootstrap(); LogoutRequest logoutReq = new org.opensaml.saml2.core.impl.LogoutRequestBuilder().buildObject(); logoutReq.setID(Util.createID()); logoutReq.setDestination(Util.getIdentityProviderSSOServiceURL()); DateTime issueInstant = new DateTime(); logoutReq.setIssueInstant(issueInstant); logoutReq.setNotOnOrAfter(new DateTime(issueInstant.getMillis() + 5 * 60 * 1000)); IssuerBuilder issuerBuilder = new IssuerBuilder(); Issuer issuer = issuerBuilder.buildObject(); issuer.setValue(Util.getServiceProviderId()); logoutReq.setIssuer(issuer); NameID nameId = new NameIDBuilder().buildObject(); nameId.setFormat(SAML2SSOAuthenticatorConstants.SAML2_NAME_ID_POLICY_TRANSIENT); nameId.setValue(subject); logoutReq.setNameID(nameId); SessionIndex sessionIndex = new SessionIndexBuilder().buildObject(); sessionIndex.setSessionIndex(sessionIndexStr); logoutReq.getSessionIndexes().add(sessionIndex); logoutReq.setReason(reason); Util.setSignature(logoutReq, XMLSignature.ALGO_ID_SIGNATURE_RSA, new SignKeyDataHolder()); return logoutReq; }
Example 3
Source File: SAML2SSOManager.java From carbon-identity with Apache License 2.0 | 5 votes |
protected LogoutRequest buildLogoutRequest(String user, String sessionIdx) throws SSOAgentException { LogoutRequest logoutReq = new LogoutRequestBuilder().buildObject(); logoutReq.setID(SSOAgentUtils.createID()); logoutReq.setDestination(ssoAgentConfig.getSAML2().getIdPURL()); DateTime issueInstant = new DateTime(); logoutReq.setIssueInstant(issueInstant); logoutReq.setNotOnOrAfter(new DateTime(issueInstant.getMillis() + 5 * 60 * 1000)); IssuerBuilder issuerBuilder = new IssuerBuilder(); Issuer issuer = issuerBuilder.buildObject(); issuer.setValue(ssoAgentConfig.getSAML2().getSPEntityId()); logoutReq.setIssuer(issuer); NameID nameId = new NameIDBuilder().buildObject(); nameId.setFormat("urn:oasis:names:tc:SAML:2.0:nameid-format:entity"); nameId.setValue(user); logoutReq.setNameID(nameId); SessionIndex sessionIndex = new SessionIndexBuilder().buildObject(); sessionIndex.setSessionIndex(sessionIdx); logoutReq.getSessionIndexes().add(sessionIndex); logoutReq.setReason("Single Logout"); return logoutReq; }
Example 4
Source File: LogoutRequestBuilder.java From carbon-commons with Apache License 2.0 | 5 votes |
/** * Build the logout request * @param subject name of the user * @param reason reason for generating logout request. * @return LogoutRequest object */ public LogoutRequest buildLogoutRequest(String subject,String sessionIndexId, String reason, String issuerId) { Util.doBootstrap(); LogoutRequest logoutReq = new org.opensaml.saml2.core.impl.LogoutRequestBuilder().buildObject(); logoutReq.setID(Util.createID()); DateTime issueInstant = new DateTime(); logoutReq.setIssueInstant(issueInstant); logoutReq.setNotOnOrAfter(new DateTime(issueInstant.getMillis() + 5 * 60 * 1000)); IssuerBuilder issuerBuilder = new IssuerBuilder(); Issuer issuer = issuerBuilder.buildObject(); issuer.setValue(issuerId); logoutReq.setIssuer(issuer); NameID nameId = new NameIDBuilder().buildObject(); nameId.setFormat(SSOConstants.SAML2_NAME_ID_POLICY); nameId.setValue(subject); logoutReq.setNameID(nameId); SessionIndex sessionIndex = new SessionIndexBuilder().buildObject(); sessionIndex.setSessionIndex(sessionIndexId); logoutReq.getSessionIndexes().add(sessionIndex); logoutReq.setReason(reason); return logoutReq; }
Example 5
Source File: DefaultSAML2SSOManager.java From carbon-identity with Apache License 2.0 | 4 votes |
private LogoutRequest buildLogoutRequest(String user, String sessionIndexStr, String idpUrl, String nameQualifier, String spNameQualifier) throws SAMLSSOException { LogoutRequest logoutReq = new LogoutRequestBuilder().buildObject(); logoutReq.setID(SSOUtils.createID()); logoutReq.setDestination(idpUrl); DateTime issueInstant = new DateTime(); logoutReq.setIssueInstant(issueInstant); logoutReq.setNotOnOrAfter(new DateTime(issueInstant.getMillis() + 5 * 60 * 1000)); IssuerBuilder issuerBuilder = new IssuerBuilder(); Issuer issuer = issuerBuilder.buildObject(); String spEntityId = properties.get(IdentityApplicationConstants.Authenticator.SAML2SSO.SP_ENTITY_ID); if (spEntityId != null && !spEntityId.isEmpty()) { issuer.setValue(spEntityId); } else { issuer.setValue("carbonServer"); } logoutReq.setIssuer(issuer); NameID nameId = new NameIDBuilder().buildObject(); nameId.setFormat(NameIDType.UNSPECIFIED); nameId.setValue(user); nameId.setNameQualifier(nameQualifier); nameId.setSPNameQualifier(spNameQualifier); logoutReq.setNameID(nameId); SessionIndex sessionIndex = new SessionIndexBuilder().buildObject(); if (sessionIndexStr != null) { sessionIndex.setSessionIndex(sessionIndexStr); } else { sessionIndex.setSessionIndex(UUID.randomUUID().toString()); } logoutReq.getSessionIndexes().add(sessionIndex); logoutReq.setReason("Single Logout"); return logoutReq; }
Example 6
Source File: SingleLogoutMessageBuilder.java From carbon-identity with Apache License 2.0 | 4 votes |
public LogoutRequest buildLogoutRequest(String subject, String sessionId, String reason, String destination, String nameIDFormat, String tenantDomain, String requestsigningAlgorithmUri, String requestDigestAlgoUri) throws IdentityException { LogoutRequest logoutReq = new LogoutRequestBuilder().buildObject(); logoutReq.setID(SAMLSSOUtil.createID()); DateTime issueInstant = new DateTime(); logoutReq.setIssueInstant(issueInstant); logoutReq.setIssuer(SAMLSSOUtil.getIssuerFromTenantDomain(tenantDomain)); logoutReq.setNotOnOrAfter(new DateTime(issueInstant.getMillis() + 5 * 60 * 1000)); NameID nameId = new NameIDBuilder().buildObject(); nameId.setFormat(nameIDFormat); nameId.setValue(subject); logoutReq.setNameID(nameId); SessionIndex sessionIndex = new SessionIndexBuilder().buildObject(); sessionIndex.setSessionIndex(sessionId); logoutReq.getSessionIndexes().add(sessionIndex); if (destination != null) { logoutReq.setDestination(destination); } logoutReq.setReason(reason); int tenantId; if (StringUtils.isEmpty(tenantDomain) || "null".equals(tenantDomain)) { tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; tenantId = MultitenantConstants.SUPER_TENANT_ID; } else { try { tenantId = SAMLSSOUtil.getRealmService().getTenantManager().getTenantId(tenantDomain); } catch (UserStoreException e) { throw IdentityException.error("Error occurred while retrieving tenant id from tenant domain", e); } if(MultitenantConstants.INVALID_TENANT_ID == tenantId) { throw IdentityException.error("Invalid tenant domain - '" + tenantDomain + "'" ); } } try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId); SAMLSSOUtil.setSignature(logoutReq, requestsigningAlgorithmUri, requestDigestAlgoUri, new SignKeyDataHolder(null)); } finally { PrivilegedCarbonContext.endTenantFlow(); } return logoutReq; }