Search in sources :

Example 26 with COTException

use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.

the class ConfigFedMonitoring method getAllRealms.

private void getAllRealms(String startRealm) {
    String classMethod = "ConfigFedMonitoring.getAllRealms: ";
    // until IDPs/SPs per realm instrum
    boolean skipSAML2Entities = true;
    StringBuffer sb = new StringBuffer(classMethod);
    sb.append("orgnames starting from ").append(startRealm).append(":\n");
    sb.append("  ").append(startRealm).append("\n");
    List rList = getRealmsList(startRealm);
    try {
        CircleOfTrustManager cotmgr = new CircleOfTrustManager();
        SAML2MetaManager saml2Mgr = new SAML2MetaManager();
        IDFFMetaManager idffmgr = new IDFFMetaManager(ssoToken);
        for (Iterator it = rList.iterator(); it.hasNext(); ) {
            String thisRealm = (String) it.next();
            Set cots = getCOTs(thisRealm, cotmgr);
            Map s2Ents = null;
            if (!skipSAML2Entities) {
                s2Ents = getSAML2Entities(thisRealm, saml2Mgr);
            }
            Map wsEnts = getWSFedEntities(thisRealm);
            Map idffentMap = getIDFFEntities(thisRealm, idffmgr);
            /*
                 *  getCOTMembers(thisRealm, cot, cotmgr, cotsb)
                 *  can get the members of the COT, but there isn't
                 *  a (MIB) entry that right now.
                 */
            Map membMap = getCOTMembers(thisRealm, cots, cotmgr);
            SSOServerRealmFedInfo srfi = new SSOServerRealmFedInfo.SSOServerRealmFedInfoBuilder(thisRealm).cots(cots).samlv2Entities(s2Ents).wsEntities(wsEnts).idffEntities(idffentMap).membEntities(membMap).build();
            Agent.federationConfig(srfi);
        }
    } catch (SAML2MetaException e) {
        debug.error(classMethod + "SAML2 ex: " + e.getMessage());
    } catch (COTException e) {
        debug.error(classMethod + "COT ex: " + e.getMessage());
    } catch (IDFFMetaException e) {
        debug.error(classMethod + "IDFF ex: " + e.getMessage());
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) Set(java.util.Set) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) SAML2MetaManager(com.sun.identity.saml2.meta.SAML2MetaManager) COTException(com.sun.identity.cot.COTException) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) SSOServerRealmFedInfo(com.sun.identity.monitoring.SSOServerRealmFedInfo) HashMap(java.util.HashMap) Map(java.util.Map) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException)

Example 27 with COTException

use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.

the class ConfigFedMonitoring method getCOTMembers.

private Map getCOTMembers(String realm, Set cotNames, CircleOfTrustManager cotmgr) {
    String classMethod = "ConfigFedMonitoring.getCOTMembers: ";
    StringBuffer sb = new StringBuffer(classMethod);
    Map cotMap = new HashMap();
    for (Iterator it1 = cotNames.iterator(); it1.hasNext(); ) {
        String cotName = (String) it1.next();
        if (debug.messageEnabled()) {
            sb.append(" cotName = ").append(cotName).append("\n");
        }
        Map memMap = new HashMap();
        try {
            Set cotSAML = cotmgr.listCircleOfTrustMember(realm, cotName, COTConstants.SAML2);
            Set cotIDFF = cotmgr.listCircleOfTrustMember(realm, cotName, COTConstants.IDFF);
            Set cotWSFed = cotmgr.listCircleOfTrustMember(realm, cotName, COTConstants.WS_FED);
            memMap.put("SAML", cotSAML);
            memMap.put("IDFF", cotIDFF);
            memMap.put("WSFed", cotWSFed);
            cotMap.put(cotName, memMap);
            if (debug.messageEnabled()) {
                sb.append("    SAMLv2 members: ");
                if ((cotSAML != null) && (cotSAML.size() > 0)) {
                    for (Iterator it = cotSAML.iterator(); it.hasNext(); ) {
                        sb.append("      ").append((String) it.next()).append("\n");
                    }
                } else {
                    sb.append("none\n");
                }
                sb.append("    IDFF members: ");
                if ((cotIDFF != null) && (cotIDFF.size() > 0)) {
                    for (Iterator it = cotIDFF.iterator(); it.hasNext(); ) {
                        sb.append("      ").append((String) it.next()).append("\n");
                    }
                } else {
                    sb.append("none\n");
                }
                sb.append("    WSFed members: ");
                if ((cotWSFed != null) && (cotWSFed.size() > 0)) {
                    for (Iterator it = cotWSFed.iterator(); it.hasNext(); ) {
                        sb.append("      ").append((String) it.next()).append("\n");
                    }
                } else {
                    sb.append("none\n");
                }
            }
        } catch (COTException cx) {
            debug.error(classMethod + "COTException: " + cx.getMessage());
        }
    }
    if (debug.messageEnabled()) {
        debug.error(sb.toString());
    }
    return cotMap;
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) Iterator(java.util.Iterator) COTException(com.sun.identity.cot.COTException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 28 with COTException

use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.

the class FSLoginHelper method getTLDURL.

private String getTLDURL() {
    String tldURL = null;
    FSUtils.debug.message("FSLoginHelper.getTLDURL() :: called");
    try {
        if ((cotList == null) || (cotList.isEmpty())) {
            FSUtils.debug.error("FSLoginHelper::getTLDURL():" + "Received COT Set is Invalid");
        } else {
            if (cotList.size() > 1) {
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("FSLoginHelper::getTLDURL() " + "Multiple COTs found will do polling ");
                }
            } else {
                FSUtils.debug.message("FSLoginHelper::getTLDURL() Single COT found");
            }
            Iterator iter = cotList.iterator();
            CircleOfTrustManager cotManager = new CircleOfTrustManager();
            while (iter.hasNext()) {
                CircleOfTrustDescriptor cotDesc = cotManager.getCircleOfTrust(realm, (String) iter.next());
                if (cotDesc != null && (cotDesc.getCircleOfTrustStatus()).equalsIgnoreCase(IFSConstants.ACTIVE)) {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("FSLoginHelper::getTLDURL " + "found a active cot with cotid : " + cotDesc.getCircleOfTrustName());
                    }
                    tldURL = cotDesc.getIDFFReaderServiceURL();
                    break;
                }
            }
        }
    } catch (COTException ame) {
        FSUtils.debug.error("FSLoginHelper.getTLDURL():" + "COTException:", ame);
    } catch (Exception exp) {
        FSUtils.debug.error("FSLoginHelper.getTLDURL():General Exception:", exp);
    }
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("FSLoginHelper::getTLDURL().tldURL  " + tldURL);
    }
    return tldURL;
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) Iterator(java.util.Iterator) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) COTException(com.sun.identity.cot.COTException) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException)

Example 29 with COTException

use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.

the class SAML2Utils method getReaderURL.

public static String getReaderURL(String spMetaAlias) {
    // get spExtended
    String classMethod = "SAML2Utils:getReaderURL:";
    String readerURL = null;
    try {
        String realm = SAML2MetaUtils.getRealmByMetaAlias(spMetaAlias);
        String spEntityID = saml2MetaManager.getEntityByMetaAlias(spMetaAlias);
        if (debug.messageEnabled()) {
            debug.message(classMethod + "metaAlias is :" + spMetaAlias);
            debug.message(classMethod + "Realm is :" + realm);
            debug.message(classMethod + "spEntityID is :" + spEntityID);
        }
        SPSSOConfigElement spEntityCfg = saml2MetaManager.getSPSSOConfig(realm, spEntityID);
        Map spConfigAttrsMap = null;
        if (spEntityCfg != null) {
            spConfigAttrsMap = SAML2MetaUtils.getAttributes(spEntityCfg);
            List cotList = (List) spConfigAttrsMap.get("cotlist");
            String cotListStr = (String) cotList.iterator().next();
            CircleOfTrustDescriptor cotDesc = cotManager.getCircleOfTrust(realm, cotListStr);
            readerURL = cotDesc.getSAML2ReaderServiceURL();
        }
    } catch (COTException ce) {
        if (debug.messageEnabled()) {
            debug.message(classMethod + "Error retreiving circle of trust", ce);
        }
    } catch (SAML2Exception s2e) {
        if (debug.messageEnabled()) {
            debug.message(classMethod + "Error getting reader URL : ", s2e);
        }
    } catch (Exception e) {
        if (debug.messageEnabled()) {
            debug.message(classMethod + "Error getting reader URL : ", e);
        }
    }
    return readerURL;
}
Also used : SPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement) ArrayList(java.util.ArrayList) List(java.util.List) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) Map(java.util.Map) HashMap(java.util.HashMap) SystemConfigurationException(com.sun.identity.common.SystemConfigurationException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SAML2MetaException(com.sun.identity.saml2.meta.SAML2MetaException) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) SessionException(com.sun.identity.plugin.session.SessionException) DataStoreProviderException(com.sun.identity.plugin.datastore.DataStoreProviderException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) COTException(com.sun.identity.cot.COTException) SAML2TokenRepositoryException(org.forgerock.openam.federation.saml2.SAML2TokenRepositoryException)

Example 30 with COTException

use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.

the class IDFFMetaManager method addToCircleOfTrust.

/**
     * Adds entity identifier to circle of trust.
     *
     * @param realm The realm under which the entity resides.
     * @param config the entity config.
     * @param entityId the entity identifier.
     */
private void addToCircleOfTrust(BaseConfigType config, String realm, String entityId) {
    String classMethod = "COTManager:addToCircleOfTrust :";
    try {
        if (config != null) {
            Map attr = IDFFMetaUtils.getAttributes(config);
            List cotAttr = (List) attr.get(COTConstants.COT_LIST);
            List cotList = new ArrayList(cotAttr);
            if ((cotList != null) && !cotList.isEmpty()) {
                for (Iterator iter = cotList.iterator(); iter.hasNext(); ) {
                    String cotName = (String) iter.next();
                    try {
                        cotManager.addCircleOfTrustMember(realm, cotName, COTConstants.IDFF, entityId);
                    } catch (COTException ce) {
                        debug.error(classMethod + cotName + " cotName");
                    }
                }
            }
        }
    } catch (Exception e) {
        debug.error(classMethod + "Error while adding entity " + entityId + " to COT.", e);
    }
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) COTException(com.sun.identity.cot.COTException) Map(java.util.Map) COTException(com.sun.identity.cot.COTException) ConfigurationException(com.sun.identity.plugin.configuration.ConfigurationException) JAXBException(javax.xml.bind.JAXBException)

Aggregations

COTException (com.sun.identity.cot.COTException)42 CircleOfTrustManager (com.sun.identity.cot.CircleOfTrustManager)29 Set (java.util.Set)18 Iterator (java.util.Iterator)16 CircleOfTrustDescriptor (com.sun.identity.cot.CircleOfTrustDescriptor)15 List (java.util.List)15 Map (java.util.Map)14 ArrayList (java.util.ArrayList)13 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)12 HashMap (java.util.HashMap)11 CLIException (com.sun.identity.cli.CLIException)10 HashSet (java.util.HashSet)10 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)9 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)9 SPSSOConfigElement (com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement)7 EntityConfigElement (com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement)6 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)5 JAXBException (javax.xml.bind.JAXBException)5 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)4 EntityDescriptorElement (com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement)4