Search in sources :

Example 21 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class SAML2MetaManager method getIDPSSOConfig.

/**
     * Returns first identity provider's SSO configuration in an entity under
     * the realm.
     * @param realm The realm under which the entity resides.
     * @param entityId ID of the entity to be retrieved.
     * @return <code>IDPSSOConfigElement</code> for the entity or null if not
     *         found.
     * @throws SAML2MetaException if unable to retrieve the first identity
     *                            provider's SSO configuration.
     */
public IDPSSOConfigElement getIDPSSOConfig(String realm, String entityId) throws SAML2MetaException {
    EntityConfigElement eConfig = getEntityConfig(realm, entityId);
    if (eConfig == null) {
        return null;
    }
    List list = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
    for (Iterator iter = list.iterator(); iter.hasNext(); ) {
        Object obj = iter.next();
        if (obj instanceof IDPSSOConfigElement) {
            return (IDPSSOConfigElement) obj;
        }
    }
    return null;
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 22 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class SAML2MetaManager method getPolicyDecisionPointConfig.

/**
     * Returns first policy decision point configuration in an entity under
     * the realm.
     * @param realm The realm under which the entity resides.
     * @param entityId ID of the entity to be retrieved.
     * @return policy decision point configuration or null if it is not found.
     * @throws SAML2MetaException if unable to retrieve the configuration.
     */
public XACMLPDPConfigElement getPolicyDecisionPointConfig(String realm, String entityId) throws SAML2MetaException {
    XACMLPDPConfigElement elm = null;
    EntityConfigElement eConfig = getEntityConfig(realm, entityId);
    if (eConfig != null) {
        List list = eConfig.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
        for (Iterator i = list.iterator(); i.hasNext() && (elm == null); ) {
            Object obj = i.next();
            if (obj instanceof XACMLPDPConfigElement) {
                elm = (XACMLPDPConfigElement) obj;
            }
        }
    }
    return elm;
}
Also used : Iterator(java.util.Iterator) XACMLPDPConfigElement(com.sun.identity.saml2.jaxb.entityconfig.XACMLPDPConfigElement) ArrayList(java.util.ArrayList) List(java.util.List) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 23 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class ConfigureGoogleApps method updateIDPMeta.

private void updateIDPMeta(String realm, String entityId) throws WorkflowException {
    try {
        SAML2MetaManager samlManager = new SAML2MetaManager();
        EntityConfigElement entityConfig = samlManager.getEntityConfig(realm, entityId);
        IDPSSOConfigElement idpssoConfig = samlManager.getIDPSSOConfig(realm, entityId);
        List attrList = idpssoConfig.getAttribute();
        if (idpssoConfig != null) {
            for (Iterator it = attrList.iterator(); it.hasNext(); ) {
                AttributeElement avpnew = (AttributeElement) it.next();
                String name = avpnew.getName();
                if (name.equals("nameIDFormatMap")) {
                    for (Iterator itt = avpnew.getValue().listIterator(); itt.hasNext(); ) {
                        String temp = (String) itt.next();
                        if (temp.contains("unspecified")) {
                            itt.remove();
                        }
                    }
                    avpnew.getValue().add(0, nameidMapping);
                }
            }
        }
        samlManager.setEntityConfig(realm, entityConfig);
    } catch (SAML2MetaException e) {
        throw new WorkflowException(e.getMessage());
    }
}
Also used : Iterator(java.util.Iterator) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) List(java.util.List) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) AttributeElement(com.sun.identity.saml2.jaxb.entityconfig.AttributeElement) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 24 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class ConfigureSalesForceApps method updateSPMeta.

private void updateSPMeta(String entityId, String realm, String cot, List attrMapping) throws WorkflowException {
    String extendedMeta = null;
    String localMetadata = null;
    try {
        localMetadata = METADATA.replace(ENTITY_ID_PLACEHOLDER, entityId);
        EntityDescriptorElement e = SAML2MetaUtils.getEntityDescriptorElement(localMetadata);
        String eId = e.getEntityID();
        String metaAlias = generateMetaAliasForSP(realm);
        Map map = new HashMap();
        map.put(MetaTemplateParameters.P_SP, metaAlias);
        extendedMeta = createExtendedDataTemplate(eId, false);
    } catch (SAML2MetaException ex) {
        throw new WorkflowException(ex.getMessage());
    } catch (JAXBException ex) {
        throw new WorkflowException(ex.getMessage());
    }
    String[] results = ImportSAML2MetaData.importData(realm, localMetadata, extendedMeta);
    String configuredEntityId = results[1];
    if ((cot != null) && (cot.length() > 0)) {
        try {
            AddProviderToCOT.addToCOT(realm, cot, configuredEntityId);
        } catch (COTException e) {
            throw new WorkflowException(e.getMessage());
        }
    }
    try {
        if (!attrMapping.isEmpty()) {
            SAML2MetaManager manager = new SAML2MetaManager();
            EntityConfigElement config = manager.getEntityConfig(realm, configuredEntityId);
            SPSSOConfigElement ssoConfig = manager.getSPSSOConfig(realm, configuredEntityId);
            if (ssoConfig != null) {
                ObjectFactory objFactory = new ObjectFactory();
                AttributeType avp = objFactory.createAttributeElement();
                String key = SAML2Constants.ATTRIBUTE_MAP;
                avp.setName(key);
                avp.getValue().addAll(attrMapping);
                ssoConfig.getAttribute().add(avp);
            }
            manager.setEntityConfig(realm, config);
        }
    } catch (SAML2MetaException e) {
        throw new WorkflowException(e.getMessage());
    } catch (JAXBException e) {
        throw new WorkflowException(e.getMessage());
    }
}
Also used : HashMap(java.util.HashMap) JAXBException(javax.xml.bind.JAXBException) SPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement) COTException(com.sun.identity.cot.COTException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) ObjectFactory(com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory) AttributeType(com.sun.identity.saml2.jaxb.entityconfig.AttributeType) HashMap(java.util.HashMap) Map(java.util.Map) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 25 with EntityConfigElement

use of com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement in project OpenAM by OpenRock.

the class CreateHostedIDP method execute.

/**
     * Creates hosted identity provider.
     *
     * @param locale Locale of the Request
     * @param params Map of creation parameters.
     */
public String execute(Locale locale, Map params) throws WorkflowException {
    validateParameters(params);
    String metadataFile = getString(params, ParameterKeys.P_META_DATA);
    boolean hasMetaData = (metadataFile != null) && (metadataFile.trim().length() > 0);
    String metadata = null;
    String extendedData = null;
    if (hasMetaData) {
        String extendedDataFile = getString(params, ParameterKeys.P_EXTENDED_DATA);
        metadata = getContent(metadataFile, locale);
        extendedData = getContent(extendedDataFile, locale);
    } else {
        String entityId = getString(params, ParameterKeys.P_ENTITY_ID);
        String metaAlias = generateMetaAliasForIDP(getString(params, ParameterKeys.P_REALM));
        Map map = new HashMap();
        map.put(MetaTemplateParameters.P_IDP, metaAlias);
        map.put(MetaTemplateParameters.P_IDP_E_CERT, getString(params, ParameterKeys.P_IDP_E_CERT));
        map.put(MetaTemplateParameters.P_IDP_S_CERT, getString(params, ParameterKeys.P_IDP_S_CERT));
        try {
            metadata = CreateSAML2HostedProviderTemplate.buildMetaDataTemplate(entityId, map, getRequestURL(params));
            extendedData = CreateSAML2HostedProviderTemplate.createExtendedDataTemplate(entityId, map, getRequestURL(params));
        } catch (SAML2MetaException e) {
            return e.getMessage();
        }
    }
    String[] results = ImportSAML2MetaData.importData(null, metadata, extendedData);
    String realm = results[0];
    String entityId = results[1];
    String cot = getString(params, ParameterKeys.P_COT);
    if ((cot != null) && (cot.length() > 0)) {
        try {
            AddProviderToCOT.addToCOT(realm, cot, entityId);
        } catch (COTException e) {
            throw new WorkflowException(e.getMessage());
        }
    }
    try {
        List attrMapping = getAttributeMapping(params);
        if (!attrMapping.isEmpty()) {
            SAML2MetaManager manager = new SAML2MetaManager();
            EntityConfigElement config = manager.getEntityConfig(realm, entityId);
            IDPSSOConfigElement ssoConfig = manager.getIDPSSOConfig(realm, entityId);
            Map attribConfig = SAML2MetaUtils.getAttributes(ssoConfig);
            List mappedAttributes = (List) attribConfig.get(SAML2Constants.ATTRIBUTE_MAP);
            mappedAttributes.addAll(attrMapping);
            manager.setEntityConfig(realm, config);
        }
    } catch (SAML2MetaException e) {
        throw new WorkflowException(e.getMessage());
    }
    try {
        return getMessage("idp.configured", locale) + "|||realm=" + realm + "&entityId=" + URLEncoder.encode(entityId, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new WorkflowException(e.getMessage());
    }
}
Also used : HashMap(java.util.HashMap) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) COTException(com.sun.identity.cot.COTException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Aggregations

EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)44 List (java.util.List)26 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)23 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)22 ArrayList (java.util.ArrayList)21 Iterator (java.util.Iterator)19 JAXBException (javax.xml.bind.JAXBException)18 BaseConfigType (com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType)12 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)11 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)10 COTException (com.sun.identity.cot.COTException)8 ConfigurationException (com.sun.identity.plugin.configuration.ConfigurationException)8 Set (java.util.Set)8 Map (java.util.Map)7 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)6 HashSet (java.util.HashSet)6 IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)5 AttributeType (com.sun.identity.saml2.jaxb.entityconfig.AttributeType)4 ObjectFactory (com.sun.identity.saml2.jaxb.entityconfig.ObjectFactory)4 CLIException (com.sun.identity.cli.CLIException)3