8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: PWResetUserValidationViewBean.java,v 1.4 2010/01/28 08:17:10 bina Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
ebe2bbed96ad174bcd6fc7a1136fade167573ddbSachiko Wallace * Portions Copyrighted 2011-2014 ForgeRock AS
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.password.ui;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.RequestContext;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.model.ModelControlException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.view.View;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.view.event.ChildDisplayEvent;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.view.event.DisplayEvent;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.view.event.RequestInvocationEvent;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.view.html.Button;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.view.html.HiddenField;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.view.html.StaticTextField;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.view.html.TextField;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.authentication.service.AuthUtils;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.common.ISLocaleContext;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.password.ui.model.PWResetModel;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.password.ui.model.PWResetUserValidationModel;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.password.ui.model.PWResetUserValidationModelImpl;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport javax.servlet.http.HttpServletRequest;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.shared.debug.Debug;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Hashtable;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>PWResetUserValidationViewBean</code> validates user's identity for
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the password reset service.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class PWResetUserValidationViewBean extends PWResetViewBeanBase {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private final Debug debug = Debug.getInstance("PasswordReset");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of title peer component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String USER_VALIDATION_TITLE = "userValidationTitle";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of user validation peer component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String LBL_USER_ATTR = "lblUserAttr";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of component for user validation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String TF_USER_ATTR = "tfUserAttr";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of OK button peer component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String NEXT_BUTTON = "btnNext";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Page Name
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String PAGE_NAME = "PWResetUserValidation";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of user attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String FLD_USER_ATTR = "fldUserAttr";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of org attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String ORG = "org";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of realm attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String REALM = "realm";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Default display URL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String DEFAULT_DISPLAY_URL =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "/password/ui/PWResetUserValidation.jsp";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs a user validation view bean
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public PWResetUserValidationViewBean() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super(PAGE_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster registerChildren();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Registers child components/views
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected void registerChildren() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super.registerChildren();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster registerChild(USER_VALIDATION_TITLE, StaticTextField.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster registerChild(LBL_USER_ATTR, StaticTextField.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster registerChild(TF_USER_ATTR, TextField.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster registerChild(NEXT_BUTTON, Button.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster registerChild(FLD_USER_ATTR, HiddenField.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Creates child component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name of child component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return child component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected View createChild(String name) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster View child = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (name.equals(LBL_USER_ATTR)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster child = new StaticTextField(this, LBL_USER_ATTR, "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else if (name.equals(TF_USER_ATTR)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster child = new TextField(this, TF_USER_ATTR, "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else if (name.equals(NEXT_BUTTON)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster child = new Button(this, NEXT_BUTTON, "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else if (name.equals(USER_VALIDATION_TITLE)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster child = new StaticTextField(this, USER_VALIDATION_TITLE, "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else if (name.equals(FLD_USER_ATTR)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return new HiddenField(this, FLD_USER_ATTR, "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster child = super.createChild(name);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return child;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Set the required information to display the page.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param event display event.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws ModelControlException if problem access value of component.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void beginDisplay(DisplayEvent event)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws ModelControlException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super.beginDisplay(event);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PWResetUserValidationModel model =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster (PWResetUserValidationModel)getModel();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (model.isValidRealm()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgDN = (String)getPageSessionAttribute(ORG_DN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String userAttr = model.getUserAttr(orgDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster HiddenField hf = (HiddenField)getChild(FLD_USER_ATTR);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster hf.setValue(userAttr);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setDisplayFieldValue(USER_VALIDATION_TITLE,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model.getUserValidateTitleString());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setDisplayFieldValue(LBL_USER_ATTR,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model.getLocalizedStrForAttr(userAttr));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setDisplayFieldValue(NEXT_BUTTON, model.getNextBtnLabel());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String userAttrValue = (String)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster getPageSessionAttribute(USER_ATTR_VALUE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (userAttrValue != null && userAttrValue.length() > 0) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setDisplayFieldValue(TF_USER_ATTR, userAttrValue);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster removePageSessionAttribute(USER_ATTR_VALUE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Forwards to current view bean after validating organization
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param context request context
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void forwardTo(RequestContext context) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String classMethod = "PWResetUserValidationViewBean:forwardTo : ";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster HttpServletRequest req = context.getRequest();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PWResetUserValidationModel model =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster (PWResetUserValidationModel)getModel();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ISLocaleContext localeContext = new ISLocaleContext();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster localeContext.setLocale(req);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster java.util.Locale locale = localeContext.getLocale();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model.setUserLocale(locale.toString());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgDN = (String)getPageSessionAttribute(ORG_DN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (orgDN == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Hashtable reqDataHash = AuthUtils.parseRequestParameters(req);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgParam = AuthUtils.getOrgParam(reqDataHash);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String queryOrg = AuthUtils.getQueryOrgName(req, orgParam);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster orgDN = AuthUtils.getOrganizationDN(queryOrg, true, req);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model.setValidRealm(orgDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (debug.messageEnabled()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message(classMethod + "orgDN is :" + orgDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setPageSessionAttribute(ORG_DN, orgDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Set the flag to indicate that user enter the orgname in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the url.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (orgParam != null && orgParam.length() > 0) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setPageSessionAttribute(ORG_DN_FLAG, STRING_TRUE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model.setRealmFlag(true);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model.setValidRealm(orgDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super.forwardTo(context);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Handles form submission request
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param event request invocation event
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void handleBtnNextRequest(RequestInvocationEvent event) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PWResetUserValidationModel model =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster (PWResetUserValidationModel) getModel();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String userAttrValue = (String)getDisplayFieldValue(TF_USER_ATTR);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (userAttrValue != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster userAttrValue = userAttrValue.trim();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster HiddenField hf = (HiddenField)getChild(FLD_USER_ATTR);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String userAttrName = (String) hf.getValue();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgDN = (String)getPageSessionAttribute(ORG_DN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgDNFlag = (String)getPageSessionAttribute(ORG_DN_FLAG);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RequestContext reqContext = event.getRequestContext();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ISLocaleContext localeContext = new ISLocaleContext();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster localeContext.setLocale(reqContext.getRequest());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster java.util.Locale localeObj = localeContext.getLocale();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String locale = localeObj.toString();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model.setUserLocale(locale);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (orgDNFlag != null && orgDNFlag.equals (STRING_TRUE)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model.setRealmFlag(true);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (userAttrValue == null || userAttrValue.length() == 0) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setErrorMessage(model.getErrorTitle(),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model.getMissingUserAttrMessage(userAttrName));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster forwardTo();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
ebe2bbed96ad174bcd6fc7a1136fade167573ddbSachiko Wallace if (model.isUserAttrValueValid(orgDN, userAttrValue) &&
ebe2bbed96ad174bcd6fc7a1136fade167573ddbSachiko Wallace model.isUserExists(userAttrValue, userAttrName, orgDN) &&
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model.isUserActive(model.getUserRealm()))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster forwardToPWResetQuestionVB(orgDN, userAttrValue, orgDNFlag,locale);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setErrorMessage(model.getErrorTitle(), model.getErrorMessage());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster forwardTo();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Forwards to <code>PWResetQuestionViewBean</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param orgDN organization DN
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param value user attribute value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param orgDNFlag true if organization came from URL, false otherwise
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private void forwardToPWResetQuestionVB(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgDN,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String value,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgDNFlag,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String locale
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster RequestContext rc = getRequestContext();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PWResetUserValidationModel model =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster (PWResetUserValidationModel) getModel();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PWResetQuestionViewBean vb = (PWResetQuestionViewBean)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster getViewBean(PWResetQuestionViewBean.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vb.setPageSessionAttribute(USER_DN, model.getUserId());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vb.setPageSessionAttribute(USER_ATTR_VALUE, value);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vb.setPageSessionAttribute (URL_LOCALE, locale);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vb.setPageSessionAttribute(INITIAL_ORG_DN, orgDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vb.setPageSessionAttribute(ORG_DN, model.getUserRealm());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (orgDNFlag != null && orgDNFlag.equals(STRING_TRUE)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vb.setPageSessionAttribute(ORG_DN_FLAG, STRING_TRUE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vb.forwardTo(rc);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Gets model for this view bean
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return model for this view bean
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected PWResetModel getModel() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (model == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model = new PWResetUserValidationModelImpl();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return model;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Begins password reset user validation content
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param event child display event
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return true if password reset user validation content is to
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * displayed, false otherwise
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean beginResetPageDisplay(ChildDisplayEvent event) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster PWResetUserValidationModel model =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster (PWResetUserValidationModel)getModel();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return isPWResetEnabled() && model.isValidRealm();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}