Search in sources :

Example 1 with SAML2MetaManager

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

the class ExportSAML2MetaData method exportExtendedMeta.

public static String exportExtendedMeta(String realm, String entityID) throws WorkflowException {
    try {
        String result = null;
        SAML2MetaManager metaManager = new SAML2MetaManager();
        EntityConfigElement config = metaManager.getEntityConfig(realm, entityID);
        if (config != null) {
            OutputStream os = new ByteArrayOutputStream();
            SAML2MetaUtils.convertJAXBToOutputStream(config, os);
            result = os.toString();
        }
        return result;
    } catch (JAXBException e) {
        throw new WorkflowException(e.getMessage());
    } catch (SAML2MetaException e) {
        throw new WorkflowException(e.getMessage());
    }
}
Also used : OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JAXBException(javax.xml.bind.JAXBException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 2 with SAML2MetaManager

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

the class GetHostedIDPs method execute.

public String execute(Locale locale, Map params) throws WorkflowException {
    String realm = getString(params, ParameterKeys.P_REALM);
    String cot = getString(params, ParameterKeys.P_COT);
    try {
        CircleOfTrustManager cotMgr = new CircleOfTrustManager();
        Set entities = cotMgr.listCircleOfTrustMember(realm, cot, COTConstants.SAML2);
        SAML2MetaManager mgr = new SAML2MetaManager();
        StringBuffer buff = new StringBuffer();
        boolean first = true;
        for (Iterator i = entities.iterator(); i.hasNext(); ) {
            String entityId = (String) i.next();
            EntityConfigElement elm = mgr.getEntityConfig(realm, entityId);
            // elm could be null due to OPENAM-269
            if (elm != null && elm.isHosted()) {
                EntityDescriptorElement desc = mgr.getEntityDescriptor(realm, entityId);
                if (SAML2MetaUtils.getIDPSSODescriptor(desc) != null) {
                    if (first) {
                        first = false;
                    } else {
                        buff.append("|");
                    }
                    buff.append(entityId);
                }
            }
        }
        return buff.toString();
    } catch (COTException e) {
        throw new WorkflowException(e.getMessage(), null);
    } catch (SAML2MetaException e) {
        throw new WorkflowException(e.getMessage(), null);
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) Set(java.util.Set) Iterator(java.util.Iterator) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) COTException(com.sun.identity.cot.COTException) EntityDescriptorElement(com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) EntityConfigElement(com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)

Example 3 with SAML2MetaManager

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

the class MetaDataParser method getSSOUrl.

/**
 *get SSO URL
 *
 */
private String getSSOUrl() {
    try {
        SAML2MetaManager manager = new SAML2MetaManager();
        IDPSSODescriptorElement idp = manager.getIDPSSODescriptor("/", getIDPEntityID());
        List ssoServiceList = idp.getSingleSignOnService();
        if ((ssoServiceList != null) && (!ssoServiceList.isEmpty())) {
            Iterator i = ssoServiceList.iterator();
            while (i.hasNext()) {
                SingleSignOnServiceElement sso = (SingleSignOnServiceElement) i.next();
                if ((sso != null) && (sso.getBinding() != null)) {
                    String ssoURL = sso.getLocation();
                    int loc = ssoURL.indexOf("/metaAlias/");
                    if (loc == -1) {
                        continue;
                    } else {
                        return ssoURL;
                    }
                }
            }
        }
        return null;
    } catch (SAML2MetaException ex) {
        Logger.getLogger(MetaDataParser.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}
Also used : Iterator(java.util.Iterator) List(java.util.List) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) SingleSignOnServiceElement(com.sun.identity.saml2.jaxb.metadata.SingleSignOnServiceElement) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) IDPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)

Example 4 with SAML2MetaManager

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

the class MetaDataParser method getSPEntityID.

/**
 *get SP Entity ID
 *
 */
public String getSPEntityID() {
    String spEntityID = null;
    try {
        SAML2MetaManager manager = new SAML2MetaManager();
        List spEntities = manager.getAllHostedServiceProviderEntities("/");
        if ((spEntities != null) && !spEntities.isEmpty()) {
            spEntityID = (String) spEntities.get(0);
        }
        return spEntityID;
    } catch (SAML2MetaException ex) {
        Logger.getLogger(MetaDataParser.class.getName()).log(Level.SEVERE, null, ex);
    }
    return spEntityID;
}
Also used : List(java.util.List) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 5 with SAML2MetaManager

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

the class MetaDataParser method getIDPEntityID.

/**
 *get IDP Entity ID
 *
 */
public String getIDPEntityID() {
    String idpEntityID = null;
    try {
        SAML2MetaManager manager = new SAML2MetaManager();
        List idpEntities = manager.getAllRemoteIdentityProviderEntities("/");
        if ((idpEntities != null) && !idpEntities.isEmpty()) {
            idpEntityID = (String) idpEntities.get(0);
        }
        return idpEntityID;
    } catch (SAML2MetaException ex) {
        Logger.getLogger(MetaDataParser.class.getName()).log(Level.SEVERE, null, ex);
    }
    return idpEntityID;
}
Also used : List(java.util.List) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

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