Search in sources :

Example 1 with PWResetQuestionModel

use of com.sun.identity.password.ui.model.PWResetQuestionModel in project OpenAM by OpenRock.

the class PWResetQuestionViewBean method beginDisplay.

/**
     * Set the required information to display the page.
     *
     * @param event display event.
     * @throws ModelControlException if problem access value of component.
     */
public void beginDisplay(DisplayEvent event) throws ModelControlException {
    super.beginDisplay(event);
    PWResetQuestionModel model = (PWResetQuestionModel) getModel();
    String orgDN = (String) getPageSessionAttribute(ORG_DN);
    String userDN = (String) getPageSessionAttribute(USER_DN);
    PWResetQuestionTiledView tView = (PWResetQuestionTiledView) getChild(PASSWORD_RESET_TILEDVIEW);
    tView.populateQuestionsList(userDN, orgDN);
    String value = (String) getPageSessionAttribute(USER_ATTR_VALUE);
    setDisplayFieldValue(PW_QUESTION_TITLE, model.getPWQuestionTitleString(value));
    setDisplayFieldValue(BUTTON_OK, model.getOKBtnLabel());
    setDisplayFieldValue(BUTTON_PREVIOUS, model.getPreviousBtnLabel());
}
Also used : PWResetQuestionModel(com.sun.identity.password.ui.model.PWResetQuestionModel)

Example 2 with PWResetQuestionModel

use of com.sun.identity.password.ui.model.PWResetQuestionModel in project OpenAM by OpenRock.

the class PWResetQuestionTiledView method populateQuestionsList.

/**
     * Populates secret question list
     *
     * @param userDN  user DN
     * @param orgDN  organization DN
     */
public void populateQuestionsList(String userDN, String orgDN) {
    PWResetQuestionModel model = getModel();
    int maxQuestions = model.getMaxNumQuestions(DNMapper.orgNameToRealmName(orgDN));
    Map secretMap = model.getSecretQuestions(userDN, orgDN);
    if (secretMap != null && !secretMap.isEmpty()) {
        if (maxQuestions >= 0 && maxQuestions < secretMap.size()) {
            map = new HashMap(maxQuestions);
            Set secretSet = secretMap.keySet();
            Iterator it = secretSet.iterator();
            int i = 0;
            while (it.hasNext()) {
                Object obj = (Object) it.next();
                map.put(obj, secretMap.get(obj));
                i++;
                if (i == maxQuestions) {
                    break;
                }
            }
        } else {
            map = new HashMap(secretMap.size());
            map.putAll(secretMap);
        }
    }
    if (map != null && !map.isEmpty()) {
        Set set = map.keySet();
        list = new ArrayList(set);
    }
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) PWResetQuestionModel(com.sun.identity.password.ui.model.PWResetQuestionModel)

Example 3 with PWResetQuestionModel

use of com.sun.identity.password.ui.model.PWResetQuestionModel in project OpenAM by OpenRock.

the class PWResetQuestionViewBean method handleBtnOKRequest.

/**
     * Handles form submission request for next button. It will
     * forward to <code>PWResetSuccessViewBean</code> if the answers
     * are correct for the questions.
     *
     * @param event request invocation event
     */
public void handleBtnOKRequest(RequestInvocationEvent event) {
    PWResetQuestionModel model = (PWResetQuestionModel) getModel();
    String orgDN = (String) getPageSessionAttribute(ORG_DN);
    String userDN = (String) getPageSessionAttribute(USER_DN);
    RequestContext reqContext = event.getRequestContext();
    ISLocaleContext localeContext = new ISLocaleContext();
    localeContext.setLocale(reqContext.getRequest());
    java.util.Locale localeObj = localeContext.getLocale();
    String locale = localeObj.toString();
    model.setUserLocale(locale);
    PWResetQuestionTiledView tView = (PWResetQuestionTiledView) getChild(PASSWORD_RESET_TILEDVIEW);
    Map map = tView.getAnswers();
    if (tView.isAnswerBlank()) {
        setErrorMessage(model.getErrorTitle(), model.getMissingAnswerMessage());
        forwardTo();
    } else {
        try {
            model.resetPassword(userDN, orgDN, map);
            PWResetSuccessViewBean vb = (PWResetSuccessViewBean) getViewBean(PWResetSuccessViewBean.class);
            vb.setResetMessage(model.getPasswordResetMessage());
            vb.setPageSessionAttribute(URL_LOCALE, locale);
            vb.forwardTo(getRequestContext());
        } catch (PWResetException pwe) {
            if (!model.isUserLockout(userDN, orgDN)) {
                setErrorMessage(model.getErrorTitle(), pwe.getMessage());
            }
            forwardTo();
        }
    }
}
Also used : PWResetException(com.sun.identity.password.ui.model.PWResetException) RequestContext(com.iplanet.jato.RequestContext) ISLocaleContext(com.sun.identity.common.ISLocaleContext) Map(java.util.Map) PWResetQuestionModel(com.sun.identity.password.ui.model.PWResetQuestionModel)

Example 4 with PWResetQuestionModel

use of com.sun.identity.password.ui.model.PWResetQuestionModel in project OpenAM by OpenRock.

the class PWResetQuestionTiledView method nextTile.

/**
     * Moves the current tile position to the next available tile.
     *
     * @return true if another tile was available, false if the position
     *         remained unchanged because no next tile was available.
     *
     * @throws ModelControlException if manipulation of model fails.
     */
public boolean nextTile() throws ModelControlException {
    boolean movedToRow = super.nextTile();
    PWResetQuestionModel model = getModel();
    if (movedToRow) {
        String question = (String) list.get(getTileIndex());
        String localizedStr = model.getLocalizedStrForQuestion(question);
        HiddenField hf = (HiddenField) getChild(FLD_ATTR_NAME);
        hf.setValue(question);
        setDisplayFieldValue(LBL_QUESTION, localizedStr);
    }
    return movedToRow;
}
Also used : HiddenField(com.iplanet.jato.view.html.HiddenField) PWResetQuestionModel(com.sun.identity.password.ui.model.PWResetQuestionModel)

Example 5 with PWResetQuestionModel

use of com.sun.identity.password.ui.model.PWResetQuestionModel in project OpenAM by OpenRock.

the class PWResetQuestionTiledView method getAnswers.

/**
     * Gets the answer to the secret question
     *
     * @return answer to the secret question
     */
public Map getAnswers() {
    Map map = Collections.EMPTY_MAP;
    PWResetQuestionModel model = getModel();
    try {
        DatasetModel dataModel = getPrimaryModel();
        int size = dataModel.getSize();
        if (size > 0) {
            dataModel.first();
            map = new HashMap(size);
        }
        for (int i = 0; i < size; i++) {
            HiddenField hf = (HiddenField) getChild(FLD_ATTR_NAME);
            String attrName = (String) hf.getValue();
            String answer = (String) getDisplayFieldValue(TF_ANSWER);
            if (answer != null) {
                answer = answer.trim();
            }
            if (answer == null || answer.length() == 0) {
                missingData = true;
            }
            map.put(attrName, answer);
            dataModel.next();
        }
    } catch (ModelControlException mce) {
        model.debugError("PWResetQuestionTiledView.getAnswers", mce);
    }
    return map;
}
Also used : HashMap(java.util.HashMap) HiddenField(com.iplanet.jato.view.html.HiddenField) ModelControlException(com.iplanet.jato.model.ModelControlException) HashMap(java.util.HashMap) Map(java.util.Map) DatasetModel(com.iplanet.jato.model.DatasetModel) PWResetQuestionModel(com.sun.identity.password.ui.model.PWResetQuestionModel)

Aggregations

PWResetQuestionModel (com.sun.identity.password.ui.model.PWResetQuestionModel)8 Map (java.util.Map)4 HiddenField (com.iplanet.jato.view.html.HiddenField)2 ISLocaleContext (com.sun.identity.common.ISLocaleContext)2 HashMap (java.util.HashMap)2 RequestContext (com.iplanet.jato.RequestContext)1 DatasetModel (com.iplanet.jato.model.DatasetModel)1 ModelControlException (com.iplanet.jato.model.ModelControlException)1 PWResetException (com.sun.identity.password.ui.model.PWResetException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1