source: release-kits/lirk3/bin/ant-installer/src/org/tp23/antinstaller/input/ConfirmPasswordTextInput.java@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 2.1 KB
Line 
1/*
2 * Copyright 2005 Paul Hinds
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.tp23.antinstaller.input;
17
18import org.tp23.antinstaller.InstallerContext;
19import org.tp23.antinstaller.ValidationException;
20
21/**
22 * a second password filed that checks to see if a password entered twice matches
23 * @author Paul Hinds
24 * @version $Id$
25 */
26public class ConfirmPasswordTextInput
27 extends PasswordTextInput
28{
29 private String origField;
30
31 /**
32 * Called to validate the user input, if the confirm flag is set
33 * and there is a password field on the same page with the same property name
34 * both passwords must match for validation to pass
35 */
36 public boolean validate(InstallerContext ctx) throws ValidationException{
37 OutputField[] otherFields = ctx.getCurrentPage().getOutputField();
38 for (int i = 0; i < otherFields.length; i++) {
39 if(otherFields[i] instanceof PasswordTextInput &&
40 otherFields[i] != this){
41 PasswordTextInput pwd = (PasswordTextInput)otherFields[i];
42 if(pwd.getProperty().equals(getOrigField())){
43 return this.getInputResult().equals(pwd.getInputResult());
44 }
45 }
46 }
47 throw new ValidationException("Confirm password requires a PasswordTextInput, on the same page, with property " + getOrigField());
48 }
49
50 public boolean validateObject() {
51 if ( ! super.validateObject()){
52 return false;
53 }
54 if(getOrigField() == null){
55 System.out.println("ConfirmPassword:origField must be set");
56 return false;
57 }
58 // @TODO check the orig field exists
59 return true;
60 }
61
62 public String getOrigField() {
63 return origField;
64 }
65
66 public void setOrigField(String origField) {
67 this.origField = origField;
68 }
69
70}
Note: See TracBrowser for help on using the repository browser.