Search in sources :

Example 6 with AuthConfigurationEntry

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

the class AuthConfigurationModelImpl method getModuleFlag.

/**
     * Gets the module flag 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 flag
     */
public String getModuleFlag(int idx) {
    String flag = null;
    AuthConfigurationEntry entry = (AuthConfigurationEntry) entryList.get(idx);
    if (entry != null) {
        flag = entry.getControlFlag();
    }
    return flag;
}
Also used : AuthConfigurationEntry(com.sun.identity.authentication.config.AuthConfigurationEntry)

Example 7 with AuthConfigurationEntry

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

the class UpdateAuthConfigurationEntries method getAuthConfigurationEntry.

private AuthConfigurationEntry getAuthConfigurationEntry(CommandManager mgr, String str) throws CLIException, AMConfigurationException {
    System.out.println(str);
    StringTokenizer st = new StringTokenizer(str, "|");
    if (st.countTokens() < 2) {
        throw AttributeValues.createIncorrectFormatException(mgr, str);
    }
    String name = st.nextToken();
    String flag = st.nextToken();
    String options = (st.countTokens() > 0) ? st.nextToken() : null;
    return new AuthConfigurationEntry(name, flag, options);
}
Also used : StringTokenizer(java.util.StringTokenizer) AuthConfigurationEntry(com.sun.identity.authentication.config.AuthConfigurationEntry)

Example 8 with AuthConfigurationEntry

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

the class AuthConfigViewBean method getTableData.

private List getTableData() throws ModelControlException {
    List entryList = new ArrayList();
    CCActionTable table = (CCActionTable) getChild(AUTH_ENTRY_TABLE);
    table.restoreStateData();
    int size = entryTableModel.getNumRows();
    for (int i = 0; i < size; i++) {
        entryTableModel.setRowIndex(i);
        String module = (String) entryTableModel.getValue(MODULE_NAME);
        String flag = (String) entryTableModel.getValue(CRITERIA);
        String option = (String) entryTableModel.getValue(OPTION_FIELD);
        try {
            AuthConfigurationEntry ae = new AuthConfigurationEntry(module, flag, option);
            entryList.add(ae);
        } catch (AMConfigurationException e) {
            debug.warning("AuthConfigViewBean.getTableData() " + "Couldn't create the auth configuration entry", e);
        }
    }
    return entryList;
}
Also used : ArrayList(java.util.ArrayList) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) ArrayList(java.util.ArrayList) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) CCActionTable(com.sun.web.ui.view.table.CCActionTable) AuthConfigurationEntry(com.sun.identity.authentication.config.AuthConfigurationEntry)

Example 9 with AuthConfigurationEntry

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

the class AuthConfigViewBean method handleAddEntryButtonRequest.

/**
     * Handles add auth instances request.
     *
     * @param event Request invocation event
     */
public void handleAddEntryButtonRequest(RequestInvocationEvent event) throws ModelControlException {
    // get the current values from the table so we don't 
    // overwrite any changes already made by the user.
    List currentEntries = getTableData();
    // create a new entry, add it to the list, and generat the xml
    // use the first entry from the available instances list as default
    Iterator i = getInstanceNames().iterator();
    String moduleName = (String) i.next();
    try {
        AuthConfigurationEntry ace = new AuthConfigurationEntry(moduleName, REQUIRED_FLAG, "");
        currentEntries.add(ace);
        acModel.setEntries(currentEntries);
        setPageSessionAttribute(ENTRY_LIST, acModel.getXMLValue(getRealmName(), getConfigName()));
    } catch (AMConfigurationException a) {
        debug.warning("AuthConfigViewBean.handleAddEntryButtonRequest() " + "Adding new config entry failed", a);
    }
    cacheValues();
    populateEntryTable();
    forwardTo();
}
Also used : Iterator(java.util.Iterator) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) ArrayList(java.util.ArrayList) OptionList(com.iplanet.jato.view.html.OptionList) List(java.util.List) AuthConfigurationEntry(com.sun.identity.authentication.config.AuthConfigurationEntry)

Example 10 with AuthConfigurationEntry

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

the class GetAuthConfigurationEntries 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[] params = { realm, configName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_GET_AUTH_CONFIG_ENTRIES", params);
    try {
        Map configData = AMAuthConfigUtils.getNamedConfig(configName, realm, adminSSOToken);
        IOutput outputWriter = getOutputWriter();
        boolean hasData = false;
        if ((configData != null) && !configData.isEmpty()) {
            Set tmp = (Set) configData.get(AuthOptions.AUTH_CONFIG_ATTR);
            if ((tmp != null) && !tmp.isEmpty()) {
                hasData = true;
                String xml = (String) tmp.iterator().next();
                List entryList = new ArrayList(AMAuthConfigUtils.xmlToAuthConfigurationEntry(xml));
                outputWriter.printlnMessage(getResourceString("authentication-get-auth-config-entries-succeeded"));
                for (Iterator i = entryList.iterator(); i.hasNext(); ) {
                    AuthConfigurationEntry e = (AuthConfigurationEntry) i.next();
                    String options = e.getOptions();
                    if (options == null) {
                        options = "";
                    }
                    Object[] args = { e.getLoginModuleName(), e.getControlFlag(), options };
                    outputWriter.printlnMessage(MessageFormat.format(getResourceString("authentication-get-auth-config-entries-entry"), args));
                }
            }
        } else {
            writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_AUTH_CONFIG_ENTRIES", params);
            throw new CLIException(getResourceString("authentication-get-auth-config-entries-not-found"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
        }
        if (!hasData) {
            outputWriter.printlnMessage(getResourceString("authentication-get-auth-config-entries-no-values"));
        }
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_GET_AUTH_CONFIG_ENTRIES", params);
    } catch (AMConfigurationException e) {
        debugError("GetAuthConfigurationEntries.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_AUTH_CONFIG_ENTRIES", params);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        debugError("GetAuthConfigurationEntries.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_AUTH_CONFIG_ENTRIES", params);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        debugError("GetAuthConfigurationEntries.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_GET_AUTH_CONFIG_ENTRIES", 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) ArrayList(java.util.ArrayList) SSOException(com.iplanet.sso.SSOException) AuthConfigurationEntry(com.sun.identity.authentication.config.AuthConfigurationEntry) IOutput(com.sun.identity.cli.IOutput) Iterator(java.util.Iterator) CLIException(com.sun.identity.cli.CLIException) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

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