8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
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 * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
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 * $Id: PWResetUserValidationViewBean.java,v 1.4 2010/01/28 08:17:10 bina Exp $
ebe2bbed96ad174bcd6fc7a1136fade167573ddbSachiko Wallace * Portions Copyrighted 2011-2014 ForgeRock AS
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.jato.model.ModelControlException;
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.StaticTextField;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.authentication.service.AuthUtils;
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 Foster * <code>PWResetUserValidationViewBean</code> validates user's identity for
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the password reset service.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class PWResetUserValidationViewBean extends PWResetViewBeanBase {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private final Debug debug = Debug.getInstance("PasswordReset");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of title peer component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String USER_VALIDATION_TITLE = "userValidationTitle";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of user validation peer component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String LBL_USER_ATTR = "lblUserAttr";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of component for user validation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String TF_USER_ATTR = "tfUserAttr";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of OK button peer component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String NEXT_BUTTON = "btnNext";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String PAGE_NAME = "PWResetUserValidation";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of user attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String FLD_USER_ATTR = "fldUserAttr";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of org attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of realm attribute
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Default display URL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static final String DEFAULT_DISPLAY_URL =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs a user validation view bean
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Registers child components/views
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster registerChild(USER_VALIDATION_TITLE, StaticTextField.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster registerChild(LBL_USER_ATTR, StaticTextField.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster registerChild(FLD_USER_ATTR, HiddenField.class);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Creates child component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name of child component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return child component
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster child = new StaticTextField(this, LBL_USER_ATTR, "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else if (name.equals(USER_VALIDATION_TITLE)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster child = new StaticTextField(this, USER_VALIDATION_TITLE, "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return new HiddenField(this, FLD_USER_ATTR, "");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Set the required information to display the page.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param event display event.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws ModelControlException if problem access value of component.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgDN = (String)getPageSessionAttribute(ORG_DN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster HiddenField hf = (HiddenField)getChild(FLD_USER_ATTR);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setDisplayFieldValue(NEXT_BUTTON, model.getNextBtnLabel());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (userAttrValue != null && userAttrValue.length() > 0) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setDisplayFieldValue(TF_USER_ATTR, userAttrValue);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Forwards to current view bean after validating organization
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param context request context
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void forwardTo(RequestContext context) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String classMethod = "PWResetUserValidationViewBean:forwardTo : ";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ISLocaleContext localeContext = new ISLocaleContext();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster java.util.Locale locale = localeContext.getLocale();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgDN = (String)getPageSessionAttribute(ORG_DN);
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 debug.message(classMethod + "orgDN is :" + orgDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Set the flag to indicate that user enter the orgname in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (orgParam != null && orgParam.length() > 0) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setPageSessionAttribute(ORG_DN_FLAG, STRING_TRUE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Handles form submission request
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param event request invocation event
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void handleBtnNextRequest(RequestInvocationEvent event) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String userAttrValue = (String)getDisplayFieldValue(TF_USER_ATTR);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster HiddenField hf = (HiddenField)getChild(FLD_USER_ATTR);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgDN = (String)getPageSessionAttribute(ORG_DN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgDNFlag = (String)getPageSessionAttribute(ORG_DN_FLAG);
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 if (orgDNFlag != null && orgDNFlag.equals (STRING_TRUE)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (userAttrValue == null || userAttrValue.length() == 0) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster model.getMissingUserAttrMessage(userAttrName));
ebe2bbed96ad174bcd6fc7a1136fade167573ddbSachiko Wallace if (model.isUserAttrValueValid(orgDN, userAttrValue) &&
ebe2bbed96ad174bcd6fc7a1136fade167573ddbSachiko Wallace model.isUserExists(userAttrValue, userAttrName, orgDN) &&
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster forwardToPWResetQuestionVB(orgDN, userAttrValue, orgDNFlag,locale);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setErrorMessage(model.getErrorTitle(), model.getErrorMessage());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Forwards to <code>PWResetQuestionViewBean</code>
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 PWResetQuestionViewBean vb = (PWResetQuestionViewBean)
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 if (orgDNFlag != null && orgDNFlag.equals(STRING_TRUE)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster vb.setPageSessionAttribute(ORG_DN_FLAG, STRING_TRUE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Gets model for this view bean
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return model for this view bean
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Begins password reset user validation content
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 public boolean beginResetPageDisplay(ChildDisplayEvent event) {