Search in sources :

Example 1 with SAMLv2AuthContexts

use of com.sun.identity.console.federation.SAMLv2AuthContexts in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method getSPAuthenticationContexts.

/**
     * Returns  the object of Auththentication Contexts in SP.
     *
     * @param realm Realm of Entity
     * @param entityName Name of Entity Descriptor.
     * @return SAMLv2AuthContexts contains SP authContexts values.
     * @throws AMConsoleException if unable to retrieve the SP
     *         Authentication Contexts
     */
public SAMLv2AuthContexts getSPAuthenticationContexts(String realm, String entityName) throws AMConsoleException {
    SAMLv2AuthContexts cxt = new SAMLv2AuthContexts();
    try {
        List tmpList = new ArrayList();
        SAML2MetaManager saml2MetaManager = getSAML2MetaManager();
        Map map = new HashMap();
        BaseConfigType spConfig = saml2MetaManager.getSPSSOConfig(realm, entityName);
        if (spConfig != null) {
            map = SAML2MetaUtils.getAttributes(spConfig);
        } else {
            throw new AMConsoleException("invalid.entity.name");
        }
        List list = (List) map.get(SP_AUTHN_CONTEXT_CLASS_REF_MAPPING);
        for (int i = 0; i < list.size(); i++) {
            String tmp = (String) list.get(i);
            int index = tmp.lastIndexOf("|");
            boolean isDefault = false;
            String defaultValue = tmp.substring(index + 1);
            if (defaultValue.equals("default")) {
                isDefault = true;
            }
            tmp = tmp.substring(0, index);
            index = tmp.indexOf("|");
            String level = tmp.substring(index + 1);
            String name = tmp.substring(0, index);
            cxt.put(name, "true", level, isDefault);
        }
    } catch (SAML2MetaException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (AMConsoleException e) {
        throw new AMConsoleException(getErrorString(e));
    }
    return (cxt != null) ? cxt : new SAMLv2AuthContexts();
}
Also used : BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) HashMap(java.util.HashMap) SAMLv2AuthContexts(com.sun.identity.console.federation.SAMLv2AuthContexts) ArrayList(java.util.ArrayList) 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 2 with SAMLv2AuthContexts

use of com.sun.identity.console.federation.SAMLv2AuthContexts in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method getIDPAuthenticationContexts.

/**
     * Returns the object of Auththentication Contexts in IDP.
     *
     * @param realm Realm of Entity
     * @param entityName Name of Entity Descriptor.
     * @return SAMLv2AuthContexts contains IDP authContexts values.
     * @throws AMConsoleException if unable to retrieve the IDP
     *         Authentication Contexts
     */
public SAMLv2AuthContexts getIDPAuthenticationContexts(String realm, String entityName) throws AMConsoleException {
    SAMLv2AuthContexts cxt = new SAMLv2AuthContexts();
    try {
        List tmpList = new ArrayList();
        SAML2MetaManager saml2MetaManager = getSAML2MetaManager();
        Map map = new HashMap();
        BaseConfigType idpConfig = saml2MetaManager.getIDPSSOConfig(realm, entityName);
        if (idpConfig != null) {
            map = SAML2MetaUtils.getAttributes(idpConfig);
        } else {
            throw new AMConsoleException("invalid.entity.name");
        }
        List list = (List) map.get(IDP_AUTHN_CONTEXT_CLASS_REF_MAPPING);
        for (int i = 0; i < list.size(); i++) {
            String tmp = (String) list.get(i);
            int index = tmp.lastIndexOf("|");
            boolean isDefault = false;
            String defaultValue = tmp.substring(index + 1);
            if (defaultValue.equals("default")) {
                isDefault = true;
            }
            tmp = tmp.substring(0, index);
            index = tmp.lastIndexOf("|");
            String authScheme = tmp.substring(index + 1);
            tmp = tmp.substring(0, index);
            index = tmp.indexOf("|");
            String level = tmp.substring(index + 1);
            String name = tmp.substring(0, index);
            cxt.put(name, "true", authScheme, level, isDefault);
        }
    } catch (SAML2MetaException e) {
        throw new AMConsoleException(getErrorString(e));
    } catch (AMConsoleException e) {
        throw new AMConsoleException(getErrorString(e));
    }
    return (cxt != null) ? cxt : new SAMLv2AuthContexts();
}
Also used : BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) HashMap(java.util.HashMap) SAMLv2AuthContexts(com.sun.identity.console.federation.SAMLv2AuthContexts) ArrayList(java.util.ArrayList) 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)

Aggregations

AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)2 SAMLv2AuthContexts (com.sun.identity.console.federation.SAMLv2AuthContexts)2 BaseConfigType (com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType)2 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)2 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2