Search in sources :

Example 26 with AMAuthenticationManager

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

the class AddAuthConfigurationEntry method getInstanceNames.

private Set getInstanceNames(String realm, SSOToken adminSSOToken) throws AMConfigurationException {
    Set names = new HashSet();
    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());
    }
    return names;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) AMAuthenticationInstance(com.sun.identity.authentication.config.AMAuthenticationInstance) HashSet(java.util.HashSet) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 27 with AMAuthenticationManager

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

the class GetSupportedAuthModules method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    SSOToken adminSSOToken = getAdminSSOToken();
    IOutput outputWriter = getOutputWriter();
    String[] params = {};
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_GET_SUPPORTED_AUTH_MODULES", params);
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, "/");
        Set types = mgr.getAuthenticationTypes();
        if ((types != null) && !types.isEmpty()) {
            Set sorted = new TreeSet();
            sorted.addAll(types);
            for (Iterator iter = sorted.iterator(); iter.hasNext(); ) {
                String type = (String) iter.next();
                outputWriter.printlnMessage(type);
            }
        } else {
            outputWriter.printlnMessage(getResourceString("get-supported-no-supported-authtype"));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_GET_SUPPORTED_AUTH_MODULES", params);
    } catch (AMConfigurationException e) {
        String[] args = { e.getMessage() };
        debugError("GetSupportedAuthModules.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_SUPPORTED_AUTH_MODULES", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) TreeSet(java.util.TreeSet) IOutput(com.sun.identity.cli.IOutput) TreeSet(java.util.TreeSet) Iterator(java.util.Iterator) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) CLIException(com.sun.identity.cli.CLIException) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 28 with AMAuthenticationManager

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

the class AMAuthUtils method addModInstanceNames.

private static void addModInstanceNames(String realmName, String moduleType, List modInstances) {
    try {
        SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
        AMAuthenticationManager amAM = new AMAuthenticationManager(adminToken, realmName);
        Set instanceNames = amAM.getModuleInstanceNames(moduleType);
        modInstances.addAll(instanceNames);
    } catch (AMConfigurationException exp) {
        utilDebug.error("AMAuthUtils.addModInstanceNames: Error while" + " trying to get auth module instance names " + "for auth type" + moduleType);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 29 with AMAuthenticationManager

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

the class ServicesModelImpl method getAssignedServiceNames.

/**
     * Returns a map of assigned service name to its localized name under a
     * realm.
     *
     * @param realmName Name of Realm.
     * @return a map of assigned service name to its localized name under a
     *         realm.
     * @throws AMConsoleException if service names cannot be obtained.
     */
public Map getAssignedServiceNames(String realmName) throws AMConsoleException {
    String[] param = { realmName };
    logEvent("ATTEMPT_GET_ASSIGNED_SERVICE_OF_REALM", param);
    try {
        OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realmName);
        Set names = orgCfgMgr.getAssignedServices();
        if ((names == null) || names.isEmpty()) {
            names = new HashSet();
        }
        getIdentityServices(realmName, names);
        /*
             * Need to use adminSSOToken because policy admin does not
             * have the correct privileges.
             */
        AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realmName);
        AMAdminUtils.removeAllCaseIgnore(names, mgr.getAuthenticationServiceNames());
        removeNonDisplayableServices(names, SUPPORTED_SCHEMA_TYPE);
        // remove auth configuration service too
        names.remove(AMAdminConstants.AUTH_CONFIG_SERVICE);
        names.remove(AMAdminConstants.CORE_AUTH_SERVICE);
        /*
            Creation and edit of instances of the Rest/Soap STS services handled by the STS tab.
             */
        names.remove(AMAdminConstants.REST_STS_SERVICE);
        names.remove(AMAdminConstants.SOAP_STS_SERVICE);
        logEvent("SUCCEED_GET_ASSIGNED_SERVICE_OF_REALM", param);
        return mapNameToDisplayName(names);
    } catch (AMConfigurationException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, strError };
        logEvent("CONFIGURATION_EXCEPTION_GET_ASSIGNED_SERVICE_OF_REALM", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, strError };
        logEvent("SMS_EXCEPTION_GET_ASSIGNED_SERVICE_OF_REALM", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashSet(java.util.HashSet) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 30 with AMAuthenticationManager

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

the class ServicesModelImpl method getAssignableServiceNames.

/**
     * Returns a map of service name to its display name that can be assigned
     * to a realm.
     *
     * @param realmName Name of Realm.
     * @return a map of service name to its display name that can be assigned
     * to a realm.
     * @throws AMConsoleException if service names cannot be obtained.
     */
public Map getAssignableServiceNames(String realmName) throws AMConsoleException {
    String[] param = { realmName };
    logEvent("ATTEMPT_GET_ASSIGNABLE_SERVICE_OF_REALM", param);
    try {
        OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realmName);
        Set names = orgCfgMgr.getAssignableServices();
        addIdentityUnassignedServices(realmName, names);
        names.removeAll(orgCfgMgr.getAssignedServices());
        AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), realmName);
        AMAdminUtils.removeAllCaseIgnore(names, mgr.getAuthenticationServiceNames());
        removeNonDisplayableServices(names, SUPPORTED_SCHEMA_TYPE);
        names.remove(AMAdminConstants.CORE_AUTH_SERVICE);
        /*
            Creation and edit of instances of the Rest/Soap STS services handled by the STS tab.
             */
        names.remove(AMAdminConstants.REST_STS_SERVICE);
        names.remove(AMAdminConstants.SOAP_STS_SERVICE);
        logEvent("SUCCEED_GET_ASSIGNABLE_SERVICE_OF_REALM", param);
        return mapNameToDisplayName(names);
    } catch (AMConfigurationException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, strError };
        logEvent("CONFIGURATION_EXCEPTION_GET_ASSIGNABLE_SERVICE_OF_REALM", paramsEx);
        if (debug.warningEnabled()) {
            debug.warning("ServicesModel.getAssignableServiceNames " + strError);
        }
        throw new AMConsoleException("no.properties");
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, strError };
        logEvent("SMS_EXCEPTION_GET_ASSIGNABLE_SERVICE_OF_REALM", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

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