Search in sources :

Example 11 with SingleLogoutServiceElement

use of com.sun.identity.saml2.jaxb.metadata.SingleLogoutServiceElement in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method getStandardServiceProviderAttributes.

/**
     * Returns a map with standard service provider attributes and values.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @return Map with standard attribute values of Service Provider.
     * @throws AMConsoleException if unable to retrieve the Service Provider
     *     attrubutes based on the realm and entityName passed.
     */
public Map getStandardServiceProviderAttributes(String realm, String entityName) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "SP-Standard" };
    logEvent("ATTEMPT_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    Map map = new HashMap();
    SPSSODescriptorElement spssoDescriptor = null;
    try {
        SAML2MetaManager samlManager = getSAML2MetaManager();
        spssoDescriptor = samlManager.getSPSSODescriptor(realm, entityName);
        if (spssoDescriptor != null) {
            // retrieve WantAuthnRequestsSigned
            map.put(IS_AUTHN_REQ_SIGNED, returnEmptySetIfValueIsNull(spssoDescriptor.isAuthnRequestsSigned()));
            map.put(WANT_ASSERTIONS_SIGNED, returnEmptySetIfValueIsNull(spssoDescriptor.isWantAssertionsSigned()));
            //retrieve SingleLogoutService
            map.put(SP_SINGLE_LOGOUT_HTTP_LOCATION, Collections.EMPTY_SET);
            map.put(SP_SINGLE_LOGOUT_HTTP_RESP_LOCATION, Collections.EMPTY_SET);
            map.put(SP_SLO_POST_LOC, Collections.EMPTY_SET);
            map.put(SP_SLO_POST_RESPLOC, Collections.EMPTY_SET);
            map.put(SP_SINGLE_LOGOUT_SOAP_LOCATION, Collections.EMPTY_SET);
            map.put(SP_LOGOUT_DEFAULT, Collections.EMPTY_SET);
            List splogoutList = spssoDescriptor.getSingleLogoutService();
            for (int i = 0; i < splogoutList.size(); i++) {
                SingleLogoutServiceElement spslsElem = (SingleLogoutServiceElement) splogoutList.get(i);
                String tmp = spslsElem.getBinding();
                if (i == 0) {
                    map.put(SP_LOGOUT_DEFAULT, returnEmptySetIfValueIsNull(tmp));
                }
                if (tmp.contains(httpRedirect)) {
                    map.put(SP_SINGLE_LOGOUT_HTTP_LOCATION, returnEmptySetIfValueIsNull(spslsElem.getLocation()));
                    map.put(SP_SINGLE_LOGOUT_HTTP_RESP_LOCATION, returnEmptySetIfValueIsNull(spslsElem.getResponseLocation()));
                } else if (tmp.contains(httpPost)) {
                    map.put(SP_SLO_POST_LOC, returnEmptySetIfValueIsNull(spslsElem.getLocation()));
                    map.put(SP_SLO_POST_RESPLOC, returnEmptySetIfValueIsNull(spslsElem.getResponseLocation()));
                } else if (tmp.contains(soap)) {
                    map.put(SP_SINGLE_LOGOUT_SOAP_LOCATION, returnEmptySetIfValueIsNull(spslsElem.getLocation()));
                }
            }
            //retrieve ManageNameIDService
            map.put(SP_MANAGE_NAMEID_HTTP_LOCATION, Collections.EMPTY_SET);
            map.put(SP_MANAGE_NAMEID_HTTP_RESP_LOCATION, Collections.EMPTY_SET);
            map.put(SP_MNI_POST_LOC, Collections.EMPTY_SET);
            map.put(SP_MNI_POST_RESPLOC, Collections.EMPTY_SET);
            map.put(SP_MANAGE_NAMEID_SOAP_LOCATION, Collections.EMPTY_SET);
            map.put(SP_MANAGE_NAMEID_SOAP_RESP_LOCATION, Collections.EMPTY_SET);
            map.put(SP_MNI_DEFAULT, Collections.EMPTY_SET);
            List manageNameIdList = spssoDescriptor.getManageNameIDService();
            for (int i = 0; i < manageNameIdList.size(); i++) {
                ManageNameIDServiceElement mniElem = (ManageNameIDServiceElement) manageNameIdList.get(i);
                String tmp = mniElem.getBinding();
                if (i == 0) {
                    map.put(SP_MNI_DEFAULT, returnEmptySetIfValueIsNull(tmp));
                }
                if (tmp.contains(httpRedirect)) {
                    map.put(SP_MANAGE_NAMEID_HTTP_LOCATION, returnEmptySetIfValueIsNull(mniElem.getLocation()));
                    map.put(SP_MANAGE_NAMEID_HTTP_RESP_LOCATION, returnEmptySetIfValueIsNull(mniElem.getResponseLocation()));
                } else if (tmp.contains(httpPost)) {
                    map.put(SP_MNI_POST_LOC, returnEmptySetIfValueIsNull(mniElem.getLocation()));
                    map.put(SP_MNI_POST_RESPLOC, returnEmptySetIfValueIsNull(mniElem.getResponseLocation()));
                } else if (tmp.contains(soap)) {
                    map.put(SP_MANAGE_NAMEID_SOAP_LOCATION, returnEmptySetIfValueIsNull(mniElem.getLocation()));
                    map.put(SP_MANAGE_NAMEID_SOAP_RESP_LOCATION, returnEmptySetIfValueIsNull(mniElem.getResponseLocation()));
                }
            }
            //retrieve nameid format               
            map.put(NAMEID_FORMAT, (OrderedSet) convertListToSet(spssoDescriptor.getNameIDFormat()));
            //retrieve key descriptor encryption details if present
            map.put(TF_KEY_NAME, Collections.EMPTY_SET);
            map.put(TF_ALGORITHM, Collections.EMPTY_SET);
            if (spssoDescriptor.getKeyDescriptor() != null) {
                getKeyandAlgorithm(spssoDescriptor, map);
            }
        }
        logEvent("SUCCEED_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    } catch (SAML2MetaException e) {
        debug.warning("SAMLv2ModelImpl.getStandardServiceProviderAttribute:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "SP-Standard", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return map;
}
Also used : ManageNameIDServiceElement(com.sun.identity.saml2.jaxb.metadata.ManageNameIDServiceElement) SingleLogoutServiceElement(com.sun.identity.saml2.jaxb.metadata.SingleLogoutServiceElement) HashMap(java.util.HashMap) SPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement) List(java.util.List) ArrayList(java.util.ArrayList) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 12 with SingleLogoutServiceElement

use of com.sun.identity.saml2.jaxb.metadata.SingleLogoutServiceElement in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method savehttpRedLogout.

/**
     * Saves the Http-Redirect Single Logout Service.
     *
     * @param lohttpLocation is the location url.
     * @param lohttpRespLocation is the response location url.
     * @param logList the live list to be updated.
     * @param objFact the Object Factory class.
     * @throws JAXBException if save fails.
     */
private void savehttpRedLogout(String lohttpLocation, String lohttpRespLocation, List logList, com.sun.identity.saml2.jaxb.metadata.ObjectFactory objFact) throws JAXBException {
    if (lohttpLocation != null && lohttpLocation.length() > 0) {
        SingleLogoutServiceElement slsElemRed = objFact.createSingleLogoutServiceElement();
        slsElemRed.setBinding(httpRedirectBinding);
        slsElemRed.setLocation(lohttpLocation);
        slsElemRed.setResponseLocation(lohttpRespLocation);
        logList.add(slsElemRed);
    }
}
Also used : SingleLogoutServiceElement(com.sun.identity.saml2.jaxb.metadata.SingleLogoutServiceElement)

Example 13 with SingleLogoutServiceElement

use of com.sun.identity.saml2.jaxb.metadata.SingleLogoutServiceElement in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method savepostLogout.

/**
     * Saves the Post Single Logout Service.
     *
     * @param postLocation is the location url.
     * @param postRespLocation is the response location url.
     * @param logList the live list to be updated.
     * @param objFact the Object Factory class.
     * @throws JAXBException if save fails.
     */
private void savepostLogout(String postLocation, String postRespLocation, List logList, com.sun.identity.saml2.jaxb.metadata.ObjectFactory objFact) throws JAXBException {
    if (postLocation != null && postLocation.length() > 0) {
        SingleLogoutServiceElement slsElemPost = objFact.createSingleLogoutServiceElement();
        slsElemPost.setBinding(httpPostBinding);
        slsElemPost.setLocation(postLocation);
        slsElemPost.setResponseLocation(postRespLocation);
        logList.add(slsElemPost);
    }
}
Also used : SingleLogoutServiceElement(com.sun.identity.saml2.jaxb.metadata.SingleLogoutServiceElement)

Example 14 with SingleLogoutServiceElement

use of com.sun.identity.saml2.jaxb.metadata.SingleLogoutServiceElement in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method getStandardIdentityProviderAttributes.

/**
     * Returns a map with standard identity provider attributes and values.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @return Map with standard attribute values of Identity Provider.
     * @throws AMConsoleException if unable to retrieve the Identity Provider
     *     attrubutes based on the realm and entityName passed.
     */
public Map getStandardIdentityProviderAttributes(String realm, String entityName) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "IDP-Standard" };
    logEvent("ATTEMPT_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    Map map = new HashMap();
    IDPSSODescriptorElement idpssoDescriptor = null;
    try {
        SAML2MetaManager samlManager = getSAML2MetaManager();
        idpssoDescriptor = samlManager.getIDPSSODescriptor(realm, entityName);
        if (idpssoDescriptor != null) {
            // retrieve WantAuthnRequestsSigned
            map.put(WANT_AUTHN_REQ_SIGNED, returnEmptySetIfValueIsNull(idpssoDescriptor.isWantAuthnRequestsSigned()));
            //retrieve ArtifactResolutionService
            map.put(ART_RES_LOCATION, Collections.EMPTY_SET);
            map.put(ART_RES_INDEX, Collections.EMPTY_SET);
            map.put(ART_RES_ISDEFAULT, Collections.EMPTY_SET);
            List artList = idpssoDescriptor.getArtifactResolutionService();
            if (!artList.isEmpty()) {
                ArtifactResolutionServiceElement key = (ArtifactResolutionServiceElement) artList.get(0);
                map.put(ART_RES_LOCATION, returnEmptySetIfValueIsNull(key.getLocation()));
                map.put(ART_RES_INDEX, returnEmptySetIfValueIsNull(Integer.toString(key.getIndex())));
                map.put(ART_RES_ISDEFAULT, returnEmptySetIfValueIsNull(key.isIsDefault()));
            }
            //retrieve SingleLogoutService
            map.put(SINGLE_LOGOUT_HTTP_LOCATION, Collections.EMPTY_SET);
            map.put(SINGLE_LOGOUT_HTTP_RESP_LOCATION, Collections.EMPTY_SET);
            map.put(SLO_POST_LOC, Collections.EMPTY_SET);
            map.put(SLO_POST_RESPLOC, Collections.EMPTY_SET);
            map.put(SINGLE_LOGOUT_SOAP_LOCATION, Collections.EMPTY_SET);
            map.put(SINGLE_LOGOUT_DEFAULT, Collections.EMPTY_SET);
            List logoutList = idpssoDescriptor.getSingleLogoutService();
            for (int i = 0; i < logoutList.size(); i++) {
                SingleLogoutServiceElement spslsElem = (SingleLogoutServiceElement) logoutList.get(i);
                String tmp = spslsElem.getBinding();
                if (i == 0) {
                    map.put(SINGLE_LOGOUT_DEFAULT, returnEmptySetIfValueIsNull(tmp));
                }
                if (tmp.contains(httpRedirect)) {
                    map.put(SINGLE_LOGOUT_HTTP_LOCATION, returnEmptySetIfValueIsNull(spslsElem.getLocation()));
                    map.put(SINGLE_LOGOUT_HTTP_RESP_LOCATION, returnEmptySetIfValueIsNull(spslsElem.getResponseLocation()));
                } else if (tmp.contains(httpPost)) {
                    map.put(SLO_POST_LOC, returnEmptySetIfValueIsNull(spslsElem.getLocation()));
                    map.put(SLO_POST_RESPLOC, returnEmptySetIfValueIsNull(spslsElem.getResponseLocation()));
                } else if (tmp.contains(soap)) {
                    map.put(SINGLE_LOGOUT_SOAP_LOCATION, returnEmptySetIfValueIsNull(spslsElem.getLocation()));
                }
            }
            //retrieve ManageNameIDService
            map.put(MANAGE_NAMEID_HTTP_LOCATION, Collections.EMPTY_SET);
            map.put(MANAGE_NAMEID_HTTP_RESP_LOCATION, Collections.EMPTY_SET);
            map.put(MNI_POST_LOC, Collections.EMPTY_SET);
            map.put(MNI_POST_RESPLOC, Collections.EMPTY_SET);
            map.put(MANAGE_NAMEID_SOAP_LOCATION, Collections.EMPTY_SET);
            map.put(SINGLE_MANAGE_NAMEID_DEFAULT, Collections.EMPTY_SET);
            List manageNameIdList = idpssoDescriptor.getManageNameIDService();
            for (int i = 0; i < manageNameIdList.size(); i++) {
                ManageNameIDServiceElement mniElem = (ManageNameIDServiceElement) manageNameIdList.get(i);
                String tmp = mniElem.getBinding();
                if (i == 0) {
                    map.put(SINGLE_MANAGE_NAMEID_DEFAULT, returnEmptySetIfValueIsNull(tmp));
                }
                if (tmp.contains(httpRedirect)) {
                    map.put(MANAGE_NAMEID_HTTP_LOCATION, returnEmptySetIfValueIsNull(mniElem.getLocation()));
                    map.put(MANAGE_NAMEID_HTTP_RESP_LOCATION, returnEmptySetIfValueIsNull(mniElem.getResponseLocation()));
                } else if (tmp.contains(httpPost)) {
                    map.put(MNI_POST_LOC, returnEmptySetIfValueIsNull(mniElem.getLocation()));
                    map.put(MNI_POST_RESPLOC, returnEmptySetIfValueIsNull(mniElem.getResponseLocation()));
                } else if (tmp.contains(soap)) {
                    map.put(MANAGE_NAMEID_SOAP_LOCATION, returnEmptySetIfValueIsNull(mniElem.getLocation()));
                }
            }
            //retrieve nameid mapping service
            map.put(NAME_ID_MAPPPING, Collections.EMPTY_SET);
            List nameIDmappingList = idpssoDescriptor.getNameIDMappingService();
            if (!nameIDmappingList.isEmpty()) {
                NameIDMappingServiceElement namidElem1 = (NameIDMappingServiceElement) nameIDmappingList.get(0);
                map.put(NAME_ID_MAPPPING, returnEmptySetIfValueIsNull(namidElem1.getLocation()));
            }
            //retrieve nameid format
            map.put(NAMEID_FORMAT, (OrderedSet) convertListToSet(idpssoDescriptor.getNameIDFormat()));
            //retrieve single sign on service
            map.put(SINGLE_SIGNON_HTTP_LOCATION, Collections.EMPTY_SET);
            map.put(SINGLE_SIGNON_SOAP_LOCATION, Collections.EMPTY_SET);
            map.put(SSO_SOAPS_LOC, Collections.EMPTY_SET);
            List signonList = idpssoDescriptor.getSingleSignOnService();
            for (int i = 0; i < signonList.size(); i++) {
                SingleSignOnServiceElement signElem = (SingleSignOnServiceElement) signonList.get(i);
                String tmp = signElem.getBinding();
                if (tmp.contains(httpRedirect)) {
                    map.put(SINGLE_SIGNON_HTTP_LOCATION, returnEmptySetIfValueIsNull(signElem.getLocation()));
                } else if (tmp.contains(httpPost)) {
                    map.put(SINGLE_SIGNON_SOAP_LOCATION, returnEmptySetIfValueIsNull(signElem.getLocation()));
                } else if (tmp.contains(soap)) {
                    map.put(SSO_SOAPS_LOC, returnEmptySetIfValueIsNull(signElem.getLocation()));
                }
            }
            //retrieve key descriptor encryption details if present
            map.put(TF_KEY_NAME, Collections.EMPTY_SET);
            map.put(TF_ALGORITHM, Collections.EMPTY_SET);
            if (idpssoDescriptor.getKeyDescriptor() != null) {
                getKeyandAlgorithm(idpssoDescriptor, map);
            }
        }
        logEvent("SUCCEED_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", params);
    } catch (SAML2MetaException e) {
        debug.warning("SAMLv2ModelImpl.getIdentityProviderAttributes:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "IDP-Standard", strError };
        logEvent("FEDERATION_EXCEPTION_GET_ENTITY_DESCRIPTOR_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return map;
}
Also used : ManageNameIDServiceElement(com.sun.identity.saml2.jaxb.metadata.ManageNameIDServiceElement) HashMap(java.util.HashMap) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) SingleSignOnServiceElement(com.sun.identity.saml2.jaxb.metadata.SingleSignOnServiceElement) ArtifactResolutionServiceElement(com.sun.identity.saml2.jaxb.metadata.ArtifactResolutionServiceElement) NameIDMappingServiceElement(com.sun.identity.saml2.jaxb.metadata.NameIDMappingServiceElement) SingleLogoutServiceElement(com.sun.identity.saml2.jaxb.metadata.SingleLogoutServiceElement) List(java.util.List) ArrayList(java.util.ArrayList) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Map(java.util.Map) HashMap(java.util.HashMap) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) IDPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)

Example 15 with SingleLogoutServiceElement

use of com.sun.identity.saml2.jaxb.metadata.SingleLogoutServiceElement in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method savesoapLogout.

/**
     * Saves the Soap Single Logout Service.
     *
     * @param losoapLocation is the location url.
     * @param logList the live list to be updated.
     * @param objFact the Object Factory class.
     * @throws JAXBException if save fails.
     */
private void savesoapLogout(String losoapLocation, List logList, com.sun.identity.saml2.jaxb.metadata.ObjectFactory objFact) throws JAXBException {
    if (losoapLocation != null && losoapLocation.length() > 0) {
        SingleLogoutServiceElement slsElemSoap = objFact.createSingleLogoutServiceElement();
        slsElemSoap.setBinding(soapBinding);
        slsElemSoap.setLocation(losoapLocation);
        logList.add(slsElemSoap);
    }
}
Also used : SingleLogoutServiceElement(com.sun.identity.saml2.jaxb.metadata.SingleLogoutServiceElement)

Aggregations

SingleLogoutServiceElement (com.sun.identity.saml2.jaxb.metadata.SingleLogoutServiceElement)25 ArrayList (java.util.ArrayList)9 List (java.util.List)8 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)7 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)6 HashMap (java.util.HashMap)6 SessionException (com.sun.identity.plugin.session.SessionException)5 SAML2TokenRepositoryException (org.forgerock.openam.federation.saml2.SAML2TokenRepositoryException)5 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 Set (java.util.Set)4 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)3 IDPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)3 SPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement)3 LogoutResponse (com.sun.identity.saml2.protocol.LogoutResponse)3 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)2 SingleLogoutManager (com.sun.identity.multiprotocol.SingleLogoutManager)2 SessionProvider (com.sun.identity.plugin.session.SessionProvider)2