Search in sources :

Example 16 with CircleOfTrustManager

use of com.sun.identity.cot.CircleOfTrustManager 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 17 with CircleOfTrustManager

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

the class LibertyManager method getListOfCOTs.

/**
     * Returns the List of COTs for the given Provider under a realm.
     *
     * @param realm The realm under which the entity resides.
     * @param providerId The ID of the provider whose <code>COTList</code>
     *  is to be found
     * @param providerRole The Role of the provider whose <code>COTList</code>
     *  is to be found
     * @return The set containing the authentication domains for the given
     *  provider.
     */
public static Set getListOfCOTs(String realm, String providerId, String providerRole) {
    Set returnSet = new HashSet();
    BaseConfigType hostConfig = IDFFMetaUtils.getExtendedConfig(realm, providerId, providerRole, metaManager);
    if (hostConfig != null) {
        List cotSet = IDFFMetaUtils.getAttributeValueFromConfig(hostConfig, IFSConstants.COT_LIST);
        if (cotSet != null && !cotSet.isEmpty()) {
            Iterator iter = cotSet.iterator();
            while (iter.hasNext()) {
                String cotID = (String) iter.next();
                try {
                    CircleOfTrustManager cotManager = new CircleOfTrustManager();
                    CircleOfTrustDescriptor cotDesc = cotManager.getCircleOfTrust(realm, cotID);
                    String tldURL = cotDesc.getIDFFWriterServiceURL();
                    String cotStatus = cotDesc.getCircleOfTrustStatus();
                    if (tldURL != null && tldURL.length() > 0 && cotStatus.equalsIgnoreCase(IFSConstants.ACTIVE)) {
                        returnSet.add((String) cotID);
                    }
                } catch (COTException fsExp) {
                    debug.error("LibertyManager: getListOfCots " + "COTException caught ", fsExp);
                }
            }
        }
        if (returnSet != null && returnSet.size() > 0) {
            if (debug.messageEnabled()) {
                debug.message("LibertyManager: getListOfCots returning " + " cot set with " + returnSet);
            }
        } else {
            if (debug.messageEnabled()) {
                debug.message("LibertyManager::getListOfCots returning" + " null. Looks like COT is not set");
            }
        }
    }
    return returnSet;
}
Also used : BaseConfigType(com.sun.identity.federation.jaxb.entityconfig.BaseConfigType) HashSet(java.util.HashSet) Set(java.util.Set) CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) HashSet(java.util.HashSet)

Example 18 with CircleOfTrustManager

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

the class AddProviderToCOT method addToCOT.

public static void addToCOT(String realm, String cot, String entityId) throws COTException {
    CircleOfTrustManager cotManager = new CircleOfTrustManager();
    if (!cotManager.getAllCirclesOfTrust(realm).contains(cot)) {
        CircleOfTrustDescriptor desc = new CircleOfTrustDescriptor(cot, realm, COTConstants.ACTIVE, "", null, null, null, null, Collections.EMPTY_SET);
        cotManager.createCircleOfTrust(realm, desc);
    }
    cotManager.addCircleOfTrustMember(realm, cot, COTConstants.SAML2, entityId);
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor)

Example 19 with CircleOfTrustManager

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

the class FSAuthDomainsModelImpl method getCircleOfTrustDescriptors.

public Set getCircleOfTrustDescriptors() {
    Set descSet = new HashSet();
    String realm = COTConstants.ROOT_REALM;
    try {
        CircleOfTrustManager manager = getCircleOfTrustManager();
        Set realmSet = getRealmNames("/", "*");
        for (Iterator i = realmSet.iterator(); i.hasNext(); ) {
            realm = (String) i.next();
            Set cotSet = manager.getAllCirclesOfTrust(realm);
            for (Iterator j = cotSet.iterator(); j.hasNext(); ) {
                String cotName = (String) j.next();
                CircleOfTrustDescriptor descriptor = manager.getCircleOfTrust(realm, cotName);
                descSet.add(descriptor);
            }
        }
    } catch (COTException e) {
        String[] paramsEx = { realm, getErrorString(e) };
        logEvent("FEDERATION_EXCEPTION_GET_AUTH_DOMAINS", paramsEx);
        debug.warning("FSAuthDomainsModelImpl.getAuthenticationDomains", e);
    } catch (AMConsoleException e) {
        debug.warning("FSAuthDomainsModelImpl.getAuthenticationDomains", e);
    }
    return descSet;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) Iterator(java.util.Iterator) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashSet(java.util.HashSet)

Example 20 with CircleOfTrustManager

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

the class FSAuthDomainsModelImpl method createAuthenticationDomain.

/**
     * Creates authentication domain.
     *
     * @param attrValues Map of attribute name to set of attribute values.
     * @throws AMConsoleException if authentication domain created.
     */
public void createAuthenticationDomain(Map attrValues, Set providers) throws AMConsoleException {
    String realm = (String) AMAdminUtils.getValue((Set) attrValues.get(SINGLE_CHOICE_REALM));
    String status = (String) AMAdminUtils.getValue((Set) attrValues.get(SINGLE_CHOICE_STATUS));
    String name = (String) AMAdminUtils.getValue((Set) attrValues.get(TF_NAME));
    if (name.trim().length() == 0) {
        throw new AMConsoleException("authdomain.authentication.domain.name.missing.message");
    }
    String[] param = { name };
    logEvent("ATTEMPT_CREATE_AUTH_DOMAIN", param);
    try {
        CircleOfTrustDescriptor descriptor = new CircleOfTrustDescriptor(name, realm, status);
        descriptor.setTrustedProviders(providers);
        descriptor.setCircleOfTrustDescription((String) AMAdminUtils.getValue((Set) attrValues.get(TF_DESCRIPTION)));
        descriptor.setIDFFReaderServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(TF_IDFF_READER_SERVICE_URL)));
        descriptor.setIDFFWriterServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(TF_IDFF_WRITER_SERVICE_URL)));
        descriptor.setSAML2ReaderServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(TF_SAML2_READER_SERVICE_URL)));
        descriptor.setSAML2WriterServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(TF_SAML2_WRITER_SERVICE_URL)));
        CircleOfTrustManager manager = getCircleOfTrustManager();
        manager.createCircleOfTrust(realm, descriptor);
        logEvent("SUCCEED_CREATE_AUTH_DOMAIN", param);
    } catch (COTException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { name, strError };
        logEvent("FEDERATION_EXCEPTION_CREATE_AUTH_DOMAIN", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Aggregations

CircleOfTrustManager (com.sun.identity.cot.CircleOfTrustManager)35 COTException (com.sun.identity.cot.COTException)29 Set (java.util.Set)18 CircleOfTrustDescriptor (com.sun.identity.cot.CircleOfTrustDescriptor)16 Iterator (java.util.Iterator)15 CLIException (com.sun.identity.cli.CLIException)10 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)9 HashSet (java.util.HashSet)9 List (java.util.List)9 ArrayList (java.util.ArrayList)6 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)5 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)5 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)5 SAML2MetaManager (com.sun.identity.saml2.meta.SAML2MetaManager)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)3 CLIRequest (com.sun.identity.cli.CLIRequest)2 IOutput (com.sun.identity.cli.IOutput)2 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)2