Search in sources :

Example 1 with AuthConfigurationEntry

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

the class AddAuthConfigurationEntry 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 configName = getStringOptionValue(AuthOptions.AUTH_CONFIG_NAME);
    String moduleName = getStringOptionValue(AuthOptions.AUTH_CONFIG_MODULE_NAME);
    String criteria = getStringOptionValue(AuthOptions.AUTH_CONFIG_CRITERIA);
    String options = getStringOptionValue(AuthOptions.AUTH_CONFIG_OPTIONS);
    String[] params = { realm, configName, moduleName };
    if (!POSSIBLE_CRITERIA.contains(criteria)) {
        throw new CLIException(getResourceString("authentication-add-auth-config-entry-criteria.invalid"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
    int pos = getPosition();
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_AUTH_CONFIG_ENTRY", params);
    try {
        AuthConfigurationEntry ae = new AuthConfigurationEntry(moduleName, criteria, options);
        Set instanceNames = getInstanceNames(realm, adminSSOToken);
        String instanceName = ae.getLoginModuleName();
        if (!instanceNames.contains(instanceName)) {
            Object[] p = { instanceName };
            throw new CLIException(MessageFormat.format(getResourceString("authentication-add-auth-config-entry-not-found"), p), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
        List entries = getConfigEntries(realm, configName, adminSSOToken);
        if (entries == null) {
            entries = new ArrayList();
        }
        if ((pos == -1) || (pos >= entries.size())) {
            entries.add(ae);
        } else {
            entries.add(pos, ae);
        }
        Map configData = new HashMap(2);
        Set tmp = new HashSet(2);
        String xml = AMAuthConfigUtils.authConfigurationEntryToXMLString(entries);
        tmp.add(xml);
        configData.put(AuthOptions.AUTH_CONFIG_ATTR, tmp);
        IOutput outputWriter = getOutputWriter();
        AMAuthConfigUtils.replaceNamedConfig(configName, 0, configData, realm, adminSSOToken);
        outputWriter.printlnMessage(getResourceString("authentication-add-auth-config-entry-succeeded"));
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_ADD_AUTH_CONFIG_ENTRY", params);
    } catch (AMConfigurationException e) {
        debugError("GetAuthConfigurationEntries.handleRequest", e);
        String[] p = { realm, configName, moduleName, e.getMessage() };
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AUTH_CONFIG_ENTRY", p);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        debugError("GetAuthConfigurationEntries.handleRequest", e);
        String[] p = { realm, configName, moduleName, e.getMessage() };
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AUTH_CONFIG_ENTRY", p);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        debugError("GetAuthConfigurationEntries.handleRequest", e);
        String[] p = { realm, configName, moduleName, e.getMessage() };
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_AUTH_CONFIG_ENTRY", p);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) ArrayList(java.util.ArrayList) SSOException(com.iplanet.sso.SSOException) AuthConfigurationEntry(com.sun.identity.authentication.config.AuthConfigurationEntry) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 2 with AuthConfigurationEntry

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

the class UpdateAuthConfigurationEntries method validateEntries.

private void validateEntries(String realm, SSOToken adminSSOToken, List entries, String[] params) throws CLIException {
    if ((entries != null) && !entries.isEmpty()) {
        Set instanceNames = getInstanceNames(realm, adminSSOToken, params);
        for (Iterator i = entries.iterator(); i.hasNext(); ) {
            AuthConfigurationEntry token = (AuthConfigurationEntry) i.next();
            String instanceName = token.getLoginModuleName();
            if (!instanceNames.contains(instanceName)) {
                Object[] p = { instanceName };
                throw new CLIException(MessageFormat.format(getResourceString("authentication-set-auth-config-entries-instance-not-found"), p), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
            }
        }
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException) AuthConfigurationEntry(com.sun.identity.authentication.config.AuthConfigurationEntry)

Example 3 with AuthConfigurationEntry

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

the class ReorderAuthChainsViewBean method beginDisplay.

public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    CCOrderableList list = (CCOrderableList) getChild(REORDER_LIST);
    CCOrderableListModel model = (CCOrderableListModel) list.getModel();
    String xml = (String) getPageSessionAttribute(AuthConfigViewBean.ENTRY_LIST);
    List chains = new ArrayList(AMAuthConfigUtils.xmlToAuthConfigurationEntry(xml));
    OptionList optList = new OptionList();
    int sz = chains.size();
    for (int i = 0; i < sz; i++) {
        AuthConfigurationEntry entry = (AuthConfigurationEntry) chains.get(i);
        String name = entry.getLoginModuleName();
        String flag = entry.getControlFlag();
        String options = entry.getOptions();
        String displayName = name + " - " + flag;
        if ((options != null) && (options.trim().length() > 0)) {
            displayName += " - " + options;
        }
        optList.add(displayName, Integer.toString(i));
    }
    model.setSelectedOptionList(optList);
}
Also used : CCOrderableListModel(com.sun.web.ui.model.CCOrderableListModel) ArrayList(java.util.ArrayList) CCOrderableList(com.sun.web.ui.view.orderablelist.CCOrderableList) ArrayList(java.util.ArrayList) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) CCOrderableList(com.sun.web.ui.view.orderablelist.CCOrderableList) OptionList(com.iplanet.jato.view.html.OptionList) AuthConfigurationEntry(com.sun.identity.authentication.config.AuthConfigurationEntry)

Example 4 with AuthConfigurationEntry

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

the class AuthConfigurationModelImpl method getModuleName.

/**
     * Gets the module name for the given module index in the current
     * authentication configuration attributes
     *
     * @param idx the index of the module to retrieve name from.
     * @return the module name
     */
public String getModuleName(int idx) {
    String name = null;
    AuthConfigurationEntry entry = (AuthConfigurationEntry) entryList.get(idx);
    if (entry != null) {
        name = entry.getLoginModuleName();
    }
    return name;
}
Also used : AuthConfigurationEntry(com.sun.identity.authentication.config.AuthConfigurationEntry)

Example 5 with AuthConfigurationEntry

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

the class AuthConfigurationModelImpl method getModuleOptions.

/**
     * Gets the module options string for the given module index in the
     * current authentication configuration attributes
     *
     * @param idx the index of the module to retrieve Flag from.
     * @return the module options string
     */
public String getModuleOptions(int idx) {
    String options = null;
    AuthConfigurationEntry entry = (AuthConfigurationEntry) entryList.get(idx);
    if (entry != null) {
        options = entry.getOptions();
    }
    return options;
}
Also used : AuthConfigurationEntry(com.sun.identity.authentication.config.AuthConfigurationEntry)

Aggregations

AuthConfigurationEntry (com.sun.identity.authentication.config.AuthConfigurationEntry)12 ArrayList (java.util.ArrayList)6 AMConfigurationException (com.sun.identity.authentication.config.AMConfigurationException)5 List (java.util.List)5 OptionList (com.iplanet.jato.view.html.OptionList)3 CLIException (com.sun.identity.cli.CLIException)3 Iterator (java.util.Iterator)3 Set (java.util.Set)3 SSOException (com.iplanet.sso.SSOException)2 SSOToken (com.iplanet.sso.SSOToken)2 IOutput (com.sun.identity.cli.IOutput)2 SMSException (com.sun.identity.sm.SMSException)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 JsonValue (org.forgerock.json.JsonValue)2 CCOrderableListModel (com.sun.web.ui.model.CCOrderableListModel)1 CCOrderableList (com.sun.web.ui.view.orderablelist.CCOrderableList)1 CCActionTable (com.sun.web.ui.view.table.CCActionTable)1 HashMap (java.util.HashMap)1 StringTokenizer (java.util.StringTokenizer)1