01: /*
02: * Copyright 2005 Paul Hinds
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: */
16: package org.tp23.antinstaller.input;
17:
18: /**
19: *
20: * <p>Free validated text input type that does not echo the value in the GUI.</p>
21: * <p>This class implements SecretPropertyField so the
22: * values are not printed in the properties file. It is the responsibility of the renderer
23: * not to show the password. Hiding is currently not supported on the console.</p>
24: * @author Paul Hinds
25: * @version $Id: PasswordTextInput.java,v 1.3 2006/12/21 00:03:09 teknopaul Exp $
26: */
27: public class PasswordTextInput extends ValidatedTextInput implements
28: SecretPropertyField {
29:
30: private String textMask = "false";
31:
32: /**
33: * @return Returns true if text masking is requested.
34: */
35: public String getTextMask() {
36: return textMask;
37: }
38:
39: /**
40: * @param textMask The textMask value true or false.
41: */
42: public void setTextMask(String textMask) {
43: this .textMask = textMask;
44: }
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
54: .println("Comment:textMask must be true or false or null:"
55: + getTextMask());
56: return false;
57: }
58: if (getDisplayText() == null) {
59: System.out.println("Password:displayText must be set");
60: return false;
61: }
62: if (getProperty() == null) {
63: System.out.println("Password:property must be set");
64: return false;
65: }
66: if (getDefaultValue() == null) {
67: System.out.println("Password:defaultValue must be set");
68: return false;
69: }
70: if (getRegex() == null) {
71: System.out.println("Password:regex must be set");
72: return false;
73: }
74: return true;
75: }
76:
77: }
|