From a4682ceae6774956461edd03b2485bbacea445f4 Mon Sep 17 00:00:00 2001 From: mharmsen Date: Tue, 4 Oct 2011 01:17:41 +0000 Subject: Bugzilla Bug #688225 - (dogtagIPAv2.1) TRACKER: of the Dogtag fixes for freeIPA 2.1 git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/tags/IPA_v2_RHEL_6_2_20111003@2252 c9f7a03b-bd48-0410-a16d-cbbf54688b0b --- .../admin/certsrv/keycert/CertSetupWizard.java | 82 +++ .../admin/certsrv/keycert/CertSetupWizardInfo.java | 412 +++++++++++ .../admin/certsrv/keycert/WCACertRequest1Page.java | 237 ++++++ .../netscape/admin/certsrv/keycert/WCAKeyPage.java | 102 +++ .../admin/certsrv/keycert/WCertDNPage.java | 198 +++++ .../admin/certsrv/keycert/WCertDNValidityPage.java | 100 +++ .../admin/certsrv/keycert/WCertExtensionPage.java | 275 +++++++ .../certsrv/keycert/WCertMessageDigestPage.java | 113 +++ .../admin/certsrv/keycert/WCertRequestPage.java | 81 ++ .../admin/certsrv/keycert/WCertTypePage.java | 501 +++++++++++++ .../admin/certsrv/keycert/WCertValidityPage.java | 139 ++++ .../admin/certsrv/keycert/WDisplayCertPage.java | 259 +++++++ .../admin/certsrv/keycert/WExecute1Page.java | 161 ++++ .../admin/certsrv/keycert/WExecutePage.java | 159 ++++ .../admin/certsrv/keycert/WGenerateReqPage.java | 92 +++ .../certsrv/keycert/WInstallCertChainPage.java | 141 ++++ .../admin/certsrv/keycert/WInstallOpPage.java | 222 ++++++ .../admin/certsrv/keycert/WInstallStatusPage.java | 105 +++ .../certsrv/keycert/WIntroInstallCertPage.java | 93 +++ .../netscape/admin/certsrv/keycert/WIntroPage.java | 121 +++ .../certsrv/keycert/WIssueImportStatusPage.java | 105 +++ .../netscape/admin/certsrv/keycert/WKeyPage.java | 811 +++++++++++++++++++++ .../certsrv/keycert/WManualCertRequestPage.java | 199 +++++ .../certsrv/keycert/WOperationSelectionPage.java | 134 ++++ .../certsrv/keycert/WOtherCertRequest1Page.java | 176 +++++ .../admin/certsrv/keycert/WPasteCertPage.java | 264 +++++++ .../netscape/admin/certsrv/keycert/WRAKeyPage.java | 72 ++ .../admin/certsrv/keycert/WRequestStatusPage.java | 142 ++++ .../admin/certsrv/keycert/WSSLKeyPage.java | 72 ++ .../admin/certsrv/keycert/WTokenLogonPage.java | 181 +++++ .../admin/certsrv/keycert/WTokenSelectionPage.java | 158 ++++ .../certsrv/keycert/WWarningExecute1Page.java | 163 +++++ .../admin/certsrv/keycert/WWarningExecutePage.java | 154 ++++ .../admin/certsrv/keycert/WWarningPage.java | 143 ++++ 34 files changed, 6367 insertions(+) create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizard.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizardInfo.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WCACertRequest1Page.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WCAKeyPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WCertDNPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WCertDNValidityPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WCertExtensionPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WCertMessageDigestPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WCertRequestPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WCertTypePage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WCertValidityPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WDisplayCertPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WExecute1Page.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WExecutePage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WGenerateReqPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WInstallCertChainPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WInstallOpPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WInstallStatusPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WIntroInstallCertPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WIntroPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WIssueImportStatusPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WKeyPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WManualCertRequestPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WOperationSelectionPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WOtherCertRequest1Page.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WPasteCertPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WRAKeyPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WRequestStatusPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WSSLKeyPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WTokenLogonPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WTokenSelectionPage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WWarningExecute1Page.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WWarningExecutePage.java create mode 100644 pki/base/console/src/com/netscape/admin/certsrv/keycert/WWarningPage.java (limited to 'pki/base/console/src/com/netscape/admin/certsrv/keycert') diff --git a/pki/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizard.java b/pki/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizard.java new file mode 100644 index 000000000..f7650decb --- /dev/null +++ b/pki/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizard.java @@ -0,0 +1,82 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.admin.certsrv.keycert; + +import java.awt.*; +import javax.swing.*; +import com.netscape.admin.certsrv.*; +import com.netscape.admin.certsrv.wizard.*; + +/** + * Wizard for Key and Certificate management + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ + +public class CertSetupWizard extends WizardWidget { + + public CertSetupWizard(CMSBaseResourceModel parent, CertSetupWizardInfo info) { + super(parent.getFrame()); + JFrame frame = parent.getFrame(); + info.addEntry(info.FRAME, frame); + info.addEntry(info.SERVERINFO, parent.getServerInfo()); + setWizardInfo(info); + addPage(new WIntroPage(this, frame)); +// addPage(new WTokenSelectionPage()); + addPage(new WOperationSelectionPage(this, frame)); +// addPage(new WGenerateReqPage(this)); + addPage(new WCertTypePage(this, frame)); + //addPage(new WServerCertSubmitPage(this, frame)); +// addPage(new WCACertRequest1Page()); +// addPage(new WOtherCertRequest1Page()); +// addPage(new WCAKeyPage()); + addPage(new WKeyPage(this, frame)); + addPage(new WTokenLogonPage(this, frame)); + addPage(new WCertMessageDigestPage(this, frame)); +// addPage(new WWarningPage()); + addPage(new WCertDNPage(this, frame)); + addPage(new WCertValidityPage(this, frame)); +// addPage(new WCertDNValidityPage()); +// addPage(new WWarningExecute1Page()); + addPage(new WCertExtensionPage(this, frame)); + addPage(new WExecute1Page(this, frame)); +// addPage(new WRAKeyPage()); +// addPage(new WSSLKeyPage()); +// addPage(new WWarningExecutePage()); + addPage(new WExecutePage(this, frame)); + addPage(new WIssueImportStatusPage(this, frame)); + addPage(new WManualCertRequestPage(this, frame)); + addPage(new WRequestStatusPage(this, frame)); +// addPage(new WIntroInstallCertPage()); + addPage(new WInstallOpPage(this, frame)); + addPage(new WInstallCertChainPage(this, frame)); + addPage(new WPasteCertPage(this, frame)); + addPage(new WDisplayCertPage(this, frame)); + addPage(new WInstallStatusPage(this, frame)); + show(); + } + + protected void callHelp() { + if (mCurrent instanceof IWizardPanel) { + ((IWizardPanel)mCurrent).callHelp(); + } + } +} + diff --git a/pki/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizardInfo.java b/pki/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizardInfo.java new file mode 100644 index 000000000..81ffc2d0e --- /dev/null +++ b/pki/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizardInfo.java @@ -0,0 +1,412 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.admin.certsrv.keycert; + +import java.awt.*; +import javax.swing.*; +import com.netscape.admin.certsrv.*; +import com.netscape.admin.certsrv.connection.*; +import com.netscape.admin.certsrv.wizard.*; +import com.netscape.certsrv.common.*; +import com.netscape.management.client.console.*; + +/** + * WizardInfo for certificate setup wizard + * Once complete, we need to zap this object. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +public class CertSetupWizardInfo extends WizardInfo { + + private AdminConnection mConnection; + private ConsoleInfo mConsoleInfo; + public static final String FRAME = "frame"; + public static final String SERVERINFO = "serverInfo"; + public static final String TOKENNAME = "tokenName"; + public static final String DBPASSWD = "dbPasswd"; + public static final String OPTYPE = "operationType"; + public static final String INSTALLTYPE = "install"; + public static final String REQUESTTYPE = "request"; +// public static final String CA_SIGNING_CERT = "caSigningCert"; + // public static final String RA_SIGNING_CERT = " raSigningCert"; + // public static final String KRA_TRANSPORT_CERT = "kraTransportCert"; + // public static final String SSL_SERVER_CERT = "sslServerCert"; + public static final String SERVER_CERT_CHAIN = "serverCertChain"; + public static final String TRUSTED_CA_CERT = "trustedCACert"; + public static final String TRUSTED_CERT = "trustedCert"; +// public static final String SERVER_CERT = "serverCert"; + public static final String SELF_SIGNED = "selfSigned"; + public static final String SUBORDINATE_CA = "subordinateCA"; + public static final String CA_EMAIL = "caEmail"; + public static final String CA_URL = "caUrl"; + public static final String MANUAL = "manual"; + public static final String SUBMIT_METHOD = "reqSubmitMethod"; + public static final String KEY_MATERIAL = "keyMaterial"; + public static final String CA_TYPE = "caType"; + public static final String DERVALUE = "derValue"; + public static final String INSTALLCERTTYPE = "installCertType"; + public static final String ALL_INFO = "allInfo"; + public static final String BEGIN_YEAR = "beginYear"; + public static final String BEGIN_MONTH = "beginMonth"; + public static final String BEGIN_DATE = "beginDate"; + public static final String BEGIN_HOUR = "beginHour"; + public static final String BEGIN_MIN = "beginMin"; + public static final String BEGIN_SEC = "beginSec"; + public static final String AFTER_YEAR = "afterYear"; + public static final String AFTER_MONTH = "afterMonth"; + public static final String AFTER_DATE = "afterDate"; + public static final String AFTER_HOUR = "afterHour"; + public static final String AFTER_MIN = "afterMin"; + public static final String AFTER_SEC = "afterSec"; + public static final String NICKNAME = "nickname"; + public static final String CERT_CONTENT = "certContent"; + + public CertSetupWizardInfo(AdminConnection conn, ConsoleInfo info) { + super(); + mConnection = conn; + mConsoleInfo = info; + } + + public JFrame getFrame() { + return (JFrame)get(FRAME); + } + + public CMSServerInfo getServerInfo() { + return (CMSServerInfo)get(SERVERINFO); + } + + public AdminConnection getAdminConnection() { + return mConnection; + } + + public ConsoleInfo getAdminConsoleInfo() { + return mConsoleInfo; + } + + // if mode = 0, then it is in root cert mode. + // if mode = 1, then it is in user cert mode. + public void setMode(String mode) { + put("mode", mode); + } + + public String getMode() { + return (String)get("mode"); + } + + public String getCertType() { + return (String)get(Constants.PR_CERTIFICATE_TYPE); + } + + public void setCertType(String certType) { + put(Constants.PR_CERTIFICATE_TYPE, certType); + } + + public String getSubmitMethod() { + return (String)get(SUBMIT_METHOD); + } + + public String getCAType() { + return (String)get(CA_TYPE); + } + + public boolean isNewKey() { + String isNew = (String)get(KEY_MATERIAL); + if (isNew != null && isNew.equals(Constants.TRUE)) + return true; + return false; + } + + public String getOperationType() { + String opType = (String)get(OPTYPE); + return opType; + } + + public boolean isSSLCertLocalCA() { + String val = (String)get(ConfigConstants.PR_SSLCERT_LOCALCA); + if (val == null) + return false; + else if (val.equals(Constants.TRUE)) + return true; + return false; + } + + // set true or false + public void setSSLCertLocalCA(String val) { + put(ConfigConstants.PR_SSLCERT_LOCALCA, val); + } + + public byte[] getDERValue() { + byte[] derValue = (byte[])get(DERVALUE); + return derValue; + } + + public String getTokenName() { + return (String)get(TOKENNAME); + } + + public String getKeyLength() { + return (String)get(Constants.PR_KEY_LENGTH); + } + + public String getKeyCurveName() { + return (String)get(Constants.PR_KEY_CURVENAME); + } + + public String getKeyType() { + return (String)get(Constants.PR_KEY_TYPE); + } + + public String getSubjectName() { + return (String)get(Constants.PR_SUBJECT_NAME); + } + + public void setSubjectName(String str) { + put(Constants.PR_SUBJECT_NAME, str); + } + + public String getCSR() { + return (String)get(Constants.PR_CSR); + } + + public String getPKCS10() { + String val = (String)get(Constants.PR_PKCS10); + if (val != null && !val.equals("")) + return val; + return null; + } + + public void setPKCS10(String b64E) { + put(Constants.PR_PKCS10, b64E); + } + + public String getCertFilePath() { + String val = (String)get(Constants.PR_CERT_FILEPATH); + if (val != null && !val.equals("")) + return val; + return null; + } + + public void setCertFilePath(String path) { + put(Constants.PR_CERT_FILEPATH, path); + } + + public String getCertSubjectName() { + return (String)get(Constants.PR_CERT_SUBJECT_NAME); + } + + public String getIssuerName() { + return (String)get(Constants.PR_ISSUER_NAME); + } + + public String getSerialNumber() { + return (String)get(Constants.PR_SERIAL_NUMBER); + } + + public String getNotBefore() { + return (String)get(Constants.PR_BEFORE_VALIDDATE); + } + + public String getNotAfter() { + return (String)get(Constants.PR_AFTER_VALIDDATE); + } + + public String getInstallCertType() { + return (String)get(INSTALLCERTTYPE); + } + + public String getValidityPeriod() { + return (String)get(Constants.PR_VALIDITY_PERIOD); + } + + public String getTokenList() { + return (String)get(Constants.PR_TOKEN_LIST); + } + + public Boolean isCertAdded() { + return (Boolean)get(Constants.PR_ADD_CERT); + } + + public NameValuePairs getNameValuePairs() { + return (NameValuePairs)get(ALL_INFO); + } + + public String getBeginYear() { + return (String)get(Constants.PR_BEGIN_YEAR); + } + + public String getBeginMonth() { + return (String)get(Constants.PR_BEGIN_MONTH); + } + + public String getBeginDate() { + return (String)get(Constants.PR_BEGIN_DATE); + } + + public String getBeginHour() { + return (String)get(Constants.PR_BEGIN_HOUR); + } + + public String getBeginMin() { + return (String)get(Constants.PR_BEGIN_MIN); + } + + public String getBeginSec() { + return (String)get(Constants.PR_BEGIN_SEC); + } + + public String getAfterYear() { + return (String)get(Constants.PR_AFTER_YEAR); + } + + public String getAfterMonth() { + return (String)get(Constants.PR_AFTER_MONTH); + } + + public String getAfterDate() { + return (String)get(Constants.PR_AFTER_DATE); + } + + public String getAfterHour() { + return (String)get(Constants.PR_AFTER_HOUR); + } + + public String getAfterMin() { + return (String)get(Constants.PR_AFTER_MIN); + } + + public String getAfterSec() { + return (String)get(Constants.PR_AFTER_SEC); + } + + public String getNickname() { + return (String)get(Constants.PR_NICKNAME); + } + + public String getCertContent() { + return (String)get(Constants.PR_CERT_CONTENT); + } + + public String getHashType() { + return (String)get(ConfigConstants.PR_HASH_TYPE); + } + + public void setHashType(String type) { + put(ConfigConstants.PR_HASH_TYPE, type); + } + + public String getSignedByType() { + return (String)get(ConfigConstants.PR_SIGNEDBY_TYPE); + } + + public void setSignedByType(String type) { + put(ConfigConstants.PR_SIGNEDBY_TYPE, type); + } + + + public boolean isLoggedIn() { + String value = (String)get(Constants.PR_LOGGED_IN); + if (value != null && value.equals(Constants.FALSE)) + return false; + return true; + } + + public String getCertRequestDir() { + return (String)get(Constants.PR_CERT_REQUEST_DIR); + } + + public void setCMHost(String host) { + put(ConfigConstants.CA_HOST, host); + } + + public String getCMHost() { + return (String)get(ConfigConstants.CA_HOST); + } + + public void setCMEEPort(String port) { + put(ConfigConstants.CA_EEPORT, port); + } + + public String getCMEEPort() { + return (String)get(ConfigConstants.CA_EEPORT); + } + + public void setCMEEType(String type) { + put(ConfigConstants.CA_EETYPE, type); + } + + public String getCMEEType() { + return (String)get(ConfigConstants.CA_EETYPE); + } + + public void setRequestStatus(String requestStatus) { + put(getCertType()+ConfigConstants.PR_CERT_REQUEST+"Status", requestStatus); + } + + public String getRequestStatus() { + return (String)get(getCertType()+ConfigConstants.PR_CERT_REQUEST+"Status"); + } + + public void setRequestID(String requestID) { + put(getCertType()+ConfigConstants.PR_CERT_REQUEST, requestID); + } + + public String getRequestID() { + return (String)get(getCertType()+ConfigConstants.PR_CERT_REQUEST); + } + + public void setRequestSent(boolean sent) { + if (sent) + put(getCertType()+"Sent", ConfigConstants.TRUE); + else + put(getCertType()+"Sent", ConfigConstants.FALSE); + } + + public boolean requestSent() { + String str = (String)get(getCertType()+"Sent"); + if (str == null || str.equals(ConfigConstants.FALSE)) + return false; + return true; + } + + public void setRequestError(String error) { + put(getCertType()+"Error", error); + } + + public String getRequestError() { + return (String)get(getCertType()+"Error"); + } + + public void setCertSubType(String str) { + put(Constants.PR_CERTIFICATE_SUBTYPE, str); + } + + public String getCertSubType() { + return (String)get(Constants.PR_CERTIFICATE_SUBTYPE); + } + + public void setNicknames(String str) { + put(Constants.PR_ALL_NICKNAMES, str); + } + + public String getNicknames() { + return (String)get(Constants.PR_ALL_NICKNAMES); + } +} + diff --git a/pki/base/console/src/com/netscape/admin/certsrv/keycert/WCACertRequest1Page.java b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WCACertRequest1Page.java new file mode 100644 index 000000000..fe5ebd2d7 --- /dev/null +++ b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WCACertRequest1Page.java @@ -0,0 +1,237 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.admin.certsrv.keycert; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import com.netscape.admin.certsrv.*; +import com.netscape.admin.certsrv.connection.*; +import com.netscape.admin.certsrv.wizard.*; +import com.netscape.certsrv.common.*; + +/** + * Certificate Request from certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WCACertRequest1Page extends WizardBasePanel implements IWizardPanel { + private JTextArea mMethodText; + private JRadioButton mCABtn; + private JRadioButton mSubBtn; + private JRadioButton mExistingKeyBtn; + private JRadioButton mNewKeyBtn; + private JRadioButton mEmailBtn; + private JRadioButton mURLBtn; + private JRadioButton mManualBtn; + private Color mActiveColor; + private static final String PANELNAME = "CACERTREQUESTWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WCACertRequest1Page() { + super(PANELNAME); + init(); + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + if (wizardInfo.getOperationType().equals(wizardInfo.INSTALLTYPE)) + return false; + + if (wizardInfo.getCertType().equals(Constants.PR_CA_SIGNING_CERT)) + return true; + + return false; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + public boolean isLastPage() { + return false; + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + JLabel caLbl = makeJLabel("CATYPE"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.gridwidth = gbc.REMAINDER; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + add(caLbl, gbc); + + mCABtn = makeJRadioButton("SELFSIGN", true); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0,4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mCABtn, gbc); + + mSubBtn = makeJRadioButton("SUBORDINATE", false); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0,4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mSubBtn, gbc); + + ButtonGroup caGroup = new ButtonGroup(); + caGroup.add(mCABtn); + caGroup.add(mSubBtn); + + JLabel keyLbl = makeJLabel("KEYPAIR"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(keyLbl, gbc); + + mExistingKeyBtn = makeJRadioButton("OLDKEY", true); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mExistingKeyBtn, gbc); + + mNewKeyBtn = makeJRadioButton("NEWKEY", true); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mNewKeyBtn, gbc); + + ButtonGroup keyGroup = new ButtonGroup(); + keyGroup.add(mExistingKeyBtn); + keyGroup.add(mNewKeyBtn); + + mMethodText = createTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "CACERTREQUESTWIZARD_TEXT_METHOD_LABEL"), 100), 1, 100); + mActiveColor = mMethodText.getBackground(); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mMethodText, gbc); + + mEmailBtn = makeJRadioButton("EMAIL", true); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mEmailBtn, gbc); + + mURLBtn = makeJRadioButton("URL", false); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mURLBtn, gbc); + + mManualBtn = makeJRadioButton("MANUAL", false); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + gbc.weighty = 1.0; + add(mManualBtn, gbc); + + ButtonGroup methodGroup = new ButtonGroup(); + methodGroup.add(mEmailBtn); + methodGroup.add(mURLBtn); + methodGroup.add(mManualBtn); + + enableFields(false, getBackground()); + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + + if (mCABtn.isSelected()) + wizardInfo.addEntry(wizardInfo.CA_TYPE, wizardInfo.SELF_SIGNED); + else if (mSubBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.CA_TYPE, wizardInfo.SUBORDINATE_CA); + + if (mNewKeyBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.KEY_MATERIAL, Constants.TRUE); + else if (mExistingKeyBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.KEY_MATERIAL, Constants.FALSE); + + if (mEmailBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.SUBMIT_METHOD, wizardInfo.CA_EMAIL); + else if (mURLBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.SUBMIT_METHOD, wizardInfo.CA_URL); + else if (mManualBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.SUBMIT_METHOD, wizardInfo.MANUAL); + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(mCABtn)) + if (mCABtn.isSelected()) + enableFields(false, getBackground()); + else + enableFields(true, mActiveColor); + else if (e.getSource().equals(mSubBtn)) + if (mSubBtn.isSelected()) + enableFields(true, mActiveColor); + else + enableFields(false, getBackground()); + } + + private void enableFields(boolean enable, Color color) { + mMethodText.setEnabled(enable); + mEmailBtn.setEnabled(enable); + mURLBtn.setEnabled(enable); + mManualBtn.setEnabled(enable); + } +} diff --git a/pki/base/console/src/com/netscape/admin/certsrv/keycert/WCAKeyPage.java b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WCAKeyPage.java new file mode 100644 index 000000000..fe06a6313 --- /dev/null +++ b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WCAKeyPage.java @@ -0,0 +1,102 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.admin.certsrv.keycert; + +import java.awt.*; +import javax.swing.*; +import javax.swing.event.*; +import com.netscape.admin.certsrv.*; +import com.netscape.admin.certsrv.connection.*; +import com.netscape.admin.certsrv.wizard.*; +import com.netscape.certsrv.common.*; +import com.netscape.admin.certsrv.config.*; + +/** + * Setup CA signing cert for installation wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.config.install + */ +class WCAKeyPage extends WBaseKeyPage implements IWizardPanel { + private static final String PANELNAME = "CAKEYWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WCAKeyPage() { + super(PANELNAME); + init(); + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + if (wizardInfo.getOperationType().equals(wizardInfo.INSTALLTYPE)) + // (wizardInfo.isNewKey())) + return false; + + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { +/* + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + AdminConnection connection = wizardInfo.getAdminConnection(); + NameValuePairs nvps = new NameValuePairs(); + + nvps.add(Constants.PR_TOKEN_NAME, wizardInfo.getTokenName()); + nvps.add(Constants.PR_KEY_LENGTH, (String)mKeyLengthBox.getSelectedItem()); + nvps.add(Constants.PR_KEY_TYPE, (String)mKeyTypeBox.getSelectedItem()); + + try { + NameValuePairs response = connection.process( + DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_CA_SIGNINGCERT, + Constants.PR_CERT_REQUEST, nvps); + } catch (EAdminException e) { + showErrorDialog(e.toString()); + return false; + } +*/ + + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + super.init(); + } + + public boolean isLastPage() { + return false; + } + + public void getUpdateInfo(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + wizardInfo.addEntry(Constants.PR_KEY_LENGTH, + (String)mKeyLengthBox.getSelectedItem()); + wizardInfo.addEntry(Constants.PR_KEY_TYPE, + (String)mKeyTypeBox.getSelectedItem()); + } +} diff --git a/pki/base/console/src/com/netscape/admin/certsrv/keycert/WCertDNPage.java b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WCertDNPage.java new file mode 100644 index 000000000..661b7e469 --- /dev/null +++ b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WCertDNPage.java @@ -0,0 +1,198 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.admin.certsrv.keycert; + +import java.awt.*; +import java.util.*; +import javax.swing.*; +import javax.swing.border.*; +import javax.swing.event.*; +import com.netscape.admin.certsrv.*; +import com.netscape.admin.certsrv.connection.*; +import com.netscape.admin.certsrv.wizard.*; +import com.netscape.certsrv.common.*; +import com.netscape.admin.certsrv.config.*; + +/** + * CA signing cert for installation wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.config.install + */ +class WCertDNPage extends WBaseDNPage implements IWizardPanel { + private static final String PANELNAME = "CERTDNWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-subjectdn-help"; + + private String certType = ""; + + WCertDNPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WCertDNPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mParent = parent; + mAdminFrame = frame; + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + NameValuePairs nvps = new NameValuePairs(); + nvps.add(Constants.PR_SUBJECT_NAME, wizardInfo.getSubjectName()); + wizardInfo.addEntry(wizardInfo.ALL_INFO, nvps); + + if (wizardInfo.getOperationType().equals(wizardInfo.INSTALLTYPE) || + !wizardInfo.isNewKey()) + return false; + + String title = ""; + certType = wizardInfo.getCertType(); + if (certType.equals(Constants.PR_CA_SIGNING_CERT)) + title = mResource.getString("CERTDNWIZARD_BORDER_CASIGNING_LABEL"); + else if (certType.equals(Constants.PR_OCSP_SIGNING_CERT)) + title = mResource.getString("CERTDNWIZARD_BORDER_OCSPSIGNING_LABEL"); + else if (certType.equals(Constants.PR_RA_SIGNING_CERT)) + title = mResource.getString("CERTDNWIZARD_BORDER_RASIGNING_LABEL"); + else if (certType.equals(Constants.PR_KRA_TRANSPORT_CERT)) + title = mResource.getString("CERTDNWIZARD_BORDER_KRATRANSPORT_LABEL"); + else if (certType.equals(Constants.PR_SERVER_CERT) || + certType.equals(Constants.PR_SERVER_CERT_RADM)) + title = mResource.getString("CERTDNWIZARD_BORDER_SERVER_LABEL"); + else if (certType.equals(Constants.PR_OTHER_CERT)) + title = mResource.getString("CERTDNWIZARD_BORDER_OTHER_LABEL"); + setBorder(new TitledBorder(title)); + +/* + if (wizardInfo.getOperationType().equals(wizardInfo.INSTALLTYPE) || + (wizardInfo.getCAType().equals(wizardInfo.SELF_SIGNED))) + return false; +*/ + + String subjectName = wizardInfo.getSubjectName(); + + //mSubjectStringText.setText(subjectName) + + //dnDesc.setText(subjectName); + //enableFields(true, mActiveColor); + if (subjectName != null) + populateDN(subjectName); + return true; + } + + public boolean validatePanel() { + if (certType.equals(Constants.PR_SERVER_CERT_RADM)) + return true; + return super.validatePanel(); + } + + public boolean concludePanel(WizardInfo info) { + startProgressStatus(); + String str1 = mSubjectDNText.getText().trim(); + String str2 = mSubjectStringText.getText().trim(); + String str = ""; + + if (mDNComponents.isSelected()) { + str = str1; + } else { + str = str2; + } + + if (str.equals("")) { + setErrorMessage("BLANKFIELD"); + return false; + //str = dnDesc.getText().trim(); + } + + str = CMSAdminUtil.getPureString(str); + + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + AdminConnection connection = wizardInfo.getAdminConnection(); + NameValuePairs nvps = new NameValuePairs(); + + nvps.add(Constants.PR_SUBJECT_NAME, str); + wizardInfo.addEntry(Constants.PR_SUBJECT_NAME, str); + + try { + connection.validate(DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_SUBJECT_NAME, nvps); + } catch (EAdminException e) { + //showErrorDialog(e.toString()); + setErrorMessage(e.toString()); + endProgressStatus(); + return false; + } + + if (wizardInfo.isNewKey()) { + String type = wizardInfo.getKeyType(); + if (type.equals("ECC")) { + nvps.add(Constants.PR_KEY_CURVENAME, wizardInfo.getKeyCurveName()); + } else { + nvps.add(Constants.PR_KEY_LENGTH, wizardInfo.getKeyLength()); + } + + nvps.add(Constants.PR_KEY_TYPE, type); + nvps.add(Constants.PR_TOKEN_NAME, wizardInfo.getTokenName()); + } + + wizardInfo.addEntry(wizardInfo.ALL_INFO, nvps); +/* + try { + NameValuePairs response = connection.process( + DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_CERT_REQUEST, wizardInfo.getCertType(), nvps); + for (int i=0; i 0) { +/* + if (mNewKeyBtn.isSelected() || certType.equals(Constants.PR_OTHER_CERT)) { + mTokenBox.setEnabled(true); + mTokenLbl.setEnabled(true); + } else { + mTokenBox.setEnabled(false); + mTokenLbl.setEnabled(false); + } +*/ + return true; + } + + String tokenList = wizardInfo.getTokenList(); + StringTokenizer tokenizer = new StringTokenizer(tokenList, ","); + while (tokenizer.hasMoreTokens()) { + mTokenBox.addItem((String)tokenizer.nextToken()); + } + + mTokenBox.addItemListener(this); + + if (certType.equals(Constants.PR_CA_SIGNING_CERT) || + certType.equals(Constants.PR_RA_SIGNING_CERT) || + certType.equals(Constants.PR_OCSP_SIGNING_CERT) ) { + mDSAKeyTypeBox.setVisible(true); + mKeyTypeBox.setVisible(false); + } else { + mDSAKeyTypeBox.setVisible(false); + mKeyTypeBox.setVisible(true); + } + + String type = (String)mKeyTypeBox.getSelectedItem(); + if (mDSAKeyTypeBox.isVisible()) { + type = (String)mDSAKeyTypeBox.getSelectedItem(); + } + + setLengthCurveFields(type); + enableKeyLengthFields(); + + //if (mNewKeyBtn.isSelected() || certType.equals(Constants.PR_OTHER_CERT)) { + if (mNewKeyBtn.isSelected()) { + mTokenBox.setEnabled(true); + mTokenLbl.setEnabled(true); + } else { + mTokenBox.setEnabled(false); + mTokenLbl.setEnabled(false); + } + +/* + if (certType.equals(Constants.PR_SERVER_CERT)) { + mKeyLengthBox.removeItem("4096"); + mKeyLengthBox.setSelectedIndex(0); + } +*/ + + if (certType.equals(Constants.PR_SERVER_CERT_RADM)) { + mKeyLengthBox.removeItem("768"); + mKeyLengthBox.removeItem("4096"); + mKeyLengthBox.removeItem("Custom"); + mKeyLengthBox.setSelectedIndex(0); + } + + CMSAdminUtil.repaintComp(mTokenBox); + CMSAdminUtil.repaintComp(mTokenLbl); + CMSAdminUtil.repaintComp(mNicknamePanel); + CMSAdminUtil.repaintComp(mNicknameLbl); + CMSAdminUtil.repaintComp(mNicknameBox); + + return true; + } + + public boolean validatePanel() { + if (mKeyLengthText.isVisible() && mKeyLengthText.isEnabled()) { + String str = mKeyLengthText.getText().trim(); + if (str.equals("")) { + setErrorMessage("BLANKLEN"); + return false; + } else { + try { + int num = Integer.parseInt(str); + if (num <= 0) { + setErrorMessage("INVALIDKEYLEN"); + return false; + } + } catch (NumberFormatException e) { + setErrorMessage("NONINTEGER"); + return false; + } + } + } + + /* + if (mKeyCurveText.isVisible() && mKeyCurveText.isEnabled()) { + String str = mKeyCurveText.getText().trim(); + if (str.equals("")) { + setErrorMessage("BLANKCURVE"); + return false; + } + }*/ + + return true; + } + + public boolean concludePanel(WizardInfo info) { + AdminConnection connection = wizardInfo.getAdminConnection(); + NameValuePairs nvps = new NameValuePairs(); + + if (mNewKeyBtn.isSelected()) { + String val = ""; + + if (mKeyLengthBox.isVisible()) { + val = (String)mKeyLengthBox.getSelectedItem(); + } else if (mKeyCurveBox.isVisible()) { + val = (String)mKeyCurveBox.getSelectedItem(); + } else { + if (mDSAKeyLengthBox.isVisible()) + val = (String)mDSAKeyLengthBox.getSelectedItem(); + } + + if (val.equals("Custom")) { + if (mKeyCurveBox.isVisible()) { // ECC + wizardInfo.addEntry(Constants.PR_KEY_CURVENAME, + mKeyCurveText.getText().trim()); + nvps.add(Constants.PR_KEY_CURVENAME, mKeyCurveText.getText().trim()); + } else { + wizardInfo.addEntry(Constants.PR_KEY_LENGTH, + mKeyLengthText.getText().trim()); + nvps.add(Constants.PR_KEY_LENGTH, mKeyLengthText.getText().trim()); + } + } else { + if (mKeyCurveBox.isVisible()) { // ECC + wizardInfo.addEntry(Constants.PR_KEY_CURVENAME, val.trim()); + nvps.add(Constants.PR_KEY_CURVENAME, val.trim()); + } else { + wizardInfo.addEntry(Constants.PR_KEY_LENGTH, val.trim()); + nvps.add(Constants.PR_KEY_LENGTH, val.trim()); + } + } + + if (mKeyTypeBox.isVisible()) { + wizardInfo.addEntry(Constants.PR_KEY_TYPE, + (String)mKeyTypeBox.getSelectedItem()); + nvps.add(Constants.PR_KEY_TYPE, (String)mKeyTypeBox.getSelectedItem()); + } else if (mDSAKeyTypeBox.isVisible()) { + wizardInfo.addEntry(Constants.PR_KEY_TYPE, + (String)mDSAKeyTypeBox.getSelectedItem()); + nvps.add(Constants.PR_KEY_TYPE, (String)mDSAKeyTypeBox.getSelectedItem()); + } + } + + startProgressStatus(); + + String certType = wizardInfo.getCertType(); + nvps.add(Constants.PR_SUBJECT_NAME, ""); + nvps.add(Constants.PR_CERTIFICATE_TYPE, certType); + + try { + // validate the key length or curvename + if (mKeyCurveBox.isVisible()) { //ECC + connection.validate(DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_KEY_CURVENAME, nvps); + } else { + connection.validate(DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_KEY_LENGTH, nvps); + } + + NameValuePairs response = null; + if (!mNewKeyBtn.isSelected()) { + + if (mNicknameBox.isVisible()) { + String nicknameStr = (String)mNicknameBox.getSelectedItem(); + nvps.add(Constants.PR_NICKNAME, nicknameStr); + response = connection.process( + DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_SUBJECT_NAME, + wizardInfo.getCertType(), nvps); + wizardInfo.addEntry(Constants.PR_NICKNAME, nicknameStr); + } else { + response = connection.read( + DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_SUBJECT_NAME, + wizardInfo.getCertType(), nvps); + } + + NameValuePair nvp = response.getPair(Constants.PR_SUBJECT_NAME); + + wizardInfo.addEntry(Constants.PR_SUBJECT_NAME, nvp.getValue()); + } + + if (mNewKeyBtn.isSelected()) { + String tokenName = (String)mTokenBox.getSelectedItem(); + if (tokenName.equals("internal")) + tokenName = Constants.PR_INTERNAL_TOKEN_NAME; + nvps.removeAllPairs(); + nvps.add(Constants.PR_TOKEN_NAME, tokenName); + response = connection.process(DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_TOKEN_STATUS, Constants.RS_ID_CONFIG, nvps); + + NameValuePair result = response.getPair(Constants.PR_LOGGED_IN); + wizardInfo.addEntry(Constants.PR_LOGGED_IN, result.getValue()); + wizardInfo.addEntry(Constants.PR_TOKEN_NAME, tokenName); + } + } catch (EAdminException e) { + //showErrorDialog(e.toString()); + setErrorMessage(e.toString()); + endProgressStatus(); + return false; + } + + endProgressStatus(); + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + JPanel panel = new JPanel(); + GridBagLayout gb1 = new GridBagLayout(); + panel.setLayout(gb1); + + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.gridwidth = gbc.REMAINDER; + gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE, COMPONENT_SPACE); + add(panel, gbc); + + JTextArea selectTokenLbl = createTextArea(mResource.getString( + PANELNAME+"_LABEL_SELECTTOKEN_LABEL")); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.gridwidth = gbc.REMAINDER; + gbc.insets = new Insets(0, 0, COMPONENT_SPACE,0); + panel.add(selectTokenLbl, gbc); + + mTokenLbl = makeJLabel("TOKEN"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.CENTER; + gbc.insets = new Insets(COMPONENT_SPACE, 0, + COMPONENT_SPACE, COMPONENT_SPACE); + gbc.fill = gbc.NONE; + panel.add(mTokenLbl, gbc); + + mTokenBox = new JComboBox(); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + //gbc.weightx = 1.0; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + panel.add(mTokenBox, gbc); + + JTextArea dummy2 = createTextArea(" ", 1, 5); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.gridwidth = gbc.REMAINDER; + gbc.gridheight = gbc.REMAINDER; + panel.add(dummy2, gbc); + + JTextArea createKeyLbl = createTextArea(mResource.getString( + PANELNAME+"_LABEL_KEYPAIR_LABEL")); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE, COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(createKeyLbl, gbc); + + mExistingKeyBtn = makeJRadioButton("OLDKEY", true); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE, COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mExistingKeyBtn, gbc); + + mNicknamePanel = new JPanel(); + GridBagLayout gb3 = new GridBagLayout(); + mNicknamePanel.setLayout(gb3); + + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.gridwidth = gbc.REMAINDER; + gbc.insets = new Insets(COMPONENT_SPACE, 4*COMPONENT_SPACE, + COMPONENT_SPACE, COMPONENT_SPACE); + gbc.fill = gbc.BOTH; + gbc.weightx = 1.0; + add(mNicknamePanel, gbc); + + mNicknameLbl = makeJLabel("NICKNAME"); + CMSAdminUtil.resetGBC(gbc); + //gbc.anchor = gbc.CENTER; + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, COMPONENT_SPACE, + COMPONENT_SPACE, COMPONENT_SPACE); + //gbc.fill = gbc.NONE; + gbc.fill = gbc.HORIZONTAL; + mNicknamePanel.add(mNicknameLbl, gbc); + + JLabel dummy18 = new JLabel(" "); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.gridwidth = gbc.REMAINDER; + gbc.weightx = 1.0; + gbc.fill = gbc.HORIZONTAL; + mNicknamePanel.add(dummy18, gbc); + + mNicknameBox = new JComboBox(); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + //gbc.fill = gbc.NONE; + gbc.fill = gbc.BOTH; + gbc.weightx = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE, 2*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + gbc.gridheight = gbc.REMAINDER; + mNicknamePanel.add(mNicknameBox, gbc); + +/* + JTextArea dummy22 = createTextArea(" ", 1, 5); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.gridwidth = gbc.REMAINDER; + gbc.gridheight = gbc.REMAINDER; + mNicknamePanel.add(dummy22, gbc); +*/ + + mNewKeyBtn = makeJRadioButton("NEWKEY", false); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mNewKeyBtn, gbc); + + ButtonGroup grp = new ButtonGroup(); + grp.add(mExistingKeyBtn); + grp.add(mNewKeyBtn); + +/* + JPanel panel = new JPanel(); + GridBagLayout gb1 = new GridBagLayout(); + panel.setLayout(gb1); +*/ + + keyHeading = makeJLabel("KEY"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.insets = new Insets(COMPONENT_SPACE, 4*COMPONENT_SPACE, + COMPONENT_SPACE, COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + gbc.weightx = 1.0; + add(keyHeading, gbc); + + keyTypeLbl = makeJLabel("KEYTYPE"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.CENTER; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE); + add(keyTypeLbl, gbc); + + mKeyTypeBox = makeJComboBox("KEYTYPE"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE); + gbc.fill = gbc.NONE; + add(mKeyTypeBox, gbc); + + mDSAKeyTypeBox = makeJComboBox("DSAKEYTYPE"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE); + gbc.fill = gbc.NONE; + add(mDSAKeyTypeBox, gbc); + + JLabel dummy = new JLabel(" "); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.gridwidth = gbc.REMAINDER; + gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE); + add(dummy, gbc); + + keyLengthLbl = makeJLabel("KEYLENGTH"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.CENTER; + gbc.fill = gbc.NONE; + //gbc.weighty = 1.0; + //gbc.gridheight = gbc.REMAINDER; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE); + add(keyLengthLbl, gbc); + //panel.add(keyLengthLbl, gbc); + + mKeyLengthBox = makeJComboBox("KEYLENGTH"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.fill = gbc.NONE; + //gbc.weighty = 1.0; + //gbc.gridheight = gbc.REMAINDER; + gbc.insets = new Insets(0, COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE); + add(mKeyLengthBox, gbc); + //panel.add(mKeyLengthBox, gbc); + + mDSAKeyLengthBox = makeJComboBox("DSAKEYLENGTH"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.fill = gbc.NONE; + //gbc.weighty = 1.0; + //gbc.gridheight = gbc.REMAINDER; + gbc.insets = new Insets(0, COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE); + add(mDSAKeyLengthBox, gbc); + //panel.add(mDSAKeyLengthBox, gbc); + + keyCurveLbl = makeJLabel("KEYCURVE"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.CENTER; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE); + add(keyCurveLbl, gbc); + + mKeyCurveBox = makeJComboBox("KEYCURVE"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.fill = gbc.NONE; + gbc.gridwidth = gbc.REMAINDER; + gbc.insets = new Insets(0, COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE); + add(mKeyCurveBox, gbc); + + unitLbl = makeJLabel("UNITS"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.CENTER; + gbc.gridwidth = gbc.REMAINDER; + //gbc.gridheight = gbc.REMAINDER; + //gbc.weighty = 1.0; + gbc.insets = new Insets(0, 0,COMPONENT_SPACE, COMPONENT_SPACE); + add(unitLbl, gbc); + //panel.add(unitLbl, gbc); + + JPanel panel1 = new JPanel(); + GridBagLayout gb2 = new GridBagLayout(); + panel1.setLayout(gb2); + + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.gridwidth = gbc.REMAINDER; + gbc.insets = new Insets(0, 0, 0, 0); + add(panel1, gbc); + + keyLengthCustomText = makeJLabel("CUSTOMKEY"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.WEST; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(COMPONENT_SPACE, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + panel1.add(keyLengthCustomText, gbc); + + keyCurveCustomText = makeJLabel("CUSTOMKEYCURVE"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.WEST; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(COMPONENT_SPACE, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + panel1.add(keyCurveCustomText, gbc); + + mKeyLengthText = makeJTextField(7); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.WEST; + gbc.fill = gbc.NONE; + //gbc.gridheight = gbc.REMAINDER; + gbc.insets = new Insets(0, COMPONENT_SPACE, 0, 0); + panel1.add(mKeyLengthText, gbc); + mActiveColor = mKeyLengthText.getBackground(); + + mKeyCurveText = makeJTextField(7); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.WEST; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(0, COMPONENT_SPACE, 0, 0); + panel1.add(mKeyCurveText, gbc); + + unit1Lbl = makeJLabel("UNITS"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.WEST; + gbc.weightx = 1.0; + gbc.gridwidth = gbc.REMAINDER; + //gbc.gridheight = gbc.REMAINDER; + gbc.insets = new Insets(0, COMPONENT_SPACE, 0, COMPONENT_SPACE); + panel1.add(unit1Lbl, gbc); + + JLabel dummy1 = new JLabel(" "); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.gridwidth = gbc.REMAINDER; + gbc.gridheight = gbc.REMAINDER; + gbc.weighty = 1.0; + add(dummy1, gbc); + + enableFields(false, getBackground()); + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + if (mNewKeyBtn.isSelected()) { + wizardInfo.addEntry(wizardInfo.KEY_MATERIAL, Constants.TRUE); + } else if (mExistingKeyBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.KEY_MATERIAL, Constants.FALSE); + } + + public void actionPerformed(ActionEvent e) { + Object source = e.getSource(); + if (source.equals(mExistingKeyBtn)) { + enableFields(false, getBackground()); + enableKeyLengthFields(); + mTokenBox.setEnabled(false); + mTokenLbl.setEnabled(false); + } else if (source.equals(mNewKeyBtn)) { + String certType = wizardInfo.getCertType(); + if (certType.equals(Constants.PR_CA_SIGNING_CERT)) { + WarningDialog dialog = new WarningDialog(wizardInfo.getFrame(), + "_TEXT_DESC_LABEL"); + } + enableFields(true, mActiveColor); + enableKeyLengthFields(); + mTokenBox.setEnabled(true); + mTokenLbl.setEnabled(true); + } + CMSAdminUtil.repaintComp(mTokenBox); + CMSAdminUtil.repaintComp(mTokenLbl); + } + + public void setLengthCurveFields(String type) { + if (type.equals("RSA")) { + mDSAKeyLengthBox.setVisible(false); + mKeyLengthBox.setVisible(true); + mKeyCurveBox.setVisible(false); + keyLengthCustomText.setVisible(true); + keyCurveCustomText.setVisible(false); + keyLengthLbl.setVisible(true); + keyCurveLbl.setVisible(false); + unit1Lbl.setVisible(true); + unitLbl.setVisible(true); + mKeyLengthText.setVisible(true); + mKeyCurveText.setVisible(false); + } else if (type.equals("ECC")) { + mDSAKeyLengthBox.setVisible(false); + mKeyLengthBox.setVisible(false); + mKeyCurveBox.setVisible(true); + keyLengthCustomText.setVisible(false); + keyCurveCustomText.setVisible(true); + keyLengthLbl.setVisible(false); + keyCurveLbl.setVisible(true); + unit1Lbl.setVisible(false); + unitLbl.setVisible(false); + mKeyLengthText.setVisible(false); + mKeyCurveText.setVisible(true); + } else { + mDSAKeyLengthBox.setVisible(true); + mKeyLengthBox.setVisible(false); + mKeyCurveBox.setVisible(false); + keyLengthCustomText.setVisible(true); + keyCurveCustomText.setVisible(false); + keyLengthLbl.setVisible(true); + keyCurveLbl.setVisible(false); + unit1Lbl.setVisible(true); + unitLbl.setVisible(true); + mKeyLengthText.setVisible(true); + mKeyCurveText.setVisible(false); + } + } + + + public void itemStateChanged(ItemEvent e) { + if (e.getSource().equals(mKeyLengthBox) || + e.getSource().equals(mKeyCurveBox) || + e.getSource().equals(mDSAKeyLengthBox)) { + enableKeyLengthFields(); + } else if (e.getSource().equals(mKeyTypeBox) || + e.getSource().equals(mDSAKeyTypeBox)) { + String type = ""; + if (mKeyTypeBox.isVisible()) + type = (String)mKeyTypeBox.getSelectedItem(); + else if (mDSAKeyTypeBox.isVisible()) + type = (String)mDSAKeyTypeBox.getSelectedItem(); + + setLengthCurveFields(type); + enableKeyLengthFields(); + CMSAdminUtil.repaintComp(this); + } + } + + private void enableKeyLengthFields() { + String value = ""; + + if (mKeyLengthBox.isVisible()) + value = (String)mKeyLengthBox.getSelectedItem(); + else if (mKeyCurveBox.isVisible()) + value = (String)mKeyCurveBox.getSelectedItem(); + else + value = (String)mDSAKeyLengthBox.getSelectedItem(); + + if (value.equals("Custom") && mNewKeyBtn.isSelected()) { + if (mKeyCurveBox.isVisible()) { //ECC + enableFields(keyCurveCustomText, mKeyCurveText, true, mActiveColor); + } else { + enableFields(keyLengthCustomText, mKeyLengthText, true, mActiveColor); + enableFields(unit1Lbl, null, true, mActiveColor); + } + } else { + if (mKeyCurveBox.isVisible()) { //ECC + enableFields(keyCurveCustomText, mKeyCurveText, false, + getBackground()); + } else { + enableFields(keyLengthCustomText, mKeyLengthText, false, + getBackground()); + enableFields(unit1Lbl, null, false, getBackground()); + } + } + } + + protected void enableFields(JComponent comp1, JTextComponent comp2, + boolean enable, Color color) { + if (comp1 != null) { + comp1.setEnabled(enable); + CMSAdminUtil.repaintComp(comp1); + } + if (comp2 != null) { + comp2.setEnabled(enable); + comp2.setBackground(color); + comp2.setEditable(enable); + CMSAdminUtil.repaintComp(comp2); + } + } + + private void enableFields(boolean enable, Color color) { + keyHeading.setEnabled(enable); + keyTypeLbl.setEnabled(enable); + keyLengthLbl.setEnabled(enable); + keyCurveLbl.setEnabled(enable); + unitLbl.setEnabled(enable); + unit1Lbl.setEnabled(enable); + keyLengthCustomText.setEnabled(enable); + keyCurveCustomText.setEnabled(enable); + mKeyLengthText.setEnabled(enable); + mKeyLengthText.setEditable(enable); + mKeyLengthText.setBackground(color); + mKeyCurveText.setEnabled(enable); + mKeyCurveText.setEditable(enable); + mKeyCurveText.setBackground(color); + mKeyTypeBox.setEnabled(enable); + mDSAKeyTypeBox.setEnabled(enable); + mKeyLengthBox.setEnabled(enable); + mKeyCurveBox.setEnabled(enable); + mDSAKeyLengthBox.setEnabled(enable); + repaintComp(keyHeading); + repaintComp(keyTypeLbl); + repaintComp(keyLengthLbl); + repaintComp(keyCurveLbl); + repaintComp(unitLbl); + repaintComp(unit1Lbl); + repaintComp(keyLengthCustomText); + repaintComp(keyCurveCustomText); + repaintComp(mKeyLengthText); + repaintComp(mKeyCurveText); + repaintComp(mKeyTypeBox); + repaintComp(mDSAKeyTypeBox); + repaintComp(mKeyLengthBox); + repaintComp(mKeyCurveBox); + repaintComp(mDSAKeyLengthBox); + } + + private void repaintComp(JComponent component) { + component.invalidate(); + component.validate(); + component.repaint(1); + } +} diff --git a/pki/base/console/src/com/netscape/admin/certsrv/keycert/WManualCertRequestPage.java b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WManualCertRequestPage.java new file mode 100644 index 000000000..4ad069133 --- /dev/null +++ b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WManualCertRequestPage.java @@ -0,0 +1,199 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.admin.certsrv.keycert; + +import java.util.*; +import java.awt.*; +import java.io.*; +import javax.swing.*; +import com.netscape.admin.certsrv.*; +import com.netscape.admin.certsrv.connection.*; +import com.netscape.admin.certsrv.wizard.*; +import com.netscape.certsrv.common.*; +import com.netscape.admin.certsrv.config.*; +import com.netscape.admin.certsrv.task.*; + +/** + * Generate cert request page for cert setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WManualCertRequestPage extends WBaseManualCertRequestPage implements IWizardPanel { + + public static final String SERVER_CERT = "server"; + public static final String CLIENT_CERT = "client"; + public static final String CA_CERT = "ca"; + public static final String RA_CERT = "ra"; + public static final String OCSP_CERT = "ocsp"; + public static final String OBJECT_SIGNING_CERT = "objSignClient"; + public static final String OTHER_CERT = "other"; + public static final String ROUTER_CERT = "router"; // deprecated + public static final String CEP_CERT = "CEP-Request"; + + private static final String PANELNAME = "MANUALCERTREQUESTWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-displaycertrequest-help"; + + WManualCertRequestPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WManualCertRequestPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mParent = parent; + mAdminFrame = frame; + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + + if (wizardInfo.getOperationType().equals(wizardInfo.INSTALLTYPE) || + wizardInfo.getCAType().equals(wizardInfo.SELF_SIGNED)) + return false; + + String str = wizardInfo.getCSR(); +// mText.setText(CMSAdminUtil.certRequestWrapText(str, 40)); + mText.setText(str); + mText.selectAll(); + setBorder(makeTitledBorder(PANELNAME)); + + CMSServerInfo serverInfo = wizardInfo.getServerInfo(); + String certType = wizardInfo.getCertType(); + if (certType.equals(Constants.PR_CA_SIGNING_CERT)) { + mDesc.setText(mResource.getString(mPanelName+"_TEXT_CADESC_LABEL")); + str = mResource.getString(mPanelName+"_TEXT_CAFILELOC_LABEL"); + } else if (certType.equals(Constants.PR_OCSP_SIGNING_CERT)) { + str = mResource.getString(mPanelName+"_TEXT_OCSPFILELOC_LABEL"); + mDesc.setText(mResource.getString(mPanelName+"_TEXT_RADESC_LABEL")); + } else if (certType.equals(Constants.PR_RA_SIGNING_CERT)) { + str = mResource.getString(mPanelName+"_TEXT_RAFILELOC_LABEL"); + mDesc.setText(mResource.getString(mPanelName+"_TEXT_RADESC_LABEL")); + } else if (certType.equals(Constants.PR_KRA_TRANSPORT_CERT)) { + str = mResource.getString(mPanelName+"_TEXT_KRAFILELOC_LABEL"); + mDesc.setText(mResource.getString(mPanelName+"_TEXT_KRADESC_LABEL")); + } else if (certType.equals(Constants.PR_SERVER_CERT)) { + str = mResource.getString(mPanelName+"_TEXT_SSLFILELOC_LABEL"); + mDesc.setText(mResource.getString(mPanelName+"_TEXT_SSLDESC_LABEL")); + } else if (certType.equals(Constants.PR_SERVER_CERT_RADM)) { + str = mResource.getString(mPanelName+"_TEXT_SSLRADMFILELOC_LABEL"); + mDesc.setText(mResource.getString(mPanelName+"_TEXT_SSLDESC_LABEL")); + } else if (certType.equals(Constants.PR_OTHER_CERT)) { + str = mResource.getString(mPanelName+"_TEXT_OTHERFILELOC_LABEL"); + mDesc.setText(mResource.getString(mPanelName+"_TEXT_OTHERDESC_LABEL")); + } + + String dir = wizardInfo.getCertRequestDir(); + mFileName.setText(str+dir+"."); + + if (mSendNowBox.isSelected()) + enableFields(true, mActiveColor); + else + enableFields(false, getBackground()); + String host = wizardInfo.getCMHost(); + if (host != null && !host.equals("")) + mHostText.setText(host); + String port = wizardInfo.getCMEEPort(); + if (port != null && !port.equals("")) + mPortText.setText(port); + + return true; + } + + public boolean validatePanel() { + return super.validatePanel(); + } + + public boolean concludePanel(WizardInfo info) { + if (!mSendNowBox.isSelected()) + return true; + + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + if (mHost != null && !mHost.equals("")) + wizardInfo.setCMHost(mHost); + if (mPort != null && !mPort.equals("")) + wizardInfo.setCMEEPort(mPort); + if (mSSL.isSelected()) + wizardInfo.setCMEEType("https"); + else + wizardInfo.setCMEEType("http"); + + CMSCertRequest requestCertCgi = new CMSCertRequest(); + requestCertCgi.initialize(wizardInfo); + Hashtable data = new Hashtable(); + + String certType = null; + + String mReqType = wizardInfo.getCertType(); + String mReq = null; + + mReq = wizardInfo.getCSR(); + + if (mReqType.equals(Constants.PR_CA_SIGNING_CERT)){ + data.put("profileId", "caCACert"); + }else if (mReqType.equals(Constants.PR_SERVER_CERT) || + mReqType.equals(Constants.PR_KRA_TRANSPORT_CERT)){ + data.put("profileId", "caServerCert"); + }else if (mReqType.equals(Constants.PR_OCSP_SIGNING_CERT)){ + data.put("profileId", "caOCSPCert"); + }else if (mReqType.equals(Constants.PR_RA_SIGNING_CERT)){ + data.put("profileId", "caRACert"); + }else if (mReqType.equals(Constants.PR_OTHER_CERT)) { + data.put("profileId", "caOtherCert"); + } else { + data.put("profileId", mReqType); + } + + data.put("cert_request_type", "pkcs10"); + data.put("cert_request", mReq); + + startProgressStatus(); + boolean ready = requestCertCgi.requestCert(data); + endProgressStatus(); + + if (!ready) { + String str = requestCertCgi.getErrorMessage(); + if (str.equals("")) + setErrorMessage("Server Error"); + else + setErrorMessage(str); + } + + wizardInfo.setRequestSent(ready); + return ready; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/pki/base/console/src/com/netscape/admin/certsrv/keycert/WOperationSelectionPage.java b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WOperationSelectionPage.java new file mode 100644 index 000000000..f2cdeff3d --- /dev/null +++ b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WOperationSelectionPage.java @@ -0,0 +1,134 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.admin.certsrv.keycert; + +import java.awt.*; +import java.util.*; +import javax.swing.*; +import com.netscape.admin.certsrv.*; +import com.netscape.admin.certsrv.wizard.*; +import com.netscape.certsrv.common.*; + +/** + * Operation Selection page for certificate setup wizard + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WOperationSelectionPage extends WizardBasePanel implements IWizardPanel { + private JRadioButton mInstallBtn; + private JRadioButton mRequestBtn; + private JComboBox mToken; + private static final String PANELNAME = "OPERATIONSELECTIONWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-operationselection-help"; + + WOperationSelectionPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WOperationSelectionPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mParent = parent; + mAdminFrame = frame; + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + String mode = wizardInfo.getMode(); + // Fixes Bugscape Bug #55862: console - Certificate Setup Wizard + // throws Null Pointer Exception + if (mode != null && mode.equals("0")) { + info.addEntry(wizardInfo.OPTYPE, wizardInfo.INSTALLTYPE); + return false; + } + setBorder(makeTitledBorder(PANELNAME)); + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + startProgressStatus(); + if (mRequestBtn.isSelected()) + info.addEntry(wizardInfo.OPTYPE, wizardInfo.REQUESTTYPE); + else + info.addEntry(wizardInfo.OPTYPE, wizardInfo.INSTALLTYPE); + endProgressStatus(); + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + CMSAdminUtil.resetGBC(gbc); + JTextArea operationTypeLbl = createTextArea(mResource.getString( + PANELNAME+"_LABEL_OPERATIONTYPE_LABEL")); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 0.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(operationTypeLbl, gbc); + + CMSAdminUtil.resetGBC(gbc); + mRequestBtn = makeJRadioButton("REQUEST", true); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mRequestBtn, gbc); + + ButtonGroup btnGroup = new ButtonGroup(); + CMSAdminUtil.resetGBC(gbc); + mInstallBtn = makeJRadioButton("INSTALL", false); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(0,COMPONENT_SPACE,COMPONENT_SPACE, 0); + gbc.gridwidth = gbc.REMAINDER; + add(mInstallBtn, gbc); + + btnGroup.add(mInstallBtn); + btnGroup.add(mRequestBtn); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/pki/base/console/src/com/netscape/admin/certsrv/keycert/WOtherCertRequest1Page.java b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WOtherCertRequest1Page.java new file mode 100644 index 000000000..1dbd614d1 --- /dev/null +++ b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WOtherCertRequest1Page.java @@ -0,0 +1,176 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.admin.certsrv.keycert; + +import java.awt.*; +import javax.swing.*; +import com.netscape.admin.certsrv.*; +import com.netscape.admin.certsrv.connection.*; +import com.netscape.admin.certsrv.wizard.*; +import com.netscape.certsrv.common.*; + +/** + * Certificate Request from certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WOtherCertRequest1Page extends WizardBasePanel implements IWizardPanel { + private JRadioButton mExistingKeyBtn; + private JRadioButton mNewKeyBtn; + private JRadioButton mEmailBtn; + private JRadioButton mURLBtn; + private JRadioButton mManualBtn; + private static final String PANELNAME = "CACERTREQUESTWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WOtherCertRequest1Page() { + super(PANELNAME); + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + if (wizardInfo.getOperationType().equals(wizardInfo.INSTALLTYPE)) + return false; + + String type = wizardInfo.getCertType(); + if (type.equals(Constants.PR_CA_SIGNING_CERT)) + return false; + + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + + if (mNewKeyBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.KEY_MATERIAL, Constants.TRUE); + else if (mExistingKeyBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.KEY_MATERIAL, Constants.FALSE); + + if (mEmailBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.SUBMIT_METHOD, wizardInfo.CA_EMAIL); + else if (mURLBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.SUBMIT_METHOD, wizardInfo.CA_URL); + else if (mManualBtn.isSelected()) + wizardInfo.addEntry(wizardInfo.SUBMIT_METHOD, wizardInfo.MANUAL); + + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + JTextArea methodText = createTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "CACERTREQUESTWIZARD_TEXT_METHOD_LABEL"), 80), 2, 80); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(methodText, gbc); + + mEmailBtn = makeJRadioButton("EMAIL", true); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mEmailBtn, gbc); + + mURLBtn = makeJRadioButton("URL", false); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mURLBtn, gbc); + + mManualBtn = makeJRadioButton("MANUAL", false); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mManualBtn, gbc); + + JLabel keyLbl = makeJLabel("KEYPAIR"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(keyLbl, gbc); + + mExistingKeyBtn = makeJRadioButton("OLDKEY", true); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mExistingKeyBtn, gbc); + + mNewKeyBtn = makeJRadioButton("NEWKEY", false); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + gbc.weighty = 1.0; + add(mNewKeyBtn, gbc); + + ButtonGroup methodGroup = new ButtonGroup(); + methodGroup.add(mURLBtn); + methodGroup.add(mManualBtn); + methodGroup.add(mEmailBtn); + + ButtonGroup keyGroup = new ButtonGroup(); + keyGroup.add(mExistingKeyBtn); + keyGroup.add(mNewKeyBtn); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/pki/base/console/src/com/netscape/admin/certsrv/keycert/WPasteCertPage.java b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WPasteCertPage.java new file mode 100644 index 000000000..8dda6e32d --- /dev/null +++ b/pki/base/console/src/com/netscape/admin/certsrv/keycert/WPasteCertPage.java @@ -0,0 +1,264 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.admin.certsrv.keycert; + +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import javax.swing.*; +import javax.swing.text.*; +import com.netscape.admin.certsrv.*; +import com.netscape.admin.certsrv.connection.*; +import com.netscape.admin.certsrv.wizard.*; +import com.netscape.certsrv.common.*; + +/** + * This page is to install the certificate in the internal token. The user can + * import the cert from the file or paste the Base 64 encoded blob in the + * text area. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.config.install + */ +class WPasteCertPage extends WizardBasePanel implements IWizardPanel { + private JRadioButton mFileBtn; + private JRadioButton mBase64Btn; + private JTextField mFileText; + private JTextArea mBase64Text; + private JButton mPaste; + private JTextArea introLbl; + private Color mActiveColor; + private String mCertContent = ""; + private String mCertFilePath = ""; + private static final String PANELNAME = "PASTECERTWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-pastecert-help"; + + WPasteCertPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WPasteCertPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mParent = parent; + mAdminFrame = frame; + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + if (wizardInfo.getOperationType().equals(wizardInfo.REQUESTTYPE)) + return false; + setBorder(makeTitledBorder(PANELNAME)); + return true; + } + + public boolean validatePanel() { + if (mBase64Btn.isSelected()) { + mCertContent = mBase64Text.getText().trim(); + if (mCertContent.equals("")) { + setErrorMessage("B64EEMPTY"); + return false; + } + } else if (mFileBtn.isSelected()) { + mCertFilePath = mFileText.getText().trim(); + if (mCertFilePath.equals("")) { + setErrorMessage("EMPTYFILE"); + return false; + } + } + return true; + } + + public boolean concludePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + startProgressStatus(); + wizardInfo.addEntry(Constants.PR_PKCS10, mCertContent); + //cert = CMSAdminUtil.getPureString(mBase64Text.getText().trim()); + + AdminConnection connection = wizardInfo.getAdminConnection(); + NameValuePairs nvps = new NameValuePairs(); + + if (mFileBtn.isSelected()) { + nvps.add(Constants.PR_CERT_FILEPATH, mCertFilePath); + wizardInfo.setCertFilePath(mCertFilePath); + wizardInfo.setPKCS10(""); + } else if (mBase64Btn.isSelected()) { + nvps.add(Constants.PR_PKCS10, mCertContent); + wizardInfo.setPKCS10(mCertContent); + wizardInfo.setCertFilePath(""); + } + + try { + NameValuePairs response = connection.process( + DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_CERTINFO, wizardInfo.getInstallCertType(), nvps); + + for (int i=0; i