Search in sources :

Example 36 with COTException

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

the class ImportMetaData method validateCOT.

private void validateCOT() throws CLIException {
    if ((cot != null) && (cot.length() > 0)) {
        try {
            CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
            if (!cotManager.getAllCirclesOfTrust(realm).contains(cot)) {
                String[] args = { realm, metadata, extendedData, cot, spec, getResourceString("import-entity-exception-cot-no-exist") };
                writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_IMPORT_ENTITY", args);
                throw new CLIException(getResourceString("import-entity-exception-cot-no-exist"), 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) CLIException(com.sun.identity.cli.CLIException) COTException(com.sun.identity.cot.COTException)

Example 37 with COTException

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

the class ImportMetaData method handleWSFedRequest.

private void handleWSFedRequest(RequestContext rc) throws CLIException {
    try {
        String federationID = null;
        List<String> newMetaAliases = null;
        com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement configElt = null;
        if (extendedData != null) {
            configElt = getWSFedEntityConfigElement();
            /*
                 * see note at the end of this class for how we decide
                 * the realm value
                 */
            if (configElt != null && configElt.isHosted()) {
                List config = configElt.getIDPSSOConfigOrSPSSOConfig();
                if (!config.isEmpty()) {
                    com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType bConfig = (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) config.iterator().next();
                    realm = WSFederationMetaUtils.getRealmByMetaAlias(bConfig.getMetaAlias());
                    newMetaAliases = getMetaAliases(config);
                }
            }
        }
        WSFederationMetaManager metaManager = new WSFederationMetaManager(ssoToken);
        if (metadata != null) {
            federationID = importWSFedMetaData();
        }
        if (configElt != null) {
            if (null != newMetaAliases && !newMetaAliases.isEmpty()) {
                metaManager.validateMetaAliasForNewEntity(realm, newMetaAliases);
            }
            metaManager.createEntityConfig(realm, configElt);
            String out = (webAccess) ? "web" : extendedData;
            Object[] objs = { out };
            getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("import-entity-succeeded"), objs));
        }
        if ((cot != null) && (cot.length() > 0) && (federationID != null)) {
            CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
            if (!cotManager.isInCircleOfTrust(realm, cot, spec, federationID)) {
                cotManager.addCircleOfTrustMember(realm, cot, spec, federationID);
            }
        }
    } catch (COTException e) {
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (WSFederationMetaException e) {
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : WSFederationMetaManager(com.sun.identity.wsfederation.meta.WSFederationMetaManager) CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) COTException(com.sun.identity.cot.COTException) BaseConfigType(com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType) CLIException(com.sun.identity.cli.CLIException) ArrayList(java.util.ArrayList) List(java.util.List) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException)

Example 38 with COTException

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

the class ListCircleOfTrustMembers method handleRequest.

/**
     * List members in a circle of trust.
     *
     * @param rc Request Context.
     * @throws CLIException if unable to process this request.
     */
@Override
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    realm = getStringOptionValue(FedCLIConstants.ARGUMENT_REALM, "/");
    cot = getStringOptionValue(FedCLIConstants.ARGUMENT_COT);
    IOutput outputWriter = getOutputWriter();
    spec = FederationManager.getIDFFSubCommandSpecification(rc);
    String[] params = { realm, cot, spec };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_LIST_COT_MEMBERS", params);
    try {
        CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
        Set circleOfTrusts = cotManager.getAllCirclesOfTrust(realm);
        if (!circleOfTrusts.contains(cot)) {
            Object[] obj = { cot };
            String[] args = { realm, cot, spec, MessageFormat.format(getResourceString("list-circle-of-trust-members-cot-does-not-exists"), obj) };
            writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_COT_MEMBERS", args);
            throw new CLIException(MessageFormat.format(getResourceString("list-circle-of-trust-members-cot-does-not-exists"), obj), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
        Set members = cotManager.listCircleOfTrustMember(realm, cot, spec);
        if ((members == null) || members.isEmpty()) {
            Object[] obj = { cot };
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-circle-of-trust-members-no-members"), obj));
        } else {
            Object[] obj = { cot };
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-circle-of-trust-members-members"), obj));
            for (Iterator i = members.iterator(); i.hasNext(); ) {
                String entityId = (String) i.next();
                outputWriter.printlnMessage("  " + entityId);
            }
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_LIST_COT_MEMBERS", params);
    } catch (COTException e) {
        debugWarning("ListCircleOfTrustMembers.handleRequest", e);
        String[] args = { realm, cot, spec, e.getMessage() };
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_COT_MEMBERS", args);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) Set(java.util.Set) IOutput(com.sun.identity.cli.IOutput) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException) COTException(com.sun.identity.cot.COTException)

Example 39 with COTException

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

the class ListCircleOfTrusts method handleRequest.

/**
     * Lists circle of trusts.
     *
     * @param rc Request Context.
     * @throws CLIException if unable to process this request.
     */
@Override
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    realm = getStringOptionValue(FedCLIConstants.ARGUMENT_REALM, "/");
    IOutput outputWriter = getOutputWriter();
    String[] params = { realm };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_LIST_COTS", params);
    try {
        CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
        Set members = cotManager.getAllCirclesOfTrust(realm);
        if ((members == null) || members.isEmpty()) {
            Object[] obj = { realm };
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-circles-of-trust-no-members"), obj));
        } else {
            Object[] obj = { realm };
            outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-circles-of-trust-members"), obj));
            for (Iterator i = members.iterator(); i.hasNext(); ) {
                String cot = (String) i.next();
                outputWriter.printlnMessage("  " + cot);
            }
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_LIST_COTS", params);
    } catch (COTException e) {
        debugWarning("ListCircleOfTrusts.handleRequest", e);
        String[] args = { realm, e.getMessage() };
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_COTS", args);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) Set(java.util.Set) IOutput(com.sun.identity.cli.IOutput) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException) COTException(com.sun.identity.cot.COTException)

Example 40 with COTException

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

the class TaskModelImpl method getEntities.

/**
     * Returns a set of entities in a circle of trust.
     * 
     * @param realm Realm.
     * @param cotName Name of circle of trust.
     * @return a set of entities in a circle of trust.
     * @throws AMConsoleException if unable to retrieve entities.
     */
public Set getEntities(String realm, String cotName) throws AMConsoleException {
    try {
        CircleOfTrustManager mgr = new CircleOfTrustManager();
        Set entities = mgr.listCircleOfTrustMember(realm, cotName, COTConstants.SAML2);
        return (entities == null) ? Collections.EMPTY_SET : entities;
    } catch (COTException ex) {
        throw new AMConsoleException(ex.getMessage());
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) 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