Search in sources :

Example 6 with CircleOfTrustManager

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

Example 7 with CircleOfTrustManager

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

the class CreateCircleOfTrust method handleRequest.

/**
     * Creates 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);
    prefix = getStringOptionValue(FedCLIConstants.ARGUMENT_PREFIX);
    trustedProviders = (List) rc.getOption(FedCLIConstants.ARGUMENT_TRUSTED_PROVIDERS);
    Set providers = new HashSet();
    if (trustedProviders != null) {
        providers.addAll(trustedProviders);
    }
    String[] params = { realm, cot, providers.toString(), prefix };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_CREATE_COT", params);
    try {
        CircleOfTrustDescriptor descriptor = ((prefix == null) || (prefix.trim().length() == 0)) ? new CircleOfTrustDescriptor(cot, realm, COTConstants.ACTIVE, "", null, null, null, null, providers) : new CircleOfTrustDescriptor(cot, realm, COTConstants.ACTIVE, "", prefix + "/idffreader", prefix + "/idffwriter", prefix + "/saml2reader", prefix + "/saml2writer", providers);
        CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
        cotManager.createCircleOfTrust(realm, descriptor);
        Object[] objs = { cot, realm };
        getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("create-circle-of-trust-succeeded"), objs));
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_CREATE_COT", params);
    } catch (COTException e) {
        debug.warning("CreateCircleOfTrust.handleRequest", e);
        String[] args = { realm, cot, providers.toString(), prefix, e.getMessage() };
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_COT", args);
        throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) CLIException(com.sun.identity.cli.CLIException) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) HashSet(java.util.HashSet)

Example 8 with CircleOfTrustManager

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

the class DeleteCircleOfTrust method handleRequest.

/**
     * Deletes 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);
    String[] params = { realm, cot };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_COT", params);
    try {
        CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
        cotManager.deleteCircleOfTrust(realm, cot);
        Object[] obj = { cot };
        getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("delete-circle-of-trust-succeeded"), obj));
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_DELETE_COT", params);
    } catch (COTException e) {
        debugWarning("DeleteCircleOfTrust.handleRequest", e);
        String[] args = { realm, cot, e.getMessage() };
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_COT", args);
        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 9 with CircleOfTrustManager

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

the class AddCircleOfTrustMembers method handleRequest.

/**
     * Adds member to 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);
    spec = FederationManager.getIDFFSubCommandSpecification(rc);
    entityID = getStringOptionValue(FedCLIConstants.ARGUMENT_ENTITY_ID);
    String[] params = { realm, entityID, cot, spec };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_COT_MEMBER", params);
    try {
        CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
        cotManager.addCircleOfTrustMember(realm, cot, spec, entityID);
        Object[] objs = { spec, cot, entityID, realm };
        getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("add-circle-of-trust-member-succeeded"), objs));
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_ADD_COT_MEMBER", params);
    } catch (COTException e) {
        debugWarning("AddCircleOfTrustMembers.handleRequest", e);
        if (e instanceof L10NMessage) {
            String[] args = { realm, entityID, cot, spec, ((L10NMessage) e).getL10NMessage(getCommandManager().getLocale()) };
            writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_COT_MEMBER", args);
            throw new CLIException(((L10NMessage) e).getL10NMessage(getCommandManager().getLocale()), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        } else {
            String[] args = { realm, entityID, cot, spec, e.getMessage() };
            writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_COT_MEMBER", args);
            throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
    }
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) L10NMessage(com.sun.identity.shared.locale.L10NMessage) CLIException(com.sun.identity.cli.CLIException) COTException(com.sun.identity.cot.COTException)

Example 10 with CircleOfTrustManager

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

the class FSAuthDomainsModelImpl method getAttributeValues.

/**
     * Returns attribute values.
     *
     * @param name Name of authentication domain.
     * @return Map of attribute name to values.
     * @throws AMConsoleException if attribute values cannot be retrieved.
     */
public Map getAttributeValues(String realm, String name) throws AMConsoleException {
    Map values = new HashMap(16);
    String[] param = { realm, name };
    logEvent("ATTEMPT_GET_AUTH_DOMAIN_ATTR_VALUES", param);
    try {
        CircleOfTrustManager manager = getCircleOfTrustManager();
        CircleOfTrustDescriptor desc = manager.getCircleOfTrust(realm, name);
        values.put(TF_DESCRIPTION, AMAdminUtils.wrapInSet(desc.getCircleOfTrustDescription()));
        values.put(TF_IDFF_WRITER_SERVICE_URL, AMAdminUtils.wrapInSet(desc.getIDFFWriterServiceURL()));
        values.put(TF_IDFF_READER_SERVICE_URL, AMAdminUtils.wrapInSet(desc.getIDFFReaderServiceURL()));
        values.put(TF_SAML2_WRITER_SERVICE_URL, AMAdminUtils.wrapInSet(desc.getSAML2WriterServiceURL()));
        values.put(TF_SAML2_READER_SERVICE_URL, AMAdminUtils.wrapInSet(desc.getSAML2ReaderServiceURL()));
        values.put(SINGLE_CHOICE_REALM, AMAdminUtils.wrapInSet(desc.getCircleOfTrustRealm()));
        values.put(SINGLE_CHOICE_STATUS, AMAdminUtils.wrapInSet(desc.getCircleOfTrustStatus()));
        logEvent("SUCCEED_GET_AUTH_DOMAIN_ATTR_VALUES", param);
    } catch (COTException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realm, name, strError };
        logEvent("FEDERATION_EXCEPTION_GET_AUTH_DOMAIN_ATTR_VALUES", paramsEx);
        throw new AMConsoleException(strError);
    }
    return values;
}
Also used : CircleOfTrustManager(com.sun.identity.cot.CircleOfTrustManager) HashMap(java.util.HashMap) CircleOfTrustDescriptor(com.sun.identity.cot.CircleOfTrustDescriptor) COTException(com.sun.identity.cot.COTException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

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