Search in sources :

Example 66 with SAML2MetaManager

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

the class GetIDPSPPairingInCOT method getEntities.

private List getEntities(String realm, String cotName, boolean bIDP, boolean hosted) throws WorkflowException {
    try {
        SAML2MetaManager mgr = new SAML2MetaManager();
        Set entities = getEntities(realm, cotName);
        List results = new ArrayList();
        for (Iterator i = entities.iterator(); i.hasNext(); ) {
            String entityId = (String) i.next();
            EntityConfigElement elm = mgr.getEntityConfig(realm, entityId);
            if (elm.isHosted() == hosted) {
                EntityDescriptorElement desc = mgr.getEntityDescriptor(realm, entityId);
                if (bIDP) {
                    if (SAML2MetaUtils.getIDPSSODescriptor(desc) != null) {
                        results.add(entityId);
                    }
                } else {
                    if (SAML2MetaUtils.getSPSSODescriptor(desc) != null) {
                        results.add(entityId);
                    }
                }
            }
        }
        return results;
    } catch (SAML2MetaException ex) {
        throw new WorkflowException(ex.getMessage());
    }
}
Also used : Set(java.util.Set) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 67 with SAML2MetaManager

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

the class GetIDPSPPairingInCOT method getHostedSPMetaAlias.

private List getHostedSPMetaAlias(String realm, List hostedSP) throws WorkflowException {
    try {
        List list = new ArrayList();
        SAML2MetaManager mgr = new SAML2MetaManager();
        for (Iterator i = hostedSP.iterator(); i.hasNext(); ) {
            String e = (String) i.next();
            SPSSOConfigElement cfg = mgr.getSPSSOConfig(realm, e);
            list.add(e + "(" + cfg.getMetaAlias() + ")");
        }
        return list;
    } catch (SAML2MetaException ex) {
        throw new WorkflowException(ex.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) SPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement) ArrayList(java.util.ArrayList) List(java.util.List) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 68 with SAML2MetaManager

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

the class GetIDPSPPairingInCOT method getHostedIDPMetaAlias.

private List getHostedIDPMetaAlias(String realm, List hostedIDP) throws WorkflowException {
    try {
        List list = new ArrayList();
        SAML2MetaManager mgr = new SAML2MetaManager();
        for (Iterator i = hostedIDP.iterator(); i.hasNext(); ) {
            String e = (String) i.next();
            IDPSSOConfigElement cfg = mgr.getIDPSSOConfig(realm, e);
            list.add(e + "(" + cfg.getMetaAlias() + ")");
        }
        return list;
    } catch (SAML2MetaException ex) {
        throw new WorkflowException(ex.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 69 with SAML2MetaManager

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

the class ImportSAML2MetaData method importData.

/**
     * Imports meta and extended metadata.
     *
     * @param realm Realm of the entity.
     * @param metadata Meta data.
     * @param extended extended data.
     * @return realm and entity ID.
     */
public static String[] importData(String realm, String metadata, String extended) throws WorkflowException {
    String entityID = null;
    try {
        SAML2MetaManager metaManager = new SAML2MetaManager();
        EntityConfigElement configElt = null;
        if (extended != null) {
            Object obj = SAML2MetaUtils.convertStringToJAXB(extended);
            configElt = (obj instanceof EntityConfigElement) ? (EntityConfigElement) obj : null;
            if (configElt != null && configElt.isHosted()) {
                List config = configElt.getIDPSSOConfigOrSPSSOConfigOrAuthnAuthorityConfig();
                if (!config.isEmpty()) {
                    BaseConfigType bConfig = (BaseConfigType) config.iterator().next();
                    realm = SAML2MetaUtils.getRealmByMetaAlias(bConfig.getMetaAlias());
                }
            }
        }
        // Load the metadata if it has been provided
        if (metadata != null) {
            entityID = importSAML2MetaData(metaManager, realm, metadata);
        }
        // Load the extended metadata if it has been provided
        if (configElt != null) {
            metaManager.createEntityConfig(realm, configElt);
        }
    } catch (SAML2MetaException e) {
        DEBUG.error("An error occurred while importing the SAML metadata", e);
        throw new WorkflowException(e.getMessage());
    } catch (JAXBException e) {
        DEBUG.error("An error occurred while importing the SAML metadata", e);
        throw new WorkflowException(e.getMessage());
    }
    String[] results = { realm, entityID };
    return results;
}
Also used : BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) JAXBException(javax.xml.bind.JAXBException) List(java.util.List) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 70 with SAML2MetaManager

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

the class Task method generateMetaAliasForIDP.

static String generateMetaAliasForIDP(String realm) throws WorkflowException {
    try {
        Set metaAliases = new HashSet();
        SAML2MetaManager mgr = new SAML2MetaManager();
        metaAliases.addAll(mgr.getAllHostedIdentityProviderMetaAliases(realm));
        metaAliases.addAll(mgr.getAllHostedServiceProviderMetaAliases(realm));
        String metaAliasBase = (realm.equals("/")) ? "/idp" : realm + "/idp";
        String metaAlias = metaAliasBase;
        int counter = 1;
        while (metaAliases.contains(metaAlias)) {
            metaAlias = metaAliasBase + Integer.toString(counter);
            counter++;
        }
        return metaAlias;
    } catch (SAML2MetaException e) {
        throw new WorkflowException(e.getMessage());
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) HashSet(java.util.HashSet)

Aggregations

SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)100 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)93 List (java.util.List)67 ArrayList (java.util.ArrayList)48 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)46 Map (java.util.Map)33 HashMap (java.util.HashMap)31 Iterator (java.util.Iterator)28 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)27 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)23 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)22 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)21 JAXBException (javax.xml.bind.JAXBException)20 BaseConfigType (com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType)19 SPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement)17 IDPSSODescriptorElement (com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)16 IDPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement)15 Set (java.util.Set)10 CLIException (com.sun.identity.cli.CLIException)9 COTException (com.sun.identity.cot.COTException)9