KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > upgrade > common > arguments > ARG_noprompt


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.tools.upgrade.common.arguments;
25
26 import com.sun.enterprise.tools.upgrade.common.ArgsParser;
27 import com.sun.enterprise.tools.upgrade.common.PasswordVerifier;
28 import com.sun.enterprise.tools.upgrade.common.UpgradeUtils;
29 import java.util.Iterator JavaDoc;
30 import java.util.List JavaDoc;
31
32 /**
33  *
34  * @author Hans Hrasna
35  */

36 public class ARG_noprompt extends ArgumentHandler {
37     private String JavaDoc defaultAdminUser = "admin";
38     private String JavaDoc defaultAdminPassword = "adminadmin";
39     private String JavaDoc defaultMasterPassword = "changeit";
40     
41     /** Creates a new instance of ARG_noprompt */
42     public ARG_noprompt(ParsedArgument pa) {
43         super(pa);
44         //Silent upgrade support with default values
45
if (commonInfo.getAdminUserName() == null){
46             commonInfo.setAdminUserName(defaultAdminUser);
47             interactiveMap.put(ArgsParser.ADMINUSER,defaultAdminUser);
48         }
49         if (commonInfo.getAdminPassword() == null){
50             commonInfo.setAdminPassword(defaultAdminPassword);
51             interactiveMap.put(ArgsParser.ADMINPASSWORD,defaultAdminPassword);
52         }
53         if (commonInfo.getMasterPassword() == null) {
54             commonInfo.setMasterPassword(defaultMasterPassword);
55         }
56         
57         // set up silent certificate upgrade
58
commonInfo.setCertificateConversionFlag(true);
59         List JavaDoc domainList = commonInfo.getDomainList();
60         Iterator JavaDoc it = domainList.iterator();
61         while (it.hasNext()){
62             //attempt certificate migration for each domain
63
String JavaDoc domainName = (String JavaDoc)it.next();
64             commonInfo.setCurrentDomain(domainName);
65             //commonInfo.setJksCAKeystorePassword(password);
66
String JavaDoc password = UpgradeUtils.getUpgradeUtils(commonInfo).getJvmOptionValueFromSourceConfig("javax.net.ssl.keyStorePassword");
67             if(password == null) {
68                 password = commonInfo.getMasterPassword();
69             }
70             commonInfo.setJksKeystorePassword(password);
71             String JavaDoc trustPassword = UpgradeUtils.getUpgradeUtils(commonInfo).getJvmOptionValueFromSourceConfig("javax.net.ssl.trustStorePassword");
72             if(trustPassword == null) {
73                 trustPassword = commonInfo.getMasterPassword();
74             }
75             commonInfo.setJksCAKeystorePassword(trustPassword);
76             commonInfo.addDomainOptionName(domainName);
77             interactiveMap.put(ArgsParser.DOMAIN + "-" + commonInfo.getCurrentDomain(), domainName);
78             interactiveMap.put(ArgsParser.JKSPWD + "-" + domainName, password);
79             interactiveMap.put(ArgsParser.CAPWD + "-" + domainName, password);
80             interactiveMap.put(ArgsParser.NSSPWD + "-" + domainName, password);
81             interactiveMap.put(ArgsParser.TARGETNSSPWD + "-" + domainName, password);
82             commonInfo.setCertDbPassword(commonInfo.getCurrentDomain(), password);
83             String JavaDoc jksPath=commonInfo.getSourceJKSKeyStorePath();
84             if(!PasswordVerifier.verifyKeystorePassword(jksPath,password )) {
85                 commonInfo.recover();
86                 _logger.severe(sm.getString("enterprise.tools.upgrade.cli.Invalid_jks_keypair_password"));
87                 System.exit(1);
88             }
89             String JavaDoc trustJksPath = commonInfo.getSourceTrustedJKSKeyStorePath();
90             if(!PasswordVerifier.verifyKeystorePassword(trustJksPath,trustPassword)) {
91                 commonInfo.recover();
92                 _logger.severe(sm.getString("enterprise.tools.upgrade.cli.Invalid_jks_CA_password"));
93                 System.exit(1);
94             }
95         }
96     }
97     
98 }
99
Popular Tags