Search in sources :

Example 16 with AMConfigurationException

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

the class AuthPropertiesModelImpl method createAuthInstance.

public void createAuthInstance(String name, String type) throws AMConsoleException {
    String[] params = { currentRealm, name, type };
    logEvent("ATTEMPT_CREATE_AUTH_INSTANCE", params);
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), currentRealm);
        AMAuthenticationSchema as = mgr.getAuthenticationSchema(type);
        mgr.createAuthenticationInstance(name, type, as.getAttributeValues());
        logEvent("SUCCEED_CREATE_AUTH_INSTANCE", params);
    } catch (AMConfigurationException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { currentRealm, name, type, strError };
        logEvent("AUTH_CONFIG_EXCEPTION_CREATE_AUTH_INSTANCE", paramsEx);
        debug.warning("AuthPropertiesModelImpl.createAuthInstance ", e);
        throw new AMConsoleException(strError);
    }
}
Also used : AMAuthenticationSchema(com.sun.identity.authentication.config.AMAuthenticationSchema) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 17 with AMConfigurationException

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

the class AuthPropertiesModelImpl method removeAuthInstance.

public void removeAuthInstance(Set names) throws AMConsoleException {
    StringBuilder errorList = new StringBuilder();
    String message = null;
    try {
        String[] params = new String[2];
        params[0] = currentRealm;
        AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), currentRealm);
        for (Iterator i = names.iterator(); i.hasNext(); ) {
            String instance = (String) i.next();
            params[1] = instance;
            logEvent("ATTEMPT_REMOVE_AUTH_INSTANCE", params);
            try {
                mgr.deleteAuthenticationInstance(instance);
                logEvent("SUCCEED_REMOVE_AUTH_INSTANCE", params);
            } catch (AMConfigurationException e) {
                String strError = getErrorString(e);
                String[] paramsEx = { currentRealm, instance, strError };
                logEvent("AUTH_CONFIG_EXCEPTION_REMOVE_AUTH_INSTANCE", paramsEx);
                debug.warning("failed to delete", e);
                message = e.getMessage();
                if (errorList.length() > 0) {
                    errorList.append(", ");
                }
                errorList.append(instance);
            }
        }
    } catch (AMConfigurationException ace) {
        String strError = getErrorString(ace);
        String[] paramsEx = { currentRealm, "*", strError };
        logEvent("AUTH_CONFIG_EXCEPTION_REMOVE_AUTH_INSTANCE", paramsEx);
        debug.error("cant delete auth instance: ", ace);
        throw new AMConsoleException(strError);
    }
    if (errorList.length() > 0) {
        String[] tmp = { errorList.toString(), message };
        throw new AMConsoleException(MessageFormat.format(getLocalizedString("authentication.instance.delete.failed"), (Object[]) tmp));
    }
}
Also used : 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)

Example 18 with AMConfigurationException

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

the class AuthPropertiesModelImpl method getAuthTypes.

public Map getAuthTypes() {
    Map authAndLocalizedTypes = Collections.EMPTY_MAP;
    try {
        logEvent("ATTEMPT_GET_AUTH_TYPE", getServerInstanceForLogMsg());
        AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), "/");
        Set types = mgr.getAuthenticationTypes();
        authAndLocalizedTypes = new HashMap(types.size());
        for (Iterator iter = types.iterator(); iter.hasNext(); ) {
            String authType = (String) iter.next();
            AMAuthenticationSchema schema = mgr.getAuthenticationSchema(authType);
            String svcName = schema.getServiceName();
            String localizedName = (svcName != null && svcName.length() > 0) ? getLocalizedServiceName(svcName) : authType;
            authAndLocalizedTypes.put(authType, localizedName);
        }
        logEvent("SUCCEED_GET_AUTH_TYPE", getServerInstanceForLogMsg());
    } catch (AMConfigurationException e) {
        String strError = getErrorString(e);
        String[] paramEx = { strError };
        logEvent("SMS_EXCEPTION_GET_AUTH_TYPE", paramEx);
        debug.warning("AuthPropertiesModelImpl.getAuthTypes", e);
    }
    return authAndLocalizedTypes;
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) AMAuthenticationSchema(com.sun.identity.authentication.config.AMAuthenticationSchema) Iterator(java.util.Iterator) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) HashMap(java.util.HashMap) Map(java.util.Map) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 19 with AMConfigurationException

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

the class AuthConfigurationModelImpl method createAuthConfiguration.

/** 
     * Creates a new named authentication configuration object. This object
     * will be used by the various objects for authentication.
     *
     * @param name used to reference the configuration.
     * @throws AMConsoleException if the configuration cannot be created.
     */
public void createAuthConfiguration(String name) throws AMConsoleException {
    if ((name == null) || (name.length() == 0)) {
        throw new AMConsoleException(getLocalizedString("authentication.config.missing.name"));
    }
    String[] params = { currentRealm, name };
    logEvent("ATTEMPT_CREATE_AUTH_CONFIG", params);
    String errorMsg = null;
    try {
        AMAuthConfigUtils.createNamedConfig(name, 0, new HashMap(), currentRealm, getUserSSOToken());
        logEvent("SUCCEED_CREATE_AUTH_CONFIG", params);
    } catch (SMSException e) {
        errorMsg = getErrorString(e);
        String[] paramsEx = { currentRealm, name, errorMsg };
        logEvent("SMS_EXCEPTION_CREATE_AUTH_CONFIG", paramsEx);
        debug.warning("problem creating auth instance", e);
    } catch (SSOException e) {
        errorMsg = getErrorString(e);
        String[] paramsEx = { currentRealm, name, errorMsg };
        logEvent("SSO_EXCEPTION_CREATE_AUTH_CONFIG", paramsEx);
        debug.warning("problem creating auth instance", e);
    } catch (AMConfigurationException e) {
        errorMsg = getErrorString(e);
        String[] paramsEx = { currentRealm, name, errorMsg };
        logEvent("AUTH_CONFIGURATION_EXCEPTION_CREATE_AUTH_CONFIG", paramsEx);
        debug.warning("problem creating auth instance", e);
    }
    // pass the error message back to the view bean...
    if (errorMsg != null) {
        throw new AMConsoleException(errorMsg);
    }
}
Also used : HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 20 with AMConfigurationException

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

the class AuthPropertiesModelImpl method setInstanceValues.

public void setInstanceValues(String instance, Map values) throws AMConsoleException {
    String[] params = { currentRealm, instance };
    logEvent("ATTEMPT_MODIFY_AUTH_INSTANCE_PROFILE", params);
    try {
        AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), currentRealm);
        AMAuthenticationInstance ai = mgr.getAuthenticationInstance(instance);
        ai.setAttributeValues(values);
        logEvent("SUCCEED_MODIFY_AUTH_INSTANCE_PROFILE", params);
    } catch (AMConfigurationException e) {
        debug.warning("AuthPropertiesModelImpl.setInstanceValues", e);
        String strError = getErrorString(e);
        String[] paramsEx = { currentRealm, instance, strError };
        logEvent("AUTH_CONFIGURATION_EXCEPTION_MODIFY_AUTH_INSTANCE_PROFILE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SMSException e) {
        debug.warning("AuthPropertiesModelImpl.setInstanceValues", e);
        String strError = getErrorString(e);
        String[] paramsEx = { currentRealm, instance, strError };
        logEvent("SMS_EXCEPTION_MODIFY_AUTH_INSTANCE_PROFILE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SSOException e) {
        debug.warning("AuthPropertiesModelImpl.setInstanceValues", e);
        String strError = getErrorString(e);
        String[] paramsEx = { currentRealm, instance, strError };
        logEvent("SSO_EXCEPTION_MODIFY_AUTH_INSTANCE_PROFILE", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMAuthenticationInstance(com.sun.identity.authentication.config.AMAuthenticationInstance) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) 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