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());
}
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);
}
}
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();
}
}
}
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;
}
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;
}
Aggregations