Search in sources :

Example 31 with AMAuthenticationManager

use of com.sun.identity.authentication.config.AMAuthenticationManager 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 32 with AMAuthenticationManager

use of com.sun.identity.authentication.config.AMAuthenticationManager 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 33 with AMAuthenticationManager

use of com.sun.identity.authentication.config.AMAuthenticationManager 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 34 with AMAuthenticationManager

use of com.sun.identity.authentication.config.AMAuthenticationManager 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)

Example 35 with AMAuthenticationManager

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

the class AuthPropertiesModelImpl method getAuthInstances.

public Set getAuthInstances() {
    Set instances = null;
    if (currentRealm != null) {
        String[] param = { currentRealm };
        logEvent("ATTEMPT_GET_AUTH_INSTANCE", param);
        try {
            AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), currentRealm);
            instances = mgr.getAuthenticationInstances();
            logEvent("SUCCEED_GET_AUTH_INSTANCE", param);
        } catch (AMConfigurationException e) {
            String strError = getErrorString(e);
            String[] paramsEx = { currentRealm, strError };
            logEvent("AUTH_CONFIG_EXCEPTION_GET_AUTH_INSTANCE", paramsEx);
            debug.warning("AuthPropertiesModelImpl.getAuthInstances", e);
        }
    }
    return (instances == null) ? Collections.EMPTY_SET : instances;
}
Also used : Set(java.util.Set) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) 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