001// -------------------------------------------------------------------------------- 002// Copyright 2002-2026 Echo Three, LLC 003// 004// Licensed under the Apache License, Version 2.0 (the "License"); 005// you may not use this file except in compliance with the License. 006// You may obtain a copy of the License at 007// 008// http://www.apache.org/licenses/LICENSE-2.0 009// 010// Unless required by applicable law or agreed to in writing, software 011// distributed under the License is distributed on an "AS IS" BASIS, 012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013// See the License for the specific language governing permissions and 014// limitations under the License. 015// -------------------------------------------------------------------------------- 016 017package com.echothree.view.client.web.struts; 018 019import com.echothree.control.user.user.common.UserUtil; 020import com.echothree.model.control.user.common.choice.RecoveryQuestionChoicesBean; 021import java.util.List; 022import javax.naming.NamingException; 023import javax.servlet.http.HttpServletRequest; 024import org.apache.struts.action.ActionMapping; 025import org.apache.struts.util.LabelValueBean; 026 027public class BasePersonWithLoginActionForm 028 extends BasePersonActionForm { 029 030 private RecoveryQuestionChoicesBean recoveryQuestionChoices = null; 031 032 private String emailAddress = null; 033 private String username = null; 034 private String password1 = null; 035 private String password2 = null; 036 private boolean allowSolicitation; 037 private String recoveryQuestionChoice = null; 038 private String answer = null; 039 040 private void setupRecoveryQuestionChoices() { 041 if(recoveryQuestionChoices == null) { 042 try { 043 var form = UserUtil.getHome().getGetRecoveryQuestionChoicesForm(); 044 045 form.setDefaultRecoveryQuestionChoice(recoveryQuestionChoice); 046 form.setAllowNullChoice(String.valueOf(true)); 047 048 var commandResult = UserUtil.getHome().getRecoveryQuestionChoices(userVisitPK, form); 049 var executionResult = commandResult.getExecutionResult(); 050 var getRecoveryQuestionChoicesResult = executionResult.getResult(); 051 recoveryQuestionChoices = getRecoveryQuestionChoicesResult.getRecoveryQuestionChoices(); 052 053 if(recoveryQuestionChoice == null) { 054 recoveryQuestionChoice = recoveryQuestionChoices.getDefaultValue(); 055 } 056 } catch (NamingException ne) { 057 // failed, recoveryQuestionChoices remains null, no default 058 } 059 } 060 } 061 062 public void setEmailAddress(String emailAddress) { 063 this.emailAddress = emailAddress; 064 } 065 066 public String getEmailAddress() { 067 return emailAddress; 068 } 069 070 public void setUsername(String username) { 071 this.username = username; 072 } 073 074 public String getUsername() { 075 return username; 076 } 077 078 public void setPassword1(String password1) { 079 this.password1 = password1; 080 } 081 082 public String getPassword1() { 083 return password1; 084 } 085 086 public void setPassword2(String password2) { 087 this.password2 = password2; 088 } 089 090 public String getPassword2() { 091 return password2; 092 } 093 094 public void setAllowSolicitation(boolean allowSolicitation) { 095 this.allowSolicitation = allowSolicitation; 096 } 097 098 public boolean getAllowSolicitation() { 099 return allowSolicitation; 100 } 101 102 public List<LabelValueBean> getRecoveryQuestionChoices() { 103 List<LabelValueBean> choices = null; 104 105 setupRecoveryQuestionChoices(); 106 if(recoveryQuestionChoices != null) { 107 choices = convertChoices(recoveryQuestionChoices); 108 } 109 110 return choices; 111 } 112 113 public void setRecoveryQuestionChoice(String recoveryQuestionChoice) { 114 this.recoveryQuestionChoice = recoveryQuestionChoice; 115 } 116 117 public String getRecoveryQuestionChoice() { 118 setupRecoveryQuestionChoices(); 119 120 return recoveryQuestionChoice; 121 } 122 123 public void setAnswer(String answer) { 124 this.answer = answer; 125 } 126 127 public String getAnswer() { 128 return answer; 129 } 130 131 @Override 132 public void reset(ActionMapping mapping, HttpServletRequest request) { 133 super.reset(mapping, request); 134 135 allowSolicitation = false; 136 } 137 138}