01: /**
02: * CertAdmin.java
03: * @author ss133690
04: * @version 0.1
05: */package com.sun.portal.cli.cert;
06:
07: import java.io.File;
08:
09: /**
10: * This class will help the administrator to perform SRA certificate related operations.
11: */
12:
13: public class CertAdmin {
14: private String inst;
15: private String basedir;
16: private String idsameLocaledir;
17: protected JSSContext jsscntx;
18:
19: public static void main(String args[]) {
20: validateArguments(args);
21:
22: String confName = args[1];
23: String psConfigDir = args[2];
24: String amConfDir = args[3];
25: CertAdmin certadmin = new CertAdmin();
26: certadmin.setJSSContext(confName, psConfigDir, amConfDir);
27: certadmin.start();
28: }
29:
30: private static void validateArguments(String args[]) {
31: String optionName = args[0];
32: if (optionName == null || !optionName.trim().equals("-n")) {
33: String message = CertAdminLocale.getPFString("m451",
34: CertAdminConstants.m451);
35: CertAdminUtil.exitOnError(message);
36: }
37:
38: String profileName = args[1];
39: String psConfigDir = args[2];
40: String platformConfFilePath = psConfigDir + File.separator
41: + "platform.conf." + profileName;
42: File platformConfFile = new File(platformConfFilePath);
43: if (platformConfFile == null || !platformConfFile.canRead()) {
44: String message = CertAdminLocale.getPFString("m452",
45: CertAdminConstants.m452);
46: CertAdminUtil.exitOnError(message);
47: }
48:
49: if (args.length < 4) {
50: String message = CertAdminLocale.getPFString("m45",
51: CertAdminConstants.m45);
52: CertAdminUtil.exitOnError(message);
53: }
54: }
55:
56: protected void start() {
57: while (true) {
58: Command cmd = CertAdminFactory.CreateCommand(CertAdminUtil
59: .processMenuOption());
60: cmd.execute(jsscntx);
61: CertAdminUtil.println();
62: CertAdminUtil.println();
63: }
64: }
65:
66: protected void setJSSContext(String confName, String psConfigDir,
67: String amConfDir) {
68: this .inst = confName.trim();
69: this .basedir = psConfigDir.trim();
70: this .idsameLocaledir = amConfDir.trim();
71: try {
72: jsscntx = CertAdminFactory.CreateJSSContext(inst, basedir,
73: idsameLocaledir);
74: } catch (Exception ex) {
75: CertAdminUtil.println(ex.getMessage());
76: System.exit(0);
77: }
78: }
79: }
|