use of com.sun.identity.saml2.jaxb.metadata.EndpointType in project OpenAM by OpenRock.
the class SAML2PostAuthenticationPlugin method createLogoutRequest.
private LogoutRequest createLogoutRequest(String metaAlias, String realm, String idpEntityId, EndpointType logoutEndpoint, NameID nameId, String sessionIndex) throws SAML2Exception, SessionException {
// generate unique request ID
final String requestID = SAML2Utils.generateID();
if ((requestID == null) || (requestID.length() == 0)) {
DEBUG.warning("SAML2 PAP :: Unable to perform single logout, unable to generate request ID - {}", SAML2Utils.bundle.getString("cannotGenerateID"));
throw new SAML2Exception(SAML2Utils.BUNDLE_NAME, "cannotGenerateID", new Object[0]);
}
final String spEntityID = META_MANAGER.getEntityByMetaAlias(metaAlias);
final Issuer issuer = SAML2Utils.createIssuer(spEntityID);
final LogoutRequest logoutReq = ProtocolFactory.getInstance().createLogoutRequest();
logoutReq.setID(requestID);
logoutReq.setVersion(SAML2Constants.VERSION_2_0);
logoutReq.setIssueInstant(new Date());
logoutReq.setIssuer(issuer);
if (sessionIndex != null) {
logoutReq.setSessionIndex(Collections.singletonList(sessionIndex));
}
String location = logoutEndpoint.getLocation();
logoutReq.setDestination(XMLUtils.escapeSpecialCharacters(location));
LogoutUtil.setNameIDForSLORequest(logoutReq, nameId, realm, spEntityID, SAML2Constants.SP_ROLE, idpEntityId);
return logoutReq;
}
use of com.sun.identity.saml2.jaxb.metadata.EndpointType in project OpenAM by OpenRock.
the class SPSessionListener method initiateSPSingleLogout.
/**
* Performs an SP initiated SLO against the remote IdP using SOAP binding.
*
* @param metaAlias SP meta alias
* @param realm Realm
* @param binding Binding used
* @param nameIdInfoKey the nameIdInfoKey
* @param fedSession SP Federated session
* @param paramsMap parameters map
* @throws SAML2MetaException If there was an error while retrieving the metadata.
* @throws SAML2Exception If there was an error while initiating SLO.
* @throws SessionException If there was a problem with the session.
*/
private static void initiateSPSingleLogout(String metaAlias, String realm, String binding, NameIDInfoKey nameIdInfoKey, SPFedSession fedSession, Map paramsMap) throws SAML2MetaException, SAML2Exception, SessionException {
IDPSSODescriptorElement idpsso = sm.getIDPSSODescriptor(realm, nameIdInfoKey.getRemoteEntityID());
if (idpsso == null) {
String[] data = { nameIdInfoKey.getRemoteEntityID() };
LogUtil.error(Level.INFO, LogUtil.IDP_METADATA_ERROR, data, null);
throw new SAML2Exception(SAML2Utils.bundle.getString("metaDataError"));
}
List<EndpointType> slosList = idpsso.getSingleLogoutService();
String location = LogoutUtil.getSLOServiceLocation(slosList, SAML2Constants.SOAP);
if (location == null) {
if (debug.warningEnabled()) {
debug.warning("SPSessionListener.initiateSPSingleLogout(): Unable to synchronize sessions with IdP \"" + nameIdInfoKey.getRemoteEntityID() + "\" since the IdP does not have SOAP SLO endpoint " + "specified in its metadata, possibly this is a misconfiguration of the hosted SP");
}
return;
}
IDPSSOConfigElement idpConfig = sm.getIDPSSOConfig(realm, nameIdInfoKey.getRemoteEntityID());
LogoutUtil.doLogout(metaAlias, nameIdInfoKey.getRemoteEntityID(), slosList, null, binding, null, fedSession.idpSessionIndex, fedSession.info.getNameID(), null, null, paramsMap, idpConfig);
}
Aggregations