Search in sources :

Example 21 with COTException

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

the class ImportMetaData method handleIDFFRequest.

private void handleIDFFRequest(RequestContext rc) throws CLIException {
    try {
        IDFFMetaManager metaManager = new IDFFMetaManager(ssoToken);
        String entityID = null;
        com.sun.identity.federation.jaxb.entityconfig.EntityConfigElement configElt = null;
        if (extendedData != null) {
            configElt = getIDFFEntityConfigElement();
            /*
                 * see note at the end of this class for how we decide
                 * the realm value
                 */
            if ((configElt != null) && configElt.isHosted()) {
                IDPDescriptorConfigElement idpConfig = IDFFMetaUtils.getIDPDescriptorConfig(configElt);
                if (idpConfig != null) {
                    realm = SAML2MetaUtils.getRealmByMetaAlias(idpConfig.getMetaAlias());
                } else {
                    SPDescriptorConfigElement spConfig = IDFFMetaUtils.getSPDescriptorConfig(configElt);
                    if (spConfig != null) {
                        realm = SAML2MetaUtils.getRealmByMetaAlias(spConfig.getMetaAlias());
                    }
                }
            }
        }
        if (metadata != null) {
            entityID = importIDFFMetaData(realm, metaManager);
        }
        if (configElt != null) {
            String out = (webAccess) ? "web" : extendedData;
            Object[] objs = { out };
            metaManager.createEntityConfig(realm, configElt);
            getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("import-entity-succeeded"), objs));
        }
        if ((cot != null) && (cot.length() > 0) && (entityID != null) && (entityID.length() > 0)) {
            CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
            if (!cotManager.isInCircleOfTrust(realm, cot, spec, entityID)) {
                cotManager.addCircleOfTrustMember(realm, cot, spec, entityID);
            }
        }
    } catch (IDFFMetaException e) {
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (COTException e) {
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) SPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.SPDescriptorConfigElement) COTException(com.sun.identity.cot.COTException) IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) CLIException(com.sun.identity.cli.CLIException) IDPDescriptorConfigElement(com.sun.identity.federation.jaxb.entityconfig.IDPDescriptorConfigElement)

Example 22 with COTException

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

the class FSAuthDomainsModelImpl method addProviders.

/**
     * Adds providers.
     * @param realm realm of circle of trust
     * @param cotName Name of circle of trust
     * @param names Names provider to be added.
     * @throws AMConsoleException if provider cannot be added.
     */
public void addProviders(String realm, String cotName, Collection names) throws AMConsoleException {
    String cotType = COTConstants.SAML2;
    String entityId = null;
    String providerNames = AMAdminUtils.getString(names, ",", false);
    String[] params = { realm, cotName, providerNames };
    logEvent("ATTEMPT_ADD_PROVIDERS_TO_AUTH_DOMAIN", params);
    try {
        CircleOfTrustManager manager = getCircleOfTrustManager();
        CircleOfTrustDescriptor cotDescriptor = manager.getCircleOfTrust(realm, cotName);
        Set existingEntity = cotDescriptor.getTrustedProviders();
        if (existingEntity != null) {
            Iterator it = existingEntity.iterator();
            while (it.hasNext()) {
                String entityString = (String) it.next();
                String delims = "|";
                StringTokenizer tokens = new StringTokenizer(entityString, delims);
                if (tokens.countTokens() == 2) {
                    entityId = tokens.nextToken();
                    cotType = tokens.nextToken();
                    manager.removeCircleOfTrustMember(realm, cotName, cotType, entityId);
                }
            }
        }
        if (names != null) {
            int sz = names.size();
            for (int i = 0; i < sz; i++) {
                String entityString = (String) ((ArrayList) names).get(i);
                String delims = "|";
                StringTokenizer tokens = new StringTokenizer(entityString, delims);
                if (tokens.countTokens() == 2) {
                    entityId = tokens.nextToken();
                    cotType = tokens.nextToken();
                    manager.addCircleOfTrustMember(realm, cotName, cotType, entityId);
                }
            }
        }
        logEvent("SUCCEED_ADD_PROVIDERS_TO_AUTH_DOMAIN", params);
    } catch (COTException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, cotName, providerNames, strError };
        logEvent("FEDERATION_EXCEPTION_ADD_PROVIDERS_TO_AUTH_DOMAIN", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 23 with COTException

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

the class FSAuthDomainsModelImpl method getTrustedProviderNames.

/**
     * Returns a set of provider names under a authentication domain.
     *
     * @param name Name of authentication domain.
     * @return a set of provider names under a authentication domain.
     * @throws AMConsoleException if provider names cannot be obtained.
     */
public Set getTrustedProviderNames(String realm, String name) throws AMConsoleException {
    Set providers = null;
    try {
        String[] param = { realm, name };
        logEvent("ATTEMPT_GET_PROVIDER_NAMES_UNDER_AUTH_DOMAIN", param);
        CircleOfTrustManager manager = getCircleOfTrustManager();
        CircleOfTrustDescriptor desc = manager.getCircleOfTrust(realm, name);
        providers = desc.getTrustedProviders();
        logEvent("SUCCEED_GET_PROVIDER_NAMES_UNDER_AUTH_DOMAIN", param);
    } catch (COTException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, name, strError };
        logEvent("FEDERATION_EXCEPTION_GET_PROVIDER_NAMES_UNDER_AUTH_DOMAIN", paramsEx);
        throw new AMConsoleException(strError);
    }
    return (providers != null) ? providers : Collections.EMPTY_SET;
}
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)

Example 24 with COTException

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

the class FSAuthDomainsModelImpl method getAuthenticationDomains.

/**
     * Returns a &lt;code>Set&lt;/code> of all the authentication domains 
     * starting from the root realm.
     *
     * @return a Set of authentication domain names.
     */
public Set getAuthenticationDomains() {
    Set results = null;
    String realm = "";
    try {
        CircleOfTrustManager manager = getCircleOfTrustManager();
        Set realms = getRealmNames("/", "*");
        for (Iterator i = realms.iterator(); i.hasNext(); ) {
            realm = (String) i.next();
            results.addAll(manager.getAllCirclesOfTrust(realm));
        }
    } 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 (results != null) ? results : Collections.EMPTY_SET;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) Iterator(java.util.Iterator) COTException(com.sun.identity.cot.COTException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 25 with COTException

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

the class FSAuthDomainsModelImpl method setAttributeValues.

/**
     * Set attribute values.
     *
     * @param name Name of authentication domain.
     * @param values Map of attribute name to value.
     * @throws IDFFMetaException if attribute values cannot be set.
     */
public void setAttributeValues(String realm, String name, Map values) throws AMConsoleException {
    String[] param = { realm, name };
    logEvent("ATTEMPT_MODIFY_AUTH_DOMAIN", param);
    try {
        CircleOfTrustManager manager = getCircleOfTrustManager();
        CircleOfTrustDescriptor desc = manager.getCircleOfTrust(realm, name);
        desc.setCircleOfTrustDescription((String) AMAdminUtils.getValue((Set) values.get(TF_DESCRIPTION)));
        desc.setIDFFWriterServiceURL((String) AMAdminUtils.getValue((Set) values.get(TF_IDFF_WRITER_SERVICE_URL)));
        desc.setIDFFReaderServiceURL((String) AMAdminUtils.getValue((Set) values.get(TF_IDFF_READER_SERVICE_URL)));
        desc.setSAML2WriterServiceURL((String) AMAdminUtils.getValue((Set) values.get(TF_SAML2_WRITER_SERVICE_URL)));
        desc.setSAML2ReaderServiceURL((String) AMAdminUtils.getValue((Set) values.get(TF_SAML2_READER_SERVICE_URL)));
        desc.setCircleOfTrustStatus((String) AMAdminUtils.getValue((Set) values.get(SINGLE_CHOICE_STATUS)));
        manager.modifyCircleOfTrust(realm, desc);
        logEvent("SUCCEED_MODIFY_AUTH_DOMAIN", param);
    } catch (COTException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, name, strError };
        logEvent("FEDERATION_EXCEPTION_MODIFY_AUTH_DOMAIN", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : 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

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