Search in sources :

Example 6 with EndpointType

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;
}
Also used : SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) Issuer(com.sun.identity.saml2.assertion.Issuer) LogoutRequest(com.sun.identity.saml2.protocol.LogoutRequest) Date(java.util.Date)

Example 7 with EndpointType

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);
}
Also used : SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) EndpointType(com.sun.identity.saml2.jaxb.metadata.EndpointType) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) IDPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)

Aggregations

EndpointType (com.sun.identity.saml2.jaxb.metadata.EndpointType)5 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)4 IDPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)3 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)3 LogoutRequest (com.sun.identity.saml2.protocol.LogoutRequest)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Issuer (com.sun.identity.saml2.assertion.Issuer)2 SPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement)2 Date (java.util.Date)2 Iterator (java.util.Iterator)2 SessionException (com.sun.identity.plugin.session.SessionException)1 IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)1 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)1 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)1 Extensions (com.sun.identity.saml2.protocol.Extensions)1 IOException (java.io.IOException)1 SOAPException (javax.xml.soap.SOAPException)1 SAML2TokenRepositoryException (org.forgerock.openam.federation.saml2.SAML2TokenRepositoryException)1