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
18
19/**
20 *
21 * <p>Free validated text input type that does not echo the value in the GUI.</p>
22 * <p>This class implements SecretPropertyField so the
23 * values are not printed in the properties file.  It is the responsibility of the renderer
24 * not to show the password. Hiding is currently not supported on the console.</p>
25 * @author Paul Hinds
26 * @version $Id: PasswordTextInput.java,v 1.3 2006/12/21 00:03:09 teknopaul Exp $
27 */
28public class PasswordTextInput
29    extends ValidatedTextInput implements SecretPropertyField
30{
31
32    private String textMask = "false";
33
34    /**
35     * @return Returns true if text masking is requested.
36     */
37    public String getTextMask() {
38        return textMask;
39    }
40    /**
41     * @param textMask The textMask value true or false.
42     */
43    public void setTextMask(String textMask) {
44        this.textMask = textMask;
45    }
46    /**
47     * Used by checkConfig to validate the configuration file
48     * not at runtime
49     * @return boolean
50     */
51    public boolean validateObject() {
52        if( ! InputField.optionalBoolean(getTextMask())){
53            System.out.println("Comment:textMask must be true or false or null:" + getTextMask());
54            return false;
55        }
56        if(getDisplayText() == null){
57            System.out.println("Password:displayText must be set");
58            return false;
59        }
60        if(getProperty() == null){
61            System.out.println("Password:property must be set");
62            return false;
63        }
64        if(getDefaultValue() == null){
65            System.out.println("Password:defaultValue must be set");
66            return false;
67        }
68        if(getRegex() == null){
69            System.out.println("Password:regex must be set");
70            return false;
71        }
72        return true;
73    }
74
75}
76