01: /*
02: * InstallPasswordContextImpl.java
03: *
04: */
05:
06: /**
07: *
08: * @author ss133690
09: * @version
10: */package com.sun.portal.cli.cert;
11:
12: import org.mozilla.jss.crypto.*;
13: import com.sun.portal.log.common.PortalLogger;
14: import org.mozilla.jss.*;
15:
16: public class InstallPasswordContextImpl implements PasswordContext {
17: private String jsspass;
18:
19: public InstallPasswordContextImpl(String jsspass) {
20: this .jsspass = jsspass;
21: }
22:
23: public String generatePassphrase(JSSContext cntx) {
24: boolean stored = false;
25: if (cntx.isPasswordEcrypted()) {
26: try {
27: stored = CertAdminUtil.writeLine(JSSUtil
28: .encryptPassword(jsspass), cntx.getCertdir()
29: + CertAdminConstants.SEPERATOR
30: + CertAdminConstants.JSSPASSFILE);
31: } catch (SRADecoderException ex) {
32: CertAdminUtil.println(CertAdminLocale.getPFString(
33: "m55", CertAdminConstants.m55)
34: + CertAdminConstants.newline + ex);
35: return null;
36: }
37: } else {
38: stored = CertAdminUtil.writeLine(jsspass, cntx.getCertdir()
39: + CertAdminConstants.SEPERATOR
40: + CertAdminConstants.JSSPASSFILE);
41: }
42: if (!stored) {
43: //println("Could not store the password");
44: CertAdminUtil.println(CertAdminLocale.getPFString("m42",
45: CertAdminConstants.m42));
46: }
47: return jsspass;
48: }
49:
50: }
|