Search in sources :

Example 16 with AMAuthenticationManager

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

the class AuthenticationModuleCollectionHandler method getSchemaManager.

private ServiceSchemaManager getSchemaManager(String authType) throws SSOException, SMSException, AMConfigurationException {
    AMAuthenticationManager authenticationManager = new AMAuthenticationManager(adminToken, "/");
    AMAuthenticationSchema schema = authenticationManager.getAuthenticationSchema(authType);
    return new ServiceSchemaManager(schema.getServiceName(), adminToken);
}
Also used : AMAuthenticationSchema(com.sun.identity.authentication.config.AMAuthenticationSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 17 with AMAuthenticationManager

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

the class UpdateAuthConfigurationEntries method getInstanceNames.

private Set getInstanceNames(String realm, SSOToken adminSSOToken, String[] params) throws CLIException {
    Set names = new HashSet();
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realm);
        Set instances = mgr.getAuthenticationInstances();
        for (Iterator i = instances.iterator(); i.hasNext(); ) {
            AMAuthenticationInstance instance = (AMAuthenticationInstance) i.next();
            names.add(instance.getName());
        }
    } catch (AMConfigurationException e) {
        debugError("ListAuthInstances.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_AUTH_CONFIG_ENTRIES", params);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
    return names;
}
Also used : HashSet(java.util.HashSet) 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) HashSet(java.util.HashSet) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 18 with AMAuthenticationManager

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

the class UpdateAuthInstance 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 instanceName = getStringOptionValue(AuthOptions.AUTH_INSTANCE_NAME);
    String datafile = getStringOptionValue(IArgument.DATA_FILE);
    List attrValues = rc.getOption(IArgument.ATTRIBUTE_VALUES);
    if ((datafile == null) && (attrValues == null)) {
        throw new CLIException(getResourceString("missing-attributevalues"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
    }
    Map<String, Set<String>> attributeValues = AttributeValues.parse(getCommandManager(), datafile, attrValues);
    attributeValues = processFileAttributes(attributeValues);
    String[] params = { realm, instanceName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_UPDATE_AUTH_INSTANCE", params);
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realm);
        AMAuthenticationInstance ai = mgr.getAuthenticationInstance(instanceName);
        if (ai != null) {
            ai.setAttributeValues(attributeValues);
            getOutputWriter().printlnMessage(getResourceString("authentication-update-auth-instance-succeeded"));
            writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_UPDATE_AUTH_INSTANCE", params);
        } else {
            writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AUTH_INSTANCE", params);
            throw new CLIException(getResourceString("authentication-update-auth-instance-not-found"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
    } catch (AMConfigurationException e) {
        debugError("UpdateAuthInstance.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AUTH_INSTANCE", params);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        debugError("UpdateAuthInstance.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AUTH_INSTANCE", params);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        debugError("UpdateAuthInstance.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_UPDATE_AUTH_INSTANCE", params);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) CLIException(com.sun.identity.cli.CLIException) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) List(java.util.List) AMAuthenticationInstance(com.sun.identity.authentication.config.AMAuthenticationInstance) SSOException(com.iplanet.sso.SSOException) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 19 with AMAuthenticationManager

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

the class PolicyModelImpl method getAuthenticationLevel.

/**
     * Returns authentication level of an authentication instance.
     *
     * @param realmName Name of realm.
     * @param name Authentication Instance name.
     * @return authentication level of an authentication instance.
     */
public String getAuthenticationLevel(String realmName, String name) {
    String level = "0";
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realmName);
        AMAuthenticationInstance ai = mgr.getAuthenticationInstance(name);
        Map map = ai.getAttributeValues();
        String authType = ai.getType();
        Set set = (Set) map.get(AMAuthConfigUtils.getAuthLevelAttribute(map, authType));
        if ((set != null) && !set.isEmpty()) {
            level = (String) set.iterator().next();
        }
    } catch (AMConfigurationException e) {
        debug.warning("PolicyModelImpl.getInstanceValues", e);
    }
    return level;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMAuthenticationInstance(com.sun.identity.authentication.config.AMAuthenticationInstance) Map(java.util.Map) HashMap(java.util.HashMap) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 20 with AMAuthenticationManager

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

the class PolicyModelImpl method getAuthInstances.

/**
     * Returns authentication instances configured for the realm.
     *
     * @param realmName Name of realm.
     * @return authentication instances configured for the realm.
     */
public Set getAuthInstances(String realmName) {
    Set instances = null;
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realmName);
        Set inst = mgr.getAuthenticationInstances();
        if ((inst != null) && !inst.isEmpty()) {
            instances = new HashSet(inst.size() * 2);
            for (Iterator iter = inst.iterator(); iter.hasNext(); ) {
                AMAuthenticationInstance i = (AMAuthenticationInstance) iter.next();
                instances.add(i.getName());
            }
        }
    } catch (AMConfigurationException e) {
        debug.warning("PolicyModelImpl.getAuthInstances", e);
    }
    return (instances == null) ? Collections.EMPTY_SET : instances;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMAuthenticationInstance(com.sun.identity.authentication.config.AMAuthenticationInstance) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager) HashSet(java.util.HashSet)

Aggregations

AMAuthenticationManager (com.sun.identity.authentication.config.AMAuthenticationManager)43 AMConfigurationException (com.sun.identity.authentication.config.AMConfigurationException)35 Set (java.util.Set)28 AMAuthenticationInstance (com.sun.identity.authentication.config.AMAuthenticationInstance)22 HashSet (java.util.HashSet)18 Iterator (java.util.Iterator)16 SSOToken (com.iplanet.sso.SSOToken)15 SSOException (com.iplanet.sso.SSOException)10 HashMap (java.util.HashMap)10 SMSException (com.sun.identity.sm.SMSException)9 Map (java.util.Map)8 AMAuthenticationSchema (com.sun.identity.authentication.config.AMAuthenticationSchema)7 CLIException (com.sun.identity.cli.CLIException)7 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)7 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)3 ServiceConfig (com.sun.identity.sm.ServiceConfig)3 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)3 AMException (com.iplanet.am.sdk.AMException)2 SessionException (com.iplanet.dpro.session.SessionException)2 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)2