Search in sources :

Example 6 with AMConfigurationException

use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.

the class ListAuthInstances method handleRequest.

/**
     * Handles request.
     *
     * @param rc Request Context.
     * @throws CLIException if request cannot be processed.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    String realm = getStringOptionValue(IArgument.REALM_NAME);
    String[] params = { realm };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_LIST_AUTH_INSTANCES", params);
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realm);
        Set instances = mgr.getAuthenticationInstances();
        if ((instances != null) && !instances.isEmpty()) {
            getOutputWriter().printlnMessage(getResourceString("authentication-list-auth-instance"));
            for (Iterator i = instances.iterator(); i.hasNext(); ) {
                AMAuthenticationInstance instance = (AMAuthenticationInstance) i.next();
                Object[] args = { instance.getName(), instance.getType() };
                getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("authentication-list-auth-instance-entry"), args));
            }
        } else {
            getOutputWriter().printlnMessage(getResourceString("authentication-list-auth-instance-empty"));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_LIST_AUTH_INSTANCES", params);
    } catch (AMConfigurationException e) {
        debugError("ListAuthInstances.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_AUTH_INSTANCES", params);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) Iterator(java.util.Iterator) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) CLIException(com.sun.identity.cli.CLIException) AMAuthenticationInstance(com.sun.identity.authentication.config.AMAuthenticationInstance) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 7 with AMConfigurationException

use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.

the class CreateAuthInstance method handleRequest.

/**
     * Handles request.
     *
     * @param rc Request Context.
     * @throws CLIException if request cannot be processed.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    String realm = getStringOptionValue(IArgument.REALM_NAME);
    String name = getStringOptionValue(AuthOptions.AUTH_INSTANCE_NAME);
    String type = getStringOptionValue(AuthOptions.AUTH_INSTANCE_TYPE);
    String[] params = { realm, name, type };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_CREATE_AUTH_INSTANCE", params);
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realm);
        AMAuthenticationSchema as = mgr.getAuthenticationSchema(type);
        mgr.createAuthenticationInstance(name, type, as.getAttributeValues());
        getOutputWriter().printlnMessage(getResourceString("authentication-created-auth-instance-succeeded"));
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_CREATE_AUTH_INSTANCE", params);
    } catch (AMConfigurationException e) {
        debugError("CreateAuthInstance.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_CREATE_AUTH_INSTANCE", params);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) AMAuthenticationSchema(com.sun.identity.authentication.config.AMAuthenticationSchema) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) CLIException(com.sun.identity.cli.CLIException) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 8 with AMConfigurationException

use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.

the class DeleteAuthInstances method handleRequest.

/**
     * Handles request.
     *
     * @param rc Request Context.
     * @throws CLIException if request cannot be processed.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    String realm = getStringOptionValue(IArgument.REALM_NAME);
    List names = (List) rc.getOption(AuthOptions.AUTH_INSTANCE_NAMES);
    String[] params = { realm, names.toString() };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_AUTH_INSTANCES", params);
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realm);
        for (Iterator i = names.iterator(); i.hasNext(); ) {
            String name = (String) i.next();
            mgr.deleteAuthenticationInstance(name);
        }
        if (names.size() == 1) {
            getOutputWriter().printlnMessage(getResourceString("authentication-delete-auth-instance-succeeded"));
        } else {
            getOutputWriter().printlnMessage(getResourceString("authentication-delete-auth-instances-succeeded"));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_DELETE_AUTH_INSTANCES", params);
    } catch (AMConfigurationException e) {
        debugError("DeleteAuthInstances,handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_AUTH_INSTANCES", params);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Iterator(java.util.Iterator) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) CLIException(com.sun.identity.cli.CLIException) List(java.util.List) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 9 with AMConfigurationException

use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.

the class SelectRealmModelImpl method getAuthenticationInstances.

/**
     * Returns set of authentication instances.
     *
     * @param realmName Name of Realm.
     * @return set of authentication instances.
     * @throws AMConsoleException if authentication instances cannot be
     *         obtained.
     */
public Set getAuthenticationInstances(String realmName) throws AMConsoleException {
    Set names = Collections.EMPTY_SET;
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), realmName);
        Set instances = mgr.getAuthenticationInstances();
        if ((instances != null) && !instances.isEmpty()) {
            names = new HashSet(instances.size());
            for (Iterator i = instances.iterator(); i.hasNext(); ) {
                names.add(((AMAuthenticationInstance) i.next()).getName());
            }
        }
    } catch (AMConfigurationException e) {
        throw new AMConsoleException(getErrorString(e));
    }
    return names;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager) HashSet(java.util.HashSet)

Example 10 with AMConfigurationException

use of com.sun.identity.authentication.config.AMConfigurationException in project OpenAM by OpenRock.

the class ConfigMonitoring method getAuthModules.

/*
     *  gather the auth modules for this (sub)"realm".  "realm" is
     *  "currentRealmAMIdName" from:
     *
     *    AMIdentityRepository idRepo =
     *      new AMIdentityRepository(ssoToken, realm);
     *    AMIdentity thisRealmAMId = idRepo.getRealmIdentity();
     *    String currentRealmAMIdName = thisRealmAMId.getRealm();
     */
private Set getAuthModules(String realm) {
    String classMethod = "ConfigMonitoring.getAuthModules: ";
    Set insts = Collections.EMPTY_SET;
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(ssoToken, realm);
        insts = mgr.getAuthenticationInstances();
    } catch (AMConfigurationException e) {
        debug.error(classMethod + "getting auth instances; " + e.getMessage());
    }
    return insts;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Aggregations

AMConfigurationException (com.sun.identity.authentication.config.AMConfigurationException)45 AMAuthenticationManager (com.sun.identity.authentication.config.AMAuthenticationManager)33 Set (java.util.Set)26 Iterator (java.util.Iterator)18 SSOException (com.iplanet.sso.SSOException)17 SSOToken (com.iplanet.sso.SSOToken)17 SMSException (com.sun.identity.sm.SMSException)17 HashSet (java.util.HashSet)17 AMAuthenticationInstance (com.sun.identity.authentication.config.AMAuthenticationInstance)16 CLIException (com.sun.identity.cli.CLIException)13 HashMap (java.util.HashMap)12 Map (java.util.Map)11 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 AMAuthenticationSchema (com.sun.identity.authentication.config.AMAuthenticationSchema)6 AuthConfigurationEntry (com.sun.identity.authentication.config.AuthConfigurationEntry)5 IOutput (com.sun.identity.cli.IOutput)5 JsonValue (org.forgerock.json.JsonValue)3 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)3