summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/servlet/csadmin/ConfigHSMLoginPanel.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/servlet/csadmin/ConfigHSMLoginPanel.java')
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/csadmin/ConfigHSMLoginPanel.java142
1 files changed, 64 insertions, 78 deletions
diff --git a/pki/base/common/src/com/netscape/cms/servlet/csadmin/ConfigHSMLoginPanel.java b/pki/base/common/src/com/netscape/cms/servlet/csadmin/ConfigHSMLoginPanel.java
index d04fbf2f..c524e667 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/csadmin/ConfigHSMLoginPanel.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/csadmin/ConfigHSMLoginPanel.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.servlet.csadmin;
-
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -46,13 +45,13 @@ public class ConfigHSMLoginPanel extends WizardPanelBase {
private CryptoManager mCryptoManager = null;
private String mPwdFilePath = "";
- public ConfigHSMLoginPanel() {}
+ public ConfigHSMLoginPanel() {
+ }
public void init(ServletConfig config, int panelno) throws ServletException {
try {
mCryptoManager = CryptoManager.getInstance();
- mPwdFilePath = CMS.getConfigStore().getString(
- "passwordFile");
+ mPwdFilePath = CMS.getConfigStore().getString("passwordFile");
} catch (Exception e) {
CMS.debug("ConfigHSMLoginPanel: " + e.toString());
}
@@ -60,11 +59,11 @@ public class ConfigHSMLoginPanel extends WizardPanelBase {
setName("ConfigHSMLogin");
}
- public void init(WizardServlet servlet, ServletConfig config, int panelno, String id) throws ServletException {
+ public void init(WizardServlet servlet, ServletConfig config, int panelno,
+ String id) throws ServletException {
try {
mCryptoManager = CryptoManager.getInstance();
- mPwdFilePath = CMS.getConfigStore().getString(
- "passwordFile");
+ mPwdFilePath = CMS.getConfigStore().getString("passwordFile");
} catch (Exception e) {
CMS.debug("ConfigHSMLoginPanel: " + e.toString());
}
@@ -89,8 +88,7 @@ public class ConfigHSMLoginPanel extends WizardPanelBase {
}
public void display(HttpServletRequest request,
- HttpServletResponse response,
- Context context) {
+ HttpServletResponse response, Context context) {
CMS.debug("ConfigHSMLoginPanel: in display()");
context.put("title", "Security Module Login");
@@ -115,9 +113,8 @@ public class ConfigHSMLoginPanel extends WizardPanelBase {
try {
token = mCryptoManager.getTokenByName(tokName);
} catch (Exception e) {
- CMS.debug(
- "ConfigHSMLoginPanel: getTokenByName() failed: "
- + e.toString());
+ CMS.debug("ConfigHSMLoginPanel: getTokenByName() failed: "
+ + e.toString());
context.put("error", "tokenNotFound:" + tokName);
context.put("panel", "admin/console/config/config_hsmloginpanel.vm");
return;
@@ -132,7 +129,7 @@ public class ConfigHSMLoginPanel extends WizardPanelBase {
CMS.debug("ConfigHSMLoginPanel: passwrd file path: " + e.toString());
}
CMS.debug("ConfigHSMLoginPanel: checking if passwd in cache");
- String tokPwd = pr.getPassword("hardware-"+tokName);
+ String tokPwd = pr.getPassword("hardware-" + tokName);
boolean loggedIn = false;
@@ -157,48 +154,47 @@ public class ConfigHSMLoginPanel extends WizardPanelBase {
password = new Password(tokPwd.toCharArray());
try {
- if (token.passwordIsInitialized()) {
- CMS.debug(
- "ConfigHSMLoginPanel: loginToken():token password is initialized");
- if (!token.isLoggedIn()) {
- CMS.debug(
- "ConfigHSMLoginPanel: loginToken():Token is not logged in, try it");
- token.login(password);
- context.put("status", "justLoggedIn");
- } else {
- CMS.debug(
- "ConfigHSMLoginPanel:Token has already logged on");
- context.put("status", "alreadyLoggedIn");
- }
- } else {
- CMS.debug(
- "ConfigHSMLoginPanel: loginToken():Token password not initialized");
- context.put("status", "tokenPasswordNotInitialized");
- rv = false;
- }
-
- } catch (IncorrectPasswordException e) {
- context.put("status", "incorrectPassword");
- context.put("errorString", e.toString());
- CMS.debug("ConfigHSMLoginPanel: loginToken():" + e.toString());
- rv = false;
- } catch (Exception e) {
- CMS.debug("ConfigHSMLoginPanel: loginToken():" + e.toString());
- context.put("errorString", e.toString());
- rv = false;
- }
+ if (token.passwordIsInitialized()) {
+ CMS.debug("ConfigHSMLoginPanel: loginToken():token password is initialized");
+ if (!token.isLoggedIn()) {
+ CMS.debug("ConfigHSMLoginPanel: loginToken():Token is not logged in, try it");
+ token.login(password);
+ context.put("status", "justLoggedIn");
+ } else {
+ CMS.debug("ConfigHSMLoginPanel:Token has already logged on");
+ context.put("status", "alreadyLoggedIn");
+ }
+ } else {
+ CMS.debug("ConfigHSMLoginPanel: loginToken():Token password not initialized");
+ context.put("status", "tokenPasswordNotInitialized");
+ rv = false;
+ }
+
+ } catch (IncorrectPasswordException e) {
+ context.put("status", "incorrectPassword");
+ context.put("errorString", e.toString());
+ CMS.debug("ConfigHSMLoginPanel: loginToken():" + e.toString());
+ rv = false;
+ } catch (Exception e) {
+ CMS.debug("ConfigHSMLoginPanel: loginToken():" + e.toString());
+ context.put("errorString", e.toString());
+ rv = false;
+ }
return rv;
}
// XXX how do you do this?
public PropertySet getUsage() {
PropertySet set = new PropertySet();
-
- Descriptor choiceDesc = new Descriptor(IDescriptor.CHOICE, "", "", null); /* no default parameters */
- set.add(
- "choice", choiceDesc);
-
+ Descriptor choiceDesc = new Descriptor(IDescriptor.CHOICE, "", "", null); /*
+ * no
+ * default
+ * parameters
+ */
+
+ set.add("choice", choiceDesc);
+
return set;
}
@@ -206,13 +202,11 @@ public class ConfigHSMLoginPanel extends WizardPanelBase {
* Checks if the given parameters are valid.
*/
public void validate(HttpServletRequest request,
- HttpServletResponse response,
- Context context) throws IOException {
+ HttpServletResponse response, Context context) throws IOException {
}
public void update(HttpServletRequest request,
- HttpServletResponse response,
- Context context) {
+ HttpServletResponse response, Context context) {
IConfigStore cs = CMS.getConfigStore();
String select = "";
@@ -220,10 +214,10 @@ public class ConfigHSMLoginPanel extends WizardPanelBase {
select = cs.getString("preop.subsystem.select", "");
} catch (Exception e) {
}
-
-// if (select.equals("clone"))
- // return;
-
+
+ // if (select.equals("clone"))
+ // return;
+
CMS.debug("ConfigHSMLoginPanel: in update()");
String uTokName = null;
@@ -233,7 +227,7 @@ public class ConfigHSMLoginPanel extends WizardPanelBase {
uPasswd = HttpInput.getPassword(request, "__uPasswd");
} catch (Exception e) {
}
-
+
if (uPasswd == null) {
CMS.debug("ConfigHSMLoginPanel: password not found");
context.put("error", "no password");
@@ -248,47 +242,41 @@ public class ConfigHSMLoginPanel extends WizardPanelBase {
try {
token = mCryptoManager.getTokenByName(uTokName);
} catch (Exception e) {
- CMS.debug(
- "ConfigHSMLoginPanel: getTokenByName() failed: "
- + e.toString());
+ CMS.debug("ConfigHSMLoginPanel: getTokenByName() failed: "
+ + e.toString());
context.put("error", "tokenNotFound:" + uTokName);
}
try {
if (loginToken(token, uPasswd, context) == false) {
- CMS.debug(
- "ConfigHSMLoginPanel:loginToken failed for "
- + uTokName);
+ CMS.debug("ConfigHSMLoginPanel:loginToken failed for "
+ + uTokName);
context.put("error", "tokenLoginFailed");
context.put("updateStatus", "login failed");
context.put("panel",
"admin/console/config/config_hsmloginpanel.vm");
return;
}
- CMS.debug(
- "ConfigHSMLoginPanel: update(): just logged in successfully");
+ CMS.debug("ConfigHSMLoginPanel: update(): just logged in successfully");
PlainPasswordWriter pw = new PlainPasswordWriter();
pw.init(mPwdFilePath);
- pw.putPassword("hardware-"+uTokName, uPasswd);
+ pw.putPassword("hardware-" + uTokName, uPasswd);
pw.commit();
} catch (FileNotFoundException e) {
- CMS.debug(
- "ConfigHSMLoginPanel: update(): Exception caught: "
- + e.toString() + " writing to "+ mPwdFilePath);
- CMS.debug(
- "ConfigHSMLoginPanel: update(): password not written to cache");
+ CMS.debug("ConfigHSMLoginPanel: update(): Exception caught: "
+ + e.toString() + " writing to " + mPwdFilePath);
+ CMS.debug("ConfigHSMLoginPanel: update(): password not written to cache");
System.err.println("Exception caught: " + e.toString());
context.put("error", "Exception:" + e.toString());
} catch (Exception e) {
- CMS.debug(
- "ConfigHSMLoginPanel: update(): Exception caught: "
- + e.toString());
+ CMS.debug("ConfigHSMLoginPanel: update(): Exception caught: "
+ + e.toString());
System.err.println("Exception caught: " + e.toString());
context.put("error", "Exception:" + e.toString());
}
-
+
} // found password
context.put("panel", "admin/console/config/config_hsmloginpanel.vm");
@@ -302,10 +290,8 @@ public class ConfigHSMLoginPanel extends WizardPanelBase {
* If validiate() returns false, this method will be called.
*/
public void displayError(HttpServletRequest request,
- HttpServletResponse response,
- Context context) {
+ HttpServletResponse response, Context context) {
context.put("title", "Security Module Login");
context.put("panel", "admin/console/config/config_hsmloginpanel.vm");
}
}
-