01: /*
02: * Copyright 2007 Outerthought bvba and Schaubroeck nv
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.outerj.daisy.util;
17:
18: public class CliUtil {
19: public static String promptPassword(String message,
20: String defaultPassword) throws Exception {
21: char[] pwdChars = CliPasswordField.getPassword(System.in,
22: message);
23: if (pwdChars == null)
24: return defaultPassword;
25: else
26: return new String(pwdChars);
27: }
28:
29: public static String promptPassword(String message, boolean required)
30: throws Exception {
31: char[] pwdChars = null;
32: if (required) {
33: while (pwdChars == null) {
34: pwdChars = CliPasswordField.getPassword(System.in,
35: message);
36: }
37: return new String(pwdChars);
38: } else {
39: pwdChars = CliPasswordField.getPassword(System.in, message);
40: if (pwdChars == null)
41: return null;
42: else
43: return new String(pwdChars);
44: }
45: }
46: }
|