Search in sources :

Example 91 with SAML2MetaException

use of com.sun.identity.saml2.meta.SAML2MetaException 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 92 with SAML2MetaException

use of com.sun.identity.saml2.meta.SAML2MetaException in project OpenAM by OpenRock.

the class SAMLv2ModelImpl method setExtAttributeQueryValues.

/**
     * Saves the extended attribute values for Attribute Query.
     *
     * @param realm to which the entity belongs.
     * @param entityName is the entity id.
     * @param attrQueryExtValues Map which contains the extended values.
     * @param location has the information whether remote or hosted.
     * @throws AMConsoleException if saving of attribute value fails.
     */
public void setExtAttributeQueryValues(String realm, String entityName, Map attrQueryExtValues, String location) throws AMConsoleException {
    String[] params = { realm, entityName, "SAMLv2", "AttribQuery-Ext" };
    logEvent("ATTEMPT_MODIFY_ATTR_QUERY_ATTR_VALUES", params);
    String role = EntityModel.SAML_ATTRQUERY;
    try {
        SAML2MetaManager samlManager = getSAML2MetaManager();
        //entityConfig is the extended entity configuration object
        EntityConfigElement entityConfig = samlManager.getEntityConfig(realm, entityName);
        //for remote cases
        if (entityConfig == null) {
            createExtendedObject(realm, entityName, location, role);
            entityConfig = samlManager.getEntityConfig(realm, entityName);
        }
        AttributeQueryConfigElement attrQueryConfig = samlManager.getAttributeQueryConfig(realm, entityName);
        if (attrQueryConfig != null) {
            updateBaseConfig(attrQueryConfig, attrQueryExtValues, role);
        }
        //saves the attributes by passing the new entityConfig object
        samlManager.setEntityConfig(realm, entityConfig);
        logEvent("SUCCEED_MODIFY_ATTR_QUERY_ATTR_VALUES", params);
    } catch (SAML2MetaException e) {
        debug.error("SAMLv2ModelImpl.setExtAttributeQueryValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribQuery-Ext", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ATTR_QUERY_ATTR_VALUES", paramsEx);
    } catch (JAXBException e) {
        debug.error("SAMLv2ModelImpl.setExtAttributeQueryValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribQuery-Extended", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ATTR_QUERY_ATTR_VALUES", paramsEx);
    } catch (AMConsoleException e) {
        debug.error("SAMLv2ModelImpl.setExtAttributeQueryValues:", e);
        String strError = getErrorString(e);
        String[] paramsEx = { realm, entityName, "SAMLv2", "AttribQuery-Ext", strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_ATTR_QUERY_ATTR_VALUES", paramsEx);
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) AttributeQueryConfigElement(com.sun.identity.saml2.jaxb.entityconfig.AttributeQueryConfigElement) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 93 with SAML2MetaException

use of com.sun.identity.saml2.meta.SAML2MetaException 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)

Example 94 with SAML2MetaException

use of com.sun.identity.saml2.meta.SAML2MetaException in project OpenAM by OpenRock.

the class SAML2Test method deleteEntity.

@Test(groups = { "samlv2", "samlv2op" }, dependsOnMethods = { "removeProviderFromCircleOfTrust" })
public void deleteEntity() throws CLIException, SAML2MetaException {
    entering("deleteEntity", null);
    String[] args = { "delete-entity", CLIConstants.PREFIX_ARGUMENT_LONG + FedCLIConstants.ARGUMENT_ENTITY_ID, NAME_IDP, CLIConstants.PREFIX_ARGUMENT_LONG + FedCLIConstants.SPECIFICATION_VERSION, FedCLIConstants.SAML2_SPECIFICATION };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    SAML2MetaManager mgr = new SAML2MetaManager();
    EntityDescriptorElement entity = mgr.getEntityDescriptor("/", NAME_IDP);
    assert (entity == null);
    exiting("deleteEntity");
}
Also used : CLIRequest(com.sun.identity.cli.CLIRequest) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 95 with SAML2MetaException

use of com.sun.identity.saml2.meta.SAML2MetaException in project OpenAM by OpenRock.

the class SAML2Test method importEntity.

@Test(groups = { "samlv2", "samlv2op" }, dependsOnMethods = { "createMetaTemplate" })
public void importEntity() throws CLIException, SAML2MetaException {
    entering("importEntity", null);
    String[] args = { "import-entity", CLIConstants.PREFIX_ARGUMENT_LONG + FedCLIConstants.ARGUMENT_METADATA, "meta", CLIConstants.PREFIX_ARGUMENT_LONG + FedCLIConstants.ARGUMENT_EXTENDED_DATA, "extended", CLIConstants.PREFIX_ARGUMENT_LONG + FedCLIConstants.ARGUMENT_COT, NAME_COT, CLIConstants.PREFIX_ARGUMENT_LONG + FedCLIConstants.SPECIFICATION_VERSION, FedCLIConstants.SAML2_SPECIFICATION };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    SAML2MetaManager mgr = new SAML2MetaManager();
    EntityDescriptorElement entity = mgr.getEntityDescriptor("/", NAME_IDP);
    assert (entity != null);
    SPSSODescriptorElement spElt = mgr.getSPSSODescriptor("/", NAME_IDP);
    assert (spElt != null);
    IDPSSODescriptorElement idpElt = mgr.getIDPSSODescriptor("/", NAME_IDP);
    assert (idpElt != null);
    XACMLPDPDescriptorElement pdpElt = mgr.getPolicyDecisionPointDescriptor("/", NAME_IDP);
    assert (pdpElt != null);
    XACMLAuthzDecisionQueryDescriptorElement pepElt = mgr.getPolicyEnforcementPointDescriptor("/", NAME_IDP);
    assert (pepElt != null);
    IDPSSOConfigElement idpConfig = mgr.getIDPSSOConfig("/", NAME_IDP);
    assert (idpConfig != null);
    SPSSOConfigElement spConfig = mgr.getSPSSOConfig("/", NAME_IDP);
    assert (spConfig != null);
    XACMLPDPConfigElement pdpConfig = mgr.getPolicyDecisionPointConfig("/", NAME_IDP);
    assert (pdpConfig != null);
    XACMLAuthzDecisionQueryConfigElement pepConfig = mgr.getPolicyEnforcementPointConfig("/", NAME_IDP);
    assert (pepConfig != null);
    exiting("importEntity");
}
Also used : SPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement) XACMLPDPDescriptorElement(com.sun.identity.saml2.jaxb.metadata.XACMLPDPDescriptorElement) SPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement) CLIRequest(com.sun.identity.cli.CLIRequest) XACMLPDPConfigElement(com.sun.identity.saml2.jaxb.entityconfig.XACMLPDPConfigElement) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) XACMLAuthzDecisionQueryConfigElement(com.sun.identity.saml2.jaxb.entityconfig.XACMLAuthzDecisionQueryConfigElement) XACMLAuthzDecisionQueryDescriptorElement(com.sun.identity.saml2.jaxb.metadata.XACMLAuthzDecisionQueryDescriptorElement) IDPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)138 List (java.util.List)106 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)90 ArrayList (java.util.ArrayList)80 Iterator (java.util.Iterator)55 Map (java.util.Map)50 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)47 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)44 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)43 HashMap (java.util.HashMap)41 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)30 BaseConfigType (com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType)29 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)28 JAXBException (javax.xml.bind.JAXBException)28 SPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement)26 IDPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)24 IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)23 Set (java.util.Set)20 IOException (java.io.IOException)15 HashSet (java.util.HashSet)15