diff options
Diffstat (limited to 'base/console/src/com/netscape/admin/certsrv/keycert')
34 files changed, 6345 insertions, 0 deletions
diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizard.java b/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizard.java new file mode 100644 index 000000000..f7650decb --- /dev/null +++ b/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/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizardInfo.java b/base/console/src/com/netscape/admin/certsrv/keycert/CertSetupWizardInfo.java new file mode 100644 index 000000000..81ffc2d0e --- /dev/null +++ b/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/base/console/src/com/netscape/admin/certsrv/keycert/WCACertRequest1Page.java b/base/console/src/com/netscape/admin/certsrv/keycert/WCACertRequest1Page.java new file mode 100644 index 000000000..fe5ebd2d7 --- /dev/null +++ b/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/base/console/src/com/netscape/admin/certsrv/keycert/WCAKeyPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WCAKeyPage.java new file mode 100644 index 000000000..fe06a6313 --- /dev/null +++ b/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/base/console/src/com/netscape/admin/certsrv/keycert/WCertDNPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WCertDNPage.java new file mode 100644 index 000000000..1c2268bb2 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WCertDNPage.java @@ -0,0 +1,196 @@ +// --- 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 javax.swing.*; +import javax.swing.border.*; + +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.put(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.put(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.put(Constants.PR_KEY_CURVENAME, wizardInfo.getKeyCurveName()); + } else { + nvps.put(Constants.PR_KEY_LENGTH, wizardInfo.getKeyLength()); + } + + nvps.put(Constants.PR_KEY_TYPE, type); + nvps.put(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<response.size(); i++) { + NameValuePair nvp = response.elementAt(i); + String key = nvp.getName(); + String value = nvp.getValue(); + if (key.equals(Constants.PR_CSR)) { + wizardInfo.addEntry(Constants.PR_CSR, value); + break; + } + } + } catch (EAdminException e) { + //showErrorDialog(e.toString()); + setErrorMessage(e.toString()); + return false; + } +*/ + + endProgressStatus(); + wizardInfo.setSubjectName(str); + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WCertDNValidityPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WCertDNValidityPage.java new file mode 100644 index 000000000..d6359cf6c --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WCertDNValidityPage.java @@ -0,0 +1,100 @@ +// --- 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.*; + +/** + * CA signing cert for installation wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.config.install + */ +class WCertDNValidityPage extends WBaseDNValidityPage implements IWizardPanel { + private static final String PANELNAME = "CERTDNVALIDWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WCertDNValidityPage() { + super(PANELNAME); + 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.SUBORDINATE_CA))) + return false; + + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + String str = mSubjectDNText.getText().trim(); + + if (str.equals("")) { + setErrorMessage("BLANKFIELD"); + return false; + } + + str = CMSAdminUtil.getPureString(str); + + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + wizardInfo.addEntry(Constants.PR_SUBJECT_NAME, str); + + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + String valid = mValidityText.getText().trim(); + int period = Integer.parseInt(valid); + int index = mUnitBox.getSelectedIndex(); + + if (index == 1) { + period = period*30; + } else if (index == 2) { + period = period*365; + } + wizardInfo.addEntry(Constants.PR_VALIDITY_PERIOD, ""+period); + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WCertExtensionPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WCertExtensionPage.java new file mode 100644 index 000000000..f7505be2e --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WCertExtensionPage.java @@ -0,0 +1,273 @@ +// --- 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 javax.swing.border.*; +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.*; + +/** + * Certificate Extension for setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.config.install + */ +class WCertExtensionPage extends WBaseCertExtensionPage implements + IWizardPanel { + private static final String PANELNAME = "CERTEXTENSION1WIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-extension-help"; + + WCertExtensionPage(JDialog parent) { + super(PANELNAME); + mPanelName = PANELNAME; + mParent = parent; + init(); + } + + WCertExtensionPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mPanelName = PANELNAME; + mParent = parent; + mAdminFrame = frame; + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + //System.out.println("extension"); + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + if (wizardInfo.getOperationType().equals(wizardInfo.INSTALLTYPE)) + return false; + + if (wizardInfo.getCAType().equals(wizardInfo.SUBORDINATE_CA) + && !(wizardInfo.isSSLCertLocalCA())) + return false; + + String title = ""; + + if (!mModified) { + String certType = wizardInfo.getCertType(); + if (certType.equals(Constants.PR_CA_SIGNING_CERT)) { + title = mResource.getString( + "CERTEXTENSION1WIZARD_BORDER_CASIGNING_LABEL"); + mBasicCheckBox.setSelected(true); + mAKICheckBox.setSelected(true); + mCACheckBox.setSelected(true); + mSKICheckBox.setSelected(true); + mCertPathBox.setSelected(false); + mExtendedKeyCheckBox.setSelected(false); + mExtendedKeyCheckBox.setEnabled(true); + mKeyUsageBox.setSelected(true); + mOCSPNoCheck.setSelected(false); + mOCSPNoCheck.setEnabled(true); + mAIACheckBox.setSelected(true); + } else if (certType.equals(Constants.PR_OCSP_SIGNING_CERT)) { + title = mResource.getString( + "CERTEXTENSION1WIZARD_BORDER_OCSPSIGNING_LABEL"); + mKeyUsageBox.setSelected(true); + mSKICheckBox.setSelected(false); + mSKICheckBox.setEnabled(true); + mBasicCheckBox.setEnabled(false); + mAKICheckBox.setSelected(true); + mAKICheckBox.setEnabled(true); + mCACheckBox.setSelected(false); + mCACheckBox.setEnabled(false); + mCertPathBox.setEnabled(false); + mExtendedKeyCheckBox.setSelected(true); + mOCSPSigning.setSelected(true); + mOCSPNoCheck.setSelected(false); + mOCSPNoCheck.setEnabled(true); + mAIACheckBox.setSelected(true); + } else if (certType.equals(Constants.PR_RA_SIGNING_CERT)) { + title = mResource.getString( + "CERTEXTENSION1WIZARD_BORDER_RASIGNING_LABEL"); + mAKICheckBox.setSelected(true); + mExtendedKeyCheckBox.setSelected(true); + mSSLClient.setSelected(true); + } else if (certType.equals(Constants.PR_KRA_TRANSPORT_CERT)) { + title = mResource.getString( + "CERTEXTENSION1WIZARD_BORDER_KRATRANSPORT_LABEL"); + mAKICheckBox.setSelected(true); + } else if (certType.equals(Constants.PR_SERVER_CERT)) { + title = mResource.getString( + "CERTEXTENSION1WIZARD_BORDER_SERVER_LABEL"); + mExtendedKeyCheckBox.setSelected(true); + mSSLServer.setSelected(true); + mAKICheckBox.setSelected(true); + mSKICheckBox.setSelected(false); + mSKICheckBox.setEnabled(true); + mOCSPNoCheck.setSelected(false); + mOCSPNoCheck.setEnabled(true); + mAIACheckBox.setSelected(true); + } else if (certType.equals(Constants.PR_SERVER_CERT_RADM)) { + title = mResource.getString( + "CERTEXTENSION1WIZARD_BORDER_SERVER_LABEL"); + mExtendedKeyCheckBox.setSelected(true); + mAKICheckBox.setSelected(true); + mSSLServer.setSelected(true); + } + } + + setBorder(new TitledBorder(title)); + + return super.initializePanel(info); + } + + public boolean concludePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + + if (mMIMECheckBox.isSelected()) { + startProgressStatus(); + NameValuePairs nvps = new NameValuePairs(); + nvps.put(ConfigConstants.PR_CERTIFICATE_EXTENSION, mMIMEText.getText().trim()); + AdminConnection connection = wizardInfo.getAdminConnection(); + try { + connection.validate( + DestDef.DEST_SERVER_ADMIN, ScopeDef.SC_CERTIFICATE_EXTENSION, nvps); + } catch (EAdminException e) { + setErrorMessage(e.toString()); + return false; + } + endProgressStatus(); + } + + NameValuePairs nvps = new NameValuePairs(); + + nvps.put(Constants.PR_SUBJECT_NAME, wizardInfo.getSubjectName()); + if (wizardInfo.isNewKey()) { + String type = wizardInfo.getKeyType(); + if (type.equals("ECC")) { + nvps.put(Constants.PR_KEY_CURVENAME, wizardInfo.getKeyCurveName()); + } else { + nvps.put(Constants.PR_KEY_LENGTH, wizardInfo.getKeyLength()); + } + nvps.put(Constants.PR_KEY_TYPE, type); + nvps.put(Constants.PR_TOKEN_NAME, wizardInfo.getTokenName()); + } + //nvps.add(Constants.PR_VALIDITY_PERIOD, wizardInfo.getValidityPeriod()); + addValidityPeriod(wizardInfo, nvps); + + if (mBasicCheckBox.isSelected()) + addBasicConstraints(nvps); + + if (mExtendedKeyCheckBox.isSelected()) + addExtendedKey(nvps); + + if (mAIACheckBox.isSelected()) + nvps.put(Constants.PR_AIA, Constants.TRUE); + + if (mAKICheckBox.isSelected()) + nvps.put(Constants.PR_AKI, Constants.TRUE); + + if (mSKICheckBox.isSelected()) + nvps.put(Constants.PR_SKI, Constants.TRUE); + + if (mOCSPNoCheck.isSelected()) + nvps.put(Constants.PR_OCSP_NOCHECK, Constants.TRUE); + + if (mKeyUsageBox.isSelected()) + nvps.put(Constants.PR_KEY_USAGE, Constants.TRUE); + + if (mMIMECheckBox.isSelected()) + nvps.put(Constants.PR_DER_EXTENSION, mMIMEText.getText().trim()); + + wizardInfo.addEntry(wizardInfo.ALL_INFO, nvps); + + mModified = true; + return true; + } + + private void addValidityPeriod(CertSetupWizardInfo wizardInfo, + NameValuePairs nvps) { + nvps.put(Constants.PR_BEGIN_YEAR, wizardInfo.getBeginYear()); + nvps.put(Constants.PR_BEGIN_MONTH, wizardInfo.getBeginMonth()); + nvps.put(Constants.PR_BEGIN_DATE, wizardInfo.getBeginDate()); + nvps.put(Constants.PR_BEGIN_HOUR, wizardInfo.getBeginHour()); + nvps.put(Constants.PR_BEGIN_MIN, wizardInfo.getBeginMin()); + nvps.put(Constants.PR_BEGIN_SEC, wizardInfo.getBeginSec()); + nvps.put(Constants.PR_AFTER_YEAR, wizardInfo.getAfterYear()); + nvps.put(Constants.PR_AFTER_MONTH, wizardInfo.getAfterMonth()); + nvps.put(Constants.PR_AFTER_DATE, wizardInfo.getAfterDate()); + nvps.put(Constants.PR_AFTER_HOUR, wizardInfo.getAfterHour()); + nvps.put(Constants.PR_AFTER_MIN, wizardInfo.getAfterMin()); + nvps.put(Constants.PR_AFTER_SEC, wizardInfo.getAfterSec()); + } + + private void addBasicConstraints(NameValuePairs nvps) { + + if (mCACheckBox.isSelected()) + nvps.put(Constants.PR_IS_CA, Constants.TRUE); + + String certLen = mCertPathText.getText().trim(); + if (!certLen.equals("")) + nvps.put(Constants.PR_CERT_LEN, certLen); + } + + private void addExtendedKey(NameValuePairs nvps) { + + if (mSSLClient.isSelected()) + nvps.put(Constants.PR_SSL_CLIENT_BIT, Constants.TRUE); + if (mSSLServer.isSelected()) + nvps.put(Constants.PR_SSL_SERVER_BIT, Constants.TRUE); + if (mSSLMail.isSelected()) + nvps.put(Constants.PR_SSL_MAIL_BIT, Constants.TRUE); + if (mObjectSigning.isSelected()) + nvps.put(Constants.PR_OBJECT_SIGNING_BIT, Constants.TRUE); + if (mTimeStamping.isSelected()) + nvps.put(Constants.PR_TIMESTAMPING_BIT, Constants.TRUE); + if (mOCSPSigning.isSelected()) + nvps.put(Constants.PR_OCSP_SIGNING, Constants.TRUE); + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } + + private String getScope(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + String certType = wizardInfo.getCertType(); + String scope = ""; + if (certType.equals(Constants.PR_CA_SIGNING_CERT)) { + scope = ScopeDef.SC_CA_SIGNINGCERT; + } else if (certType.equals(Constants.PR_RA_SIGNING_CERT)) { + scope = ScopeDef.SC_RA_SIGNINGCERT; + } else if (certType.equals(Constants.PR_KRA_TRANSPORT_CERT)) { + scope = ScopeDef.SC_KRA_TRANSPORTCERT; + } else if (certType.equals(Constants.PR_SERVER_CERT)) { + scope = ScopeDef.SC_SERVER_CERT; + } + + return scope; + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WCertMessageDigestPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WCertMessageDigestPage.java new file mode 100644 index 000000000..a378e91d3 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WCertMessageDigestPage.java @@ -0,0 +1,113 @@ +// --- 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.util.*; +import javax.swing.*; +import javax.swing.text.*; +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.*; +import com.netscape.admin.certsrv.task.*; + +/** + * Setup the message digest information for the installation wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.config.install + */ +class WCertMessageDigestPage extends WMessageDigestPage { + + private static final String PANELNAME = "CERTMESSAGEDIGESTWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-messagedigest-help"; + + WCertMessageDigestPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + } + + WCertMessageDigestPage(JDialog parent, JFrame adminFrame) { + super(PANELNAME); + mParent = parent; + mAdminFrame = adminFrame; + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + String certType = wizardInfo.getCertType(); + + mCAKeyType = (String)wizardInfo.get(Constants.PR_KEY_TYPE); + + if (wizardInfo.getOperationType().equals(wizardInfo.INSTALLTYPE)) + return false; + + if ((wizardInfo.getCAType().equals(wizardInfo.SUBORDINATE_CA)) + && !(wizardInfo.isSSLCertLocalCA())) + return false; + + if (!wizardInfo.isNewKey()) + return false; + + if (wizardInfo.getCAType().equals(wizardInfo.SELF_SIGNED) && + certType.equals(Constants.PR_CA_SIGNING_CERT)) { + enableSignedByFields(true); + } else { + enableSignedByFields(false); + } + + if ((!certType.equals(Constants.PR_CA_SIGNING_CERT)) && + (!certType.equals(Constants.PR_OCSP_SIGNING_CERT))) { + + // (!certType.equals(Constants.PR_KRA_TRANSPORT_CERT))) { + // non-signing cert, algorithm specified by CA + return false; + } + + return super.initializePanel(info); + } + + public void getUpdateInfo(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + if (mDSAHashTypeBox.isVisible()) + wizardInfo.setHashType((String)mDSAHashTypeBox.getSelectedItem()); + else if (mECCHashTypeBox.isVisible()) + wizardInfo.setHashType((String)mECCHashTypeBox.getSelectedItem()); + else if (mRSAHashTypeBox.isVisible()) + wizardInfo.setHashType((String)mRSAHashTypeBox.getSelectedItem()); + + if (mDSASignedByTypeBox.isVisible()) + wizardInfo.setSignedByType((String)mDSASignedByTypeBox.getSelectedItem()); + else if (mECCSignedByTypeBox.isVisible()) + wizardInfo.setSignedByType((String)mECCSignedByTypeBox.getSelectedItem()); + else if (mRSASignedByTypeBox.isVisible()) + wizardInfo.setSignedByType((String)mRSASignedByTypeBox.getSelectedItem()); + + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WCertRequestPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WCertRequestPage.java new file mode 100644 index 000000000..8fa126148 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WCertRequestPage.java @@ -0,0 +1,81 @@ +// --- 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.admin.certsrv.config.*; + +/** + * Introduction page for installation wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.config.install + */ +class WCertRequestPage extends WBaseCertRequestPage implements IWizardPanel { + private static final String PANELNAME = "COPYCERTREQUESTWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WCertRequestPage() { + super(PANELNAME); + 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); + setBorder(makeTitledBorder("COPYCERTREQUESTWIZARD")); + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WCertTypePage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WCertTypePage.java new file mode 100644 index 000000000..88350fc32 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WCertTypePage.java @@ -0,0 +1,500 @@ +// --- 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.*; + +/** + * Select certificate type from certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WCertTypePage extends WizardBasePanel implements IWizardPanel, + ItemListener { + private String mCASigningCert; + private String mRASigningCert; + private String mOCSPSigningCert; + private String mServerCert, mServerCertRadm, mOtherCert; + private String mKRATransportCert; + private JTextArea mCALbl; + private JRadioButton mCABtn; + private JRadioButton mSubBtn; + private JComboBox mCertBox; + private JTextArea mCertType; + private JTextField mCertTypeText; + private Color mActiveColor; + private static final String PANELNAME = "CERTTYPEWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-certtype-help"; + + WCertTypePage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WCertTypePage(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)) + return false; + + setBorder(makeTitledBorder(PANELNAME)); + if (wizardInfo.getCertType() != null) { + return true; + } + + AdminConnection connection = wizardInfo.getAdminConnection(); + NameValuePairs nvps = new NameValuePairs(); + + try { + NameValuePairs response = connection.search(DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_SUBSYSTEM, nvps); + + for (String name : response.keySet()) { + String type = response.get(name); + + if (type.equals(Constants.PR_RA_INSTANCE)) + mRASigningCert = mResource.getString( + "CERTTYPEWIZARD_LABEL_RASIGNINGCERT_LABEL"); + else if (type.equals(Constants.PR_CA_INSTANCE)) + mCASigningCert = mResource.getString( + "CERTTYPEWIZARD_LABEL_CASIGNINGCERT_LABEL"); + else if (type.equals(Constants.PR_KRA_INSTANCE)) + mKRATransportCert = mResource.getString( + "CERTTYPEWIZARD_LABEL_KRATRANSPORTCERT_LABEL"); + } + } catch (EAdminException e) { + //showErrorDialog(e.toString()); + setErrorMessage(e.toString()); + } + + mOCSPSigningCert = mResource.getString( + "CERTTYPEWIZARD_LABEL_OCSPSIGNINGCERT_LABEL"); + + mServerCert = mResource.getString( + "CERTTYPEWIZARD_LABEL_SERVERCERT_LABEL"); + + mServerCertRadm = mResource.getString( + "CERTTYPEWIZARD_LABEL_SERVERCERTRADM_LABEL"); + + mOtherCert = mResource.getString( + "CERTTYPEWIZARD_LABEL_OTHER_LABEL"); + + mCertBox.removeAllItems(); + + if (mCASigningCert != null) + mCertBox.addItem(mCASigningCert); + + if (mRASigningCert != null) + mCertBox.addItem(mRASigningCert); + + if (mKRATransportCert != null) + mCertBox.addItem(mKRATransportCert); + + if (mOCSPSigningCert != null) + mCertBox.addItem(mOCSPSigningCert); + + if (mServerCert != null) + mCertBox.addItem(mServerCert); + +/* + if (mServerCertRadm != null) + mCertBox.addItem(mServerCertRadm); +*/ + + mCertBox.addItem(mOtherCert); + mCertBox.setSelectedIndex(0); + + String certType = (String)mCertBox.getSelectedItem(); + + if (certType.equals(mOtherCert)) { + mCABtn.setEnabled(false); + mSubBtn.setEnabled(false); + mCALbl.setEnabled(false); + mCertType.setEnabled(true); + mCertTypeText.setEnabled(true); + mCertTypeText.setBackground(mActiveColor); + } else { + mCABtn.setEnabled(true); + mSubBtn.setEnabled(true); + mCALbl.setEnabled(true); + mCertType.setEnabled(false); + mCertTypeText.setEnabled(false); + mCertTypeText.setBackground(getBackground()); + if ((mCASigningCert != null) && (certType.equals(mCASigningCert))) + enableFields(true,"casigning"); + else if ((mCASigningCert != null) && (mOCSPSigningCert != null) + && (certType.equals(mOCSPSigningCert))) + enableFields(true,"ocspsigning"); + else if ((mCASigningCert != null) && (mServerCert != null) + && (certType.equals(mServerCert))) + enableFields(true,"server"); + else if ((mCASigningCert != null) && (mServerCertRadm != null) + && (certType.equals(mServerCertRadm))) + enableFields(true,"server"); + else + enableFields(false,"other"); + } + + CMSAdminUtil.repaintComp(mCABtn); + CMSAdminUtil.repaintComp(mSubBtn); + CMSAdminUtil.repaintComp(mCALbl); + CMSAdminUtil.repaintComp(mCertType); + CMSAdminUtil.repaintComp(mCertTypeText); + return true; + } + + public boolean validatePanel() { + String str = (String)mCertBox.getSelectedItem(); + if (str.equals(mOtherCert)) { + if (mCertTypeText.getText().equals("")) { + setErrorMessage("BLANKCERTTYPE"); + return false; + } + } + return true; + } + + public boolean concludePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + NameValuePairs nvps = new NameValuePairs(); + AdminConnection connection = wizardInfo.getAdminConnection(); + startProgressStatus(); + String item = ((String)mCertBox.getSelectedItem()).trim(); + + if (mCASigningCert != null && item.equals(mCASigningCert.trim())) + wizardInfo.put(Constants.PR_CERTIFICATE_TYPE, + Constants.PR_CA_SIGNING_CERT); + else if (mRASigningCert != null && item.equals(mRASigningCert.trim())) + wizardInfo.put(Constants.PR_CERTIFICATE_TYPE, + Constants.PR_RA_SIGNING_CERT); + else if (mKRATransportCert != null && + item.equals(mKRATransportCert.trim())) + wizardInfo.put(Constants.PR_CERTIFICATE_TYPE, + Constants.PR_KRA_TRANSPORT_CERT); + else if (mServerCert != null && item.equals(mServerCert.trim())) + wizardInfo.put(Constants.PR_CERTIFICATE_TYPE, + Constants.PR_SERVER_CERT); + else if (mServerCertRadm != null && item.equals(mServerCertRadm.trim())) + wizardInfo.put(Constants.PR_CERTIFICATE_TYPE, + Constants.PR_SERVER_CERT_RADM); + else if (mOCSPSigningCert != null && item.equals(mOCSPSigningCert.trim())) + wizardInfo.put(Constants.PR_CERTIFICATE_TYPE, + Constants.PR_OCSP_SIGNING_CERT); + else if (mOtherCert != null && item.equals(mOtherCert.trim())) + wizardInfo.put(Constants.PR_CERTIFICATE_TYPE, + Constants.PR_OTHER_CERT); + + if (item.equals(mOtherCert.trim())) { + try { + NameValuePairs response = null; + + response = connection.read(DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_GET_NICKNAMES, wizardInfo.getCertType(), nvps); + String value = response.get(Constants.PR_ALL_NICKNAMES); + wizardInfo.setNicknames(value); + } catch (EAdminException e) { + 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); + +/* + JTextArea desc = createTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "CERTTYPEWIZARD_TEXT_HEADING_LABEL"), 80), 1, 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(desc, gbc); +*/ + JTextArea heading = createTextArea(mResource.getString( + PANELNAME+"_LABEL_HEADING_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(heading, gbc); + + JTextArea heading1 = createTextArea(mResource.getString( + PANELNAME+"_LABEL_HEADING1_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(heading1, gbc); + + mCertBox = new JComboBox(); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + add(mCertBox, gbc); + mCertBox.addItemListener(this); + + JLabel dummy = new JLabel(" "); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.gridwidth = gbc.REMAINDER; + add(dummy, gbc); + + mCertType = createTextArea(mResource.getString( + PANELNAME+"_LABEL_CERTTYPE_LABEL")); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mCertType, gbc); + +/* + JLabel dummy1 = new JLabel(" "); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.gridwidth = gbc.REMAINDER; + add(dummy1, gbc); +*/ + + mCertTypeText = makeJTextField(10); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.insets = new Insets(COMPONENT_SPACE, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + add(mCertTypeText, gbc); + mActiveColor = mCertTypeText.getBackground(); + + JLabel dummy2 = new JLabel(" "); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.gridwidth = gbc.REMAINDER; + add(dummy2, gbc); + + mCALbl = createTextArea(mResource.getString( + "CERTTYPEWIZARD_TEXT_CATYPE_LABEL")); +/* + mCALbl = makeJLabel("CATYPE"); +*/ + CMSAdminUtil.resetGBC(gbc); + gbc.insets = new Insets(2*COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.anchor = gbc.NORTHWEST; + gbc.gridwidth = gbc.REMAINDER; + gbc.weightx = 1.0; + add(mCALbl, gbc); + + mCABtn = makeJRadioButton("SELFSIGN", true); + 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(mCABtn, gbc); + + mSubBtn = makeJRadioButton("SUBORDINATE", false); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(0,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mSubBtn, gbc); + + ButtonGroup caGroup = new ButtonGroup(); + caGroup.add(mCABtn); + caGroup.add(mSubBtn); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + String str = (String)mCertBox.getSelectedItem(); + + /* + if ((mCASigningCert == null) || (!str.equals(mCASigningCert))) { + wizardInfo.addEntry(wizardInfo.CA_TYPE, wizardInfo.SUBORDINATE_CA); + return; + } + */ + + if ((mCASigningCert != null) && (str.equals(mCASigningCert))) { + if (mCABtn.isSelected()) { + wizardInfo.addEntry(wizardInfo.CA_TYPE, wizardInfo.SELF_SIGNED); + } else if (mSubBtn.isSelected()) { + wizardInfo.addEntry(wizardInfo.CA_TYPE, + wizardInfo.SUBORDINATE_CA); + } + } else if ((mCASigningCert != null) && (mServerCert != null) + && (str.equals(mServerCert))) { + wizardInfo.addEntry(wizardInfo.CA_TYPE, wizardInfo.SUBORDINATE_CA); + if (mCABtn.isSelected()) + wizardInfo.setSSLCertLocalCA(Constants.TRUE); + else if (mSubBtn.isSelected()) + wizardInfo.setSSLCertLocalCA(Constants.FALSE); + } else if ((mCASigningCert != null) && (mServerCertRadm != null) + && (str.equals(mServerCertRadm))) { + wizardInfo.addEntry(wizardInfo.CA_TYPE, wizardInfo.SUBORDINATE_CA); + if (mCABtn.isSelected()) + wizardInfo.setSSLCertLocalCA(Constants.TRUE); + else if (mSubBtn.isSelected()) + wizardInfo.setSSLCertLocalCA(Constants.FALSE); + } else if ((mCASigningCert != null) && (mOCSPSigningCert != null) + && (str.equals(mOCSPSigningCert))) { + wizardInfo.addEntry(wizardInfo.CA_TYPE, wizardInfo.SUBORDINATE_CA); + if (mCABtn.isSelected()) + wizardInfo.setSSLCertLocalCA(Constants.TRUE); + else if (mSubBtn.isSelected()) + wizardInfo.setSSLCertLocalCA(Constants.FALSE); + } else if (mOtherCert != null && str.equals(mOtherCert)) { + wizardInfo.addEntry(wizardInfo.CA_TYPE, wizardInfo.SUBORDINATE_CA); + wizardInfo.setCertSubType(mCertTypeText.getText()); + } else { + wizardInfo.addEntry(wizardInfo.CA_TYPE, wizardInfo.SUBORDINATE_CA); + } + } + + public void itemStateChanged(ItemEvent e) { + if (e.getSource().equals(mCertBox)) { + String str = (String)mCertBox.getSelectedItem(); + if (str == null) + return; + + if (str.equals(mOtherCert)) { + mCABtn.setEnabled(false); + mSubBtn.setEnabled(false); + mCALbl.setEnabled(false); + mCertType.setEnabled(true); + mCertTypeText.setEnabled(true); + mCertTypeText.setBackground(mActiveColor); + } else { + mCABtn.setEnabled(true); + mSubBtn.setEnabled(true); + mCALbl.setEnabled(true); + mCertType.setEnabled(false); + mCertTypeText.setEnabled(false); + mCertTypeText.setBackground(getBackground()); + if ((mCASigningCert != null) && (str.equals(mCASigningCert))) + enableFields(true,"casigning"); + else if ((mCASigningCert != null) && (mOCSPSigningCert != null) + && (str.equals(mOCSPSigningCert))) + enableFields(true,"ocspsigning"); + else if ((mCASigningCert != null) && (mServerCert != null) + && (str.equals(mServerCert))) + enableFields(true,"server"); + else if ((mCASigningCert != null) && (mServerCertRadm != null) + && (str.equals(mServerCertRadm))) + enableFields(true,"server"); + else + enableFields(false,"other"); + } + CMSAdminUtil.repaintComp(mCertType); + CMSAdminUtil.repaintComp(mCertTypeText); + } + } + + private void enableFields(boolean enable,String type) { + String label = null; + String b1 = null; + String b2 = null; + if (type.equals("casigning")) { + label = + mResource.getString("CERTTYPEWIZARD_TEXT_CATYPE_LABEL"); + b1 = + mResource.getString("CERTTYPEWIZARD_RADIOBUTTON_SELFSIGN_LABEL"); + b2 = + mResource.getString("CERTTYPEWIZARD_RADIOBUTTON_SUBORDINATE_LABEL"); + } else if (type.equals("server")) { + label = + mResource.getString("CERTTYPEWIZARD_TEXT_SERVERTYPE_LABEL"); + b1 = + mResource.getString("CERTTYPEWIZARD_RADIOBUTTON_SERVER_SELFSIGN_LABEL"); + b2 = + mResource.getString("CERTTYPEWIZARD_RADIOBUTTON_SERVER_SUBORDINATE_LABEL"); + } else if (type.equals("ocspsigning")) { + label = + mResource.getString("CERTTYPEWIZARD_TEXT_OCSPTYPE_LABEL"); + b1 = + mResource.getString("CERTTYPEWIZARD_RADIOBUTTON_SELFSIGNOCSP_LABEL"); + b2 = + mResource.getString("CERTTYPEWIZARD_RADIOBUTTON_SUBORDINATEOCSP_LABEL"); + } + + mCALbl.setEnabled(enable); + mCALbl.invalidate(); + mCALbl.validate(); + if (label != null) mCALbl.setText(label); + mCALbl.repaint(1); + mCABtn.setEnabled(enable); + mCABtn.invalidate(); + mCABtn.validate(); + if (b1 != null) mCABtn.setText(b1); + mCABtn.repaint(1); + mSubBtn.setEnabled(enable); + mSubBtn.invalidate(); + mSubBtn.validate(); + if (b2 != null) mSubBtn.setText(b2); + mSubBtn.repaint(1); + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WCertValidityPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WCertValidityPage.java new file mode 100644 index 000000000..8567703d4 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WCertValidityPage.java @@ -0,0 +1,139 @@ +// --- 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 WCertValidityPage extends WBaseValidityPage implements IWizardPanel { + private static final String PANELNAME = "CERTVALIDWIZARD"; + private String mCertType = ""; + private static final String HELPINDEX = + "configuration-keycert-wizard-validityperiod-help"; + + WCertValidityPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WCertValidityPage(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) ) + return false; + if ((wizardInfo.getCAType().equals(wizardInfo.SUBORDINATE_CA)) + && !(wizardInfo.isSSLCertLocalCA())) + return false; + + String title = ""; + mCertType = wizardInfo.getCertType(); + if (mCertType.equals(Constants.PR_CA_SIGNING_CERT)) + title = mResource.getString("CERTVALIDWIZARD_BORDER_CASIGNING_LABEL"); + else if (mCertType.equals(Constants.PR_OCSP_SIGNING_CERT)) + title = mResource.getString("CERTVALIDWIZARD_BORDER_OCSPSIGNING_LABEL"); + else if (mCertType.equals(Constants.PR_RA_SIGNING_CERT)) + title = mResource.getString("CERTVALIDWIZARD_BORDER_RASIGNING_LABEL"); + else if (mCertType.equals(Constants.PR_KRA_TRANSPORT_CERT)) + title = mResource.getString("CERTVALIDWIZARD_BORDER_KRATRANSPORT_LABEL"); + else if (mCertType.equals(Constants.PR_SERVER_CERT) || + mCertType.equals(Constants.PR_SERVER_CERT_RADM)) + title = mResource.getString("CERTVALIDWIZARD_BORDER_SERVER_LABEL"); + setBorder(new TitledBorder(title)); + + return true; + } + + public boolean validatePanel() { + boolean status = super.validatePanel(); + if (status && !mWarningDisplayed) { + Date currTime = new Date(); + if (currTime.before(mBeforeDate)) { + if (mCertType.equals(Constants.PR_CA_SIGNING_CERT)) + setErrorMessage("INVALIDCACERT"); + else if (mCertType.equals(Constants.PR_OCSP_SIGNING_CERT)) + setErrorMessage("INVALIDOCSPCERT"); + else if (mCertType.equals(Constants.PR_RA_SIGNING_CERT)) + setErrorMessage("INVALIDRACERT"); + else if (mCertType.equals(Constants.PR_KRA_TRANSPORT_CERT)) + setErrorMessage("INVALIDKRACERT"); + else if (mCertType.equals(Constants.PR_SERVER_CERT)) + setErrorMessage("INVALIDSSLCERT"); + mWarningDisplayed = true; + return false; + } + } + return status; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + protected void init() { + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + wizardInfo.addEntry(Constants.PR_BEGIN_YEAR, mBYear.getText().trim()); + int beforeMonth = Integer.parseInt(mBMonth.getText().trim()); + wizardInfo.addEntry(Constants.PR_BEGIN_MONTH, ""+(beforeMonth-1)); + wizardInfo.addEntry(Constants.PR_BEGIN_DATE, mBDay.getText().trim()); + wizardInfo.addEntry(Constants.PR_BEGIN_HOUR, mBHour.getText().trim()); + wizardInfo.addEntry(Constants.PR_BEGIN_MIN, mBMin.getText().trim()); + wizardInfo.addEntry(Constants.PR_BEGIN_SEC, mBSec.getText().trim()); + wizardInfo.addEntry(Constants.PR_AFTER_YEAR, mEYear.getText().trim()); + int afterMonth = Integer.parseInt(mEMonth.getText().trim()); + wizardInfo.addEntry(Constants.PR_AFTER_MONTH, ""+(afterMonth-1)); + wizardInfo.addEntry(Constants.PR_AFTER_DATE, mEDay.getText().trim()); + wizardInfo.addEntry(Constants.PR_AFTER_HOUR, mEHour.getText().trim()); + wizardInfo.addEntry(Constants.PR_AFTER_MIN, mEMin.getText().trim()); + wizardInfo.addEntry(Constants.PR_AFTER_SEC, mESec.getText().trim()); + //wizardInfo.addEntry(Constants.PR_VALIDITY_PERIOD, ""+period); + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WDisplayCertPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WDisplayCertPage.java new file mode 100644 index 000000000..a7fe56352 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WDisplayCertPage.java @@ -0,0 +1,258 @@ +// --- 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.util.*; +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.*; + +/** + * This page is to install the certificate in the internal token. It + * displays the certificate information. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.config.install + */ +class WDisplayCertPage extends WizardBasePanel implements IWizardPanel { + private CertSetupWizardInfo wizardInfo; + private JButton mAdd; + private boolean isAdd = false; + private static final String PANELNAME = "DISPLAYCERTWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-displaycert-help"; + private JTextArea mTextArea; + private JTextField mCertNameField; + private Color mActiveColor; + + WDisplayCertPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WDisplayCertPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mParent = parent; + mAdminFrame = frame; + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + wizardInfo = (CertSetupWizardInfo)info; + if (wizardInfo.getOperationType().equals(wizardInfo.REQUESTTYPE)) + return false; + + setBorder(makeTitledBorder(PANELNAME)); + mTextArea.setText(wizardInfo.getCertContent()); + if (wizardInfo.getInstallCertType().equals(Constants.PR_OTHER_CERT)) { + mCertNameField.setEditable(true); + mCertNameField.setBackground(mActiveColor); + mCertNameField.setEnabled(true); + } else { + mCertNameField.setEditable(false); + mCertNameField.setBackground(getBackground()); + mCertNameField.setEnabled(false); + } + + String certName = wizardInfo.getNickname(); + if (certName != null && !certName.equals("")) + mCertNameField.setText(certName); + + CMSAdminUtil.repaintComp(mCertNameField); + return true; + } + + public boolean validatePanel() { + if (mCertNameField.isEditable()) { + String str = mCertNameField.getText(); + if (str == null || str.length() == 0) { + setErrorMessage("EMPTYCERTNAME"); + return false; + } + } + return true; + } + + public boolean concludePanel(WizardInfo info) { + AdminConnection connection = wizardInfo.getAdminConnection(); + CMSServerInfo serverInfo = wizardInfo.getServerInfo(); + String certType = wizardInfo.getInstallCertType(); + String pathname = ""; + if (certType.equals(Constants.PR_CA_SIGNING_CERT)) { + pathname = "prevCACert.txt"; + } else if (certType.equals(Constants.PR_OCSP_SIGNING_CERT)) { + pathname = "prevOCSPCert.txt"; + } else if (certType.equals(Constants.PR_RA_SIGNING_CERT)) { + pathname = "prevRACert.txt"; + } else if (certType.equals(Constants.PR_KRA_TRANSPORT_CERT)) { + pathname = "prevKRACert.txt"; + } else if (certType.equals(Constants.PR_SERVER_CERT)) { + pathname = "prevSSLCert.txt"; + } else if (certType.equals(Constants.PR_SERVER_CERT_RADM)) { + pathname = "prevSSLCertRadm.txt"; + } else if (certType.equals(Constants.PR_CROSS_CERT)) { + pathname = "prevCROSSCert.txt"; + } else if (certType.equals(Constants.PR_OTHER_CERT)) { + pathname = "prevOTHERCert.txt"; + } + + NameValuePairs nvps = new NameValuePairs(); + String cert = wizardInfo.getPKCS10(); + + if (cert == null) { + nvps.put(Constants.PR_CERT_FILEPATH, + wizardInfo.getCertFilePath()); + } else { + nvps.put(Constants.PR_PKCS10, wizardInfo.getPKCS10()); + } + + nvps.put(Constants.PR_NICKNAME, mCertNameField.getText().trim()); + nvps.put("pathname", pathname); + nvps.put(Constants.PR_SERVER_ROOT, serverInfo.getServerRoot()); + nvps.put(Constants.PR_SERVER_ID, serverInfo.getServerId()); + + try { + connection.modify( + DestDef.DEST_SERVER_ADMIN, + (certType.equals(Constants.PR_CROSS_CERT))? + (ScopeDef.SC_IMPORT_CROSS_CERT):(ScopeDef.SC_INSTALL_CERT), + certType, nvps); + } catch (EAdminException ex) { + showErrorDialog(ex.toString()); + //setErrorMessage(ex.toString()); + wizardInfo.addEntry(Constants.PR_ADD_CERT, new Boolean(false)); + return false; + } + wizardInfo.addEntry(Constants.PR_ADD_CERT, new Boolean(true)); +/* + CMSAdminUtil.showMessageDialog(mResource, PANELNAME, + "INSTALL", JOptionPane.INFORMATION_MESSAGE); +*/ + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + CMSAdminUtil.resetGBC(gbc); + JLabel label1 = makeJLabel("NAME"); + gbc.fill = gbc.NONE; + gbc.anchor = gbc.WEST; + gbc.insets = new Insets(COMPONENT_SPACE, + COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE); + add(label1, gbc); + + CMSAdminUtil.resetGBC(gbc); + mCertNameField = new JTextField(30); + gbc.gridwidth = gbc.REMAINDER; + gbc.anchor = gbc.WEST; + gbc.weightx=1.0; + gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE, COMPONENT_SPACE); + add(mCertNameField, gbc); + mActiveColor = mCertNameField.getBackground(); + + mCertNameField.setEditable(false); + mCertNameField.setBackground(getBackground()); + mCertNameField.setEnabled(false); + + CMSAdminUtil.resetGBC(gbc); + JLabel certLbl = makeJLabel("CONTENT"); + gbc.gridwidth = gbc.REMAINDER; + gbc.anchor = gbc.WEST; + gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE, COMPONENT_SPACE); + add(certLbl, gbc); + + CMSAdminUtil.resetGBC(gbc); + mTextArea = new JTextArea("",100,90); + Font f = new Font("Monospaced", Font.PLAIN, 12); + if (f != null) mTextArea.setFont(f); + mTextArea.setEditable(false); + mTextArea.setBackground(getBackground()); + JScrollPane scrollPanel = new JScrollPane(mTextArea, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPanel.setAlignmentX(LEFT_ALIGNMENT); + scrollPanel.setAlignmentY(TOP_ALIGNMENT); + scrollPanel.setBorder(BorderFactory.createLoweredBevelBorder()); + gbc.fill = gbc.BOTH; + gbc.gridwidth = gbc.REMAINDER; + gbc.gridheight = gbc.REMAINDER; + //gbc.gridheight = gbc.REMAINDER; + gbc.weightx=1.0; + gbc.weighty=1.0; + gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE); + add(scrollPanel, gbc); + +/* + mAdd = makeJButton("ADD"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHEAST; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(0, COMPONENT_SPACE, + COMPONENT_SPACE, COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + gbc.gridheight = gbc.REMAINDER; + add(mAdd, gbc); +*/ + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + Boolean bool = wizardInfo.isCertAdded(); + if (bool == null) + wizardInfo.addEntry(Constants.PR_ADD_CERT, new Boolean(false)); + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(mAdd)) { + + } + } + + private String[] parseStr(String dn) { + StringTokenizer tokenizer = new StringTokenizer(dn, ","); + int numTokens = tokenizer.countTokens(); + String[] results = new String[numTokens]; + int i=0; + while (tokenizer.hasMoreElements()) { + results[i] = (String)tokenizer.nextToken(); + i++; + } + return results; + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WExecute1Page.java b/base/console/src/com/netscape/admin/certsrv/keycert/WExecute1Page.java new file mode 100644 index 000000000..d13bca6e4 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WExecute1Page.java @@ -0,0 +1,158 @@ +// --- 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.border.*; +import com.netscape.admin.certsrv.*; +import com.netscape.admin.certsrv.connection.*; +import com.netscape.admin.certsrv.wizard.*; +import com.netscape.certsrv.common.*; + +/** + * Introduction page for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WExecute1Page extends WizardBasePanel implements IWizardPanel { + private static final String PANELNAME = "EXECUTE1WIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-certrequest-help"; + private JTextArea desc; + + WExecute1Page(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WExecute1Page(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) && +// !wizardInfo.isNewKey() && + wizardInfo.getCAType().equals(wizardInfo.SUBORDINATE_CA) && + !(wizardInfo.isSSLCertLocalCA())) { + + String title = ""; + String certType = wizardInfo.getCertType(); + if (certType.equals(Constants.PR_CA_SIGNING_CERT)) + title = mResource.getString("EXECUTE1WIZARD_BORDER_CASIGNING_LABEL"); + else if (certType.equals(Constants.PR_OCSP_SIGNING_CERT)) + title = mResource.getString("EXECUTE1WIZARD_BORDER_OCSPSIGNING_LABEL"); + else if (certType.equals(Constants.PR_RA_SIGNING_CERT)) + title = mResource.getString("EXECUTE1WIZARD_BORDER_RASIGNING_LABEL"); + else if (certType.equals(Constants.PR_KRA_TRANSPORT_CERT)) + title = mResource.getString("EXECUTE1WIZARD_BORDER_KRATRANSPORT_LABEL"); + else if (certType.equals(Constants.PR_SERVER_CERT) || + certType.equals(Constants.PR_SERVER_CERT_RADM)) + title = mResource.getString("EXECUTE1WIZARD_BORDER_SERVER_LABEL"); + else if (certType.equals(Constants.PR_OTHER_CERT)) + title = mResource.getString("EXECUTE1WIZARD_BORDER_OTHER_LABEL"); + setBorder(new TitledBorder(title)); + + String str = ""; + if (wizardInfo.isNewKey()) { + str = mResource.getString("EXECUTE1WIZARD_TEXT_NEWKEY_LABEL"); + } else { + str = mResource.getString("EXECUTE1WIZARD_TEXT_OLDKEY_LABEL"); + } + desc.setText(str); + return true; + } + + return false; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + startProgressStatus(); + AdminConnection connection = wizardInfo.getAdminConnection(); + NameValuePairs nvps = wizardInfo.getNameValuePairs(); + if (wizardInfo.getCertType().equals(Constants.PR_OTHER_CERT) && + !wizardInfo.isNewKey()) { + nvps.put(Constants.PR_NICKNAME, wizardInfo.getNickname()); + } + + try { + NameValuePairs response = connection.process( + DestDef.DEST_SERVER_ADMIN, ScopeDef.SC_CERT_REQUEST, + wizardInfo.getCertType(), nvps); + for (String key : response.keySet()) { + String value = response.get(key); + if (key.equals(Constants.PR_CSR)) { + wizardInfo.addEntry(Constants.PR_CSR, value); + } else if (key.equals(Constants.PR_CERT_REQUEST_DIR)) { + wizardInfo.addEntry(Constants.PR_CERT_REQUEST_DIR, value); + } + } + } catch (EAdminException e) { + 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); + + desc = createTextArea(""); + + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(desc, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WExecutePage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WExecutePage.java new file mode 100644 index 000000000..a3ce14257 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WExecutePage.java @@ -0,0 +1,158 @@ +// --- 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.*; + +/** + * Introduction page for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WExecutePage extends WizardBasePanel implements IWizardPanel { + private static final String PANELNAME = "EXECUTEWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-selfsignedcert-help"; + private JTextArea desc; + + WExecutePage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WExecutePage(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) && +// !wizardInfo.isNewKey() && + ((wizardInfo.getCertType().equals(Constants.PR_CA_SIGNING_CERT) && + wizardInfo.getCAType().equals(wizardInfo.SELF_SIGNED)) + || + (wizardInfo.getCertType().equals(Constants.PR_OCSP_SIGNING_CERT) && + wizardInfo.isSSLCertLocalCA()) + || + (wizardInfo.getCertType().equals(Constants.PR_SERVER_CERT) && + wizardInfo.isSSLCertLocalCA()) + || + (wizardInfo.getCertType().equals(Constants.PR_SERVER_CERT_RADM) && + wizardInfo.isSSLCertLocalCA()))) { + + setBorder(makeTitledBorder(PANELNAME)); + + if (wizardInfo.isNewKey()) { + String str = mResource.getString( + "EXECUTEWIZARD_TEXT_NEWKEY_LABEL"); + desc.setText(str); + } else { + String str = mResource.getString( + "EXECUTEWIZARD_TEXT_OLDKEY_LABEL"); + desc.setText(str); + } + return true; + } + + return false; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + startProgressStatus(); + AdminConnection connection = wizardInfo.getAdminConnection(); + CMSServerInfo serverInfo = wizardInfo.getServerInfo(); + + String dir = ""; + if (wizardInfo.getCertType().equals(Constants.PR_CA_SIGNING_CERT)) + dir = "prevCACert.txt"; + else if (wizardInfo.getCertType().equals(Constants.PR_OCSP_SIGNING_CERT)) + dir = "prevOCSPCert.txt"; + else if (wizardInfo.getCertType().equals(Constants.PR_SERVER_CERT)) + dir = "prevSSLCert.txt"; + else if (wizardInfo.getCertType().equals(Constants.PR_SERVER_CERT_RADM)) + dir = "prevSSLCertRadm.txt"; + + NameValuePairs nvps = wizardInfo.getNameValuePairs(); + + if (wizardInfo.isNewKey()) { + if (wizardInfo.getHashType() != null) + nvps.put(ConfigConstants.PR_HASH_TYPE, wizardInfo.getHashType()); + if (wizardInfo.getSignedByType() != null) + nvps.put(ConfigConstants.PR_SIGNEDBY_TYPE, wizardInfo.getSignedByType()); + } + + nvps.put("pathname", dir); + try { + connection.modify( + DestDef.DEST_SERVER_ADMIN, ScopeDef.SC_ISSUE_IMPORT_CERT, + wizardInfo.getCertType(), nvps); + } catch (EAdminException e) { + 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); + + desc = createTextArea(""); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(desc, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WGenerateReqPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WGenerateReqPage.java new file mode 100644 index 000000000..b2a0005b6 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WGenerateReqPage.java @@ -0,0 +1,92 @@ +// --- 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.*; +import com.netscape.certsrv.common.*; + +/** + * Generate Request page for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WGenerateReqPage extends WizardBasePanel implements IWizardPanel { + private static final String PANELNAME = "GENERATEREQWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WGenerateReqPage() { + 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; + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + JTextArea desc = new JTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "GENERATEREQWIZARD_TEXT_REQUEST_LABEL"), 80), 2, 80); + + desc.setBackground(getBackground()); + desc.setEditable(false); + desc.setCaretColor(getBackground()); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(desc, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WInstallCertChainPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WInstallCertChainPage.java new file mode 100644 index 000000000..0ea476b6a --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WInstallCertChainPage.java @@ -0,0 +1,141 @@ +// --- 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.connection.*; +import com.netscape.admin.certsrv.wizard.*; +import com.netscape.certsrv.common.*; + +/** + * This page allows the user to do such selections as the installation of + * certificates, server certificate chain, or trusted CA. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WInstallCertChainPage extends WizardBasePanel implements IWizardPanel { + private JComboBox mCertBox; + private String mTrustedCACert; + private String mTrustedCert, mOtherCert, mCrossCert; + private static final String PANELNAME = "INSTALLCERTCHAINWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-installcerttype-help"; + + WInstallCertChainPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WInstallCertChainPage(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)); + + String mode = wizardInfo.getMode(); + if (mode != null && mode.equals("0")) { + return true; + } + + return false; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + JTextArea introLbl = createTextArea(mResource.getString( + PANELNAME+"_LABEL_INTRO_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(introLbl, gbc); + + JTextArea opLbl = createTextArea(mResource.getString( + PANELNAME+"_LABEL_INSTALLCERT_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(opLbl, gbc); + + mCertBox = makeJComboBox("CERTCHAINTYPE"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.insets = new Insets(COMPONENT_SPACE, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.weighty = 1.0; + add(mCertBox, gbc); + + JTextArea dummy = createTextArea(" ", 1, 10); + CMSAdminUtil.resetGBC(gbc); + gbc.gridwidth = gbc.REMAINDER; + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 0, COMPONENT_SPACE,COMPONENT_SPACE); + add(dummy, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + String str = (String)(mCertBox.getSelectedItem()); + if (str.startsWith("Trusted")) { + wizardInfo.addEntry(wizardInfo.INSTALLCERTTYPE, Constants.PR_TRUSTED_CA_CERT); + } else if (str.startsWith("Untrusted")) { + wizardInfo.addEntry(wizardInfo.INSTALLCERTTYPE, Constants.PR_SERVER_CERT_CHAIN); + } + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WInstallOpPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WInstallOpPage.java new file mode 100644 index 000000000..5b4d2d340 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WInstallOpPage.java @@ -0,0 +1,221 @@ +// --- 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.connection.*; +import com.netscape.admin.certsrv.wizard.*; +import com.netscape.certsrv.common.*; + +/** + * This page allows the user to do such selections as the installation of + * certificates, server certificate chain, or trusted CA. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WInstallOpPage extends WizardBasePanel implements IWizardPanel { + private JComboBox mCertBox; + private String mCASigningCert; + private String mOCSPSigningCert; + private String mRASigningCert; + private String mKRATransportCert; + private String mServerCert, mServerCertRadm; + private String mOtherCert, mCrossCert; + private Vector mCerts; + private static final String PANELNAME = "INSTALLOPWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-installcerttype-help"; + + WInstallOpPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + mCerts = new Vector(); + init(); + } + + WInstallOpPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mParent = parent; + mCerts = new Vector(); + 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; + String mode = wizardInfo.getMode(); + if (mode != null && mode.equals("0")) + return false; + + setBorder(makeTitledBorder(PANELNAME)); + + if (wizardInfo.getInstallCertType() != null) { + return true; + } + + AdminConnection connection = wizardInfo.getAdminConnection(); + NameValuePairs nvps = new NameValuePairs(); + + try { + NameValuePairs response = connection.search(DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_SUBSYSTEM, nvps); + for (String name : response.keySet()) { + String type = response.get(name); + + if (type.equals(Constants.PR_RA_INSTANCE)) + mRASigningCert = mResource.getString( + PANELNAME+"_LABEL_RASIGNINGCERT_LABEL"); + else if (type.equals(Constants.PR_CA_INSTANCE)) + mCASigningCert = mResource.getString( + PANELNAME+"_LABEL_CASIGNINGCERT_LABEL"); + else if (type.equals(Constants.PR_KRA_INSTANCE)) + mKRATransportCert = mResource.getString( + PANELNAME+"_LABEL_KRATRANSPORTCERT_LABEL"); + } + } catch (EAdminException e) { + //showErrorDialog(e.toString()); + setErrorMessage(e.toString()); + } + + mOCSPSigningCert = mResource.getString( + PANELNAME+"_LABEL_OCSPSIGNINGCERT_LABEL"); + mServerCert = mResource.getString( + PANELNAME+"_LABEL_SERVERCERT_LABEL"); + mServerCertRadm = mResource.getString( + PANELNAME+"_LABEL_SERVERCERTRADM_LABEL"); + mCrossCert = mResource.getString( + PANELNAME+"_LABEL_CROSSCERT_LABEL"); + mOtherCert = mResource.getString( + PANELNAME+"_LABEL_OTHERCERT_LABEL"); + + mCertBox.removeAllItems(); + mCerts.removeAllElements(); + + if (mCASigningCert != null) { + mCertBox.addItem(mCASigningCert); + mCerts.addElement(Constants.PR_CA_SIGNING_CERT); + } + if (mOCSPSigningCert != null) { + mCertBox.addItem(mOCSPSigningCert); + mCerts.addElement(Constants.PR_OCSP_SIGNING_CERT); + } + if (mRASigningCert != null) { + mCertBox.addItem(mRASigningCert); + mCerts.addElement(Constants.PR_RA_SIGNING_CERT); + } + if (mKRATransportCert != null) { + mCertBox.addItem(mKRATransportCert); + mCerts.addElement(Constants.PR_KRA_TRANSPORT_CERT); + } + if (mServerCert != null) { + mCertBox.addItem(mServerCert); + mCerts.addElement(Constants.PR_SERVER_CERT); + } + + if (mCrossCert != null) { + mCertBox.addItem(mCrossCert); + mCerts.addElement(Constants.PR_CROSS_CERT); + } + + if (mOtherCert != null) { + mCertBox.addItem(mOtherCert); + mCerts.addElement(Constants.PR_OTHER_CERT); + } + + // that means the wizard is launched from the task page + if (mode == null) { + mCertBox.addItem("Untrusted CA Certificate Chain"); + mCertBox.addItem("Trusted CA Certificate Chain"); + } + + mCertBox.setSelectedIndex(0); + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + JTextArea introLbl = createTextArea(mResource.getString( + PANELNAME+"_LABEL_INTRO_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(introLbl, gbc); + + JTextArea opLbl = createTextArea(mResource.getString( + PANELNAME+"_LABEL_INSTALLCERT_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(opLbl, gbc); + + mCertBox = makeJComboBox("CERTTYPE"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.insets = new Insets(COMPONENT_SPACE, 4*COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.weighty = 1.0; + add(mCertBox, gbc); + + JTextArea dummy = createTextArea(" ", 1, 10); + CMSAdminUtil.resetGBC(gbc); + gbc.gridwidth = gbc.REMAINDER; + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(0, 0, COMPONENT_SPACE,COMPONENT_SPACE); + add(dummy, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + int index = mCertBox.getSelectedIndex(); + wizardInfo.addEntry(wizardInfo.INSTALLCERTTYPE, mCerts.elementAt(index)); + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WInstallStatusPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WInstallStatusPage.java new file mode 100644 index 000000000..25022bbb9 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WInstallStatusPage.java @@ -0,0 +1,105 @@ +// --- 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.*; + +/** + * Introduction page for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WInstallStatusPage extends WizardBasePanel implements IWizardPanel { + private JTextArea mDesc; + private static final String PANELNAME = "INSTALLSTATUSWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-installcertstatus-help"; + + WInstallStatusPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WInstallStatusPage(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; + if (wizardInfo.isCertAdded().booleanValue()) + mDesc.setText(mResource.getString( + "INSTALLSTATUSWIZARD_TEXT_SUCCESS_LABEL")); + else + mDesc.setText(mResource.getString( + "INSTALLSTATUSWIZARD_TEXT_FAIL_LABEL")); + + setBorder(makeTitledBorder(PANELNAME)); + + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + mDesc = createTextArea(""); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mDesc, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WIntroInstallCertPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WIntroInstallCertPage.java new file mode 100644 index 000000000..18c6ef068 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WIntroInstallCertPage.java @@ -0,0 +1,93 @@ +// --- 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.*; + +/** + * Introduction page for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WIntroInstallCertPage extends WizardBasePanel implements IWizardPanel { + private static final String PANELNAME = "INTROINSTALLCERTWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WIntroInstallCertPage() { + super(PANELNAME); + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + if (wizardInfo.getOperationType().equals(wizardInfo.REQUESTTYPE)) + return false; + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + JTextArea desc = new JTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "INTROINSTALLCERTWIZARD_TEXT_DESC_LABEL"), 80), 2, 80); + + desc.setBackground(getBackground()); + desc.setEditable(false); + desc.setCaretColor(getBackground()); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(desc, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WIntroPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WIntroPage.java new file mode 100644 index 000000000..abcec63f3 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WIntroPage.java @@ -0,0 +1,120 @@ +// --- 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.*; + +/** + * Introduction page for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WIntroPage extends WizardBasePanel implements IWizardPanel { + private static final String PANELNAME = "INTROKEYCERTWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-introduction-help"; + + WIntroPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WIntroPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mParent = parent; + mAdminFrame = frame; + init(); + } + + public boolean initializePanel(WizardInfo info) { + setBorder(makeTitledBorder(PANELNAME)); + return true; + } + + public boolean isLastPage() { + return false; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + startProgressStatus(); + AdminConnection connection = wizardInfo.getAdminConnection(); + NameValuePairs nvps = new NameValuePairs(); + nvps.put(Constants.PR_TOKEN_LIST, ""); + try { + NameValuePairs response = connection.read(DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_TOKEN, Constants.RS_ID_CONFIG, nvps); + for (String name : response.keySet()) { + String value = response.get(name); + if (name.equals(Constants.PR_TOKEN_LIST)) + wizardInfo.addEntry(name, value); + } + } 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); + +/* + JTextArea desc = new JTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "INTROKEYCERTWIZARD_TEXT_DESC_LABEL"), 80), 2, 80); +*/ + JTextArea desc = createTextArea(mResource.getString( + "INTROKEYCERTWIZARD_TEXT_DESC_LABEL")); + + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(desc, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WIssueImportStatusPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WIssueImportStatusPage.java new file mode 100644 index 000000000..65e02ddd7 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WIssueImportStatusPage.java @@ -0,0 +1,105 @@ +// --- 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.*; + +/** + * Introduction page for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WIssueImportStatusPage extends WizardBasePanel implements IWizardPanel { + private static final String PANELNAME = "ISSUEIMPORTSTATUSWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-selfsignedstatus-help"; + private JTextArea desc; + + WIssueImportStatusPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WIssueImportStatusPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mParent = parent; + mAdminFrame = frame; + init(); + } + + public boolean initializePanel(WizardInfo info) { + setBorder(makeTitledBorder(PANELNAME)); + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + String str = ""; + + if (wizardInfo.getOperationType().equals(wizardInfo.REQUESTTYPE) && + (wizardInfo.getCAType().equals(wizardInfo.SELF_SIGNED) || + wizardInfo.isSSLCertLocalCA())) { + str = mResource.getString( + "ISSUEIMPORTSTATUSWIZARD_TEXT_DESC_LABEL"); + desc.setText(str); + return true; + } + return false; + } + + public boolean isLastPage() { + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + desc = createTextArea(""); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(desc, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WKeyPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WKeyPage.java new file mode 100644 index 000000000..40d601c1d --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WKeyPage.java @@ -0,0 +1,809 @@ +// --- 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.util.*; +import javax.swing.*; +import javax.swing.border.*; + +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 javax.swing.text.*; + +/** + * Setup key information for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.config.install + */ +class WKeyPage extends WizardBasePanel implements IWizardPanel, ItemListener { + private Color mActiveColor; + private JPanel mNicknamePanel; + private JRadioButton mExistingKeyBtn; + private JRadioButton mNewKeyBtn; + private JComboBox mKeyTypeBox, mDSAKeyTypeBox; + private JComboBox mKeyLengthBox, mDSAKeyLengthBox, mKeyCurveBox; + private JComboBox mTokenBox, mNicknameBox; + private JTextField mKeyLengthText; + private JTextField mKeyCurveText; + private JLabel keyHeading, keyTypeLbl, keyLengthLbl, keyCurveLbl, unitLbl, + unit1Lbl, mTokenLbl, mNicknameLbl; + private JLabel keyLengthCustomText, keyCurveCustomText; + private static final String PANELNAME = "KEYWIZARD"; + private CertSetupWizardInfo wizardInfo; + private static final String HELPINDEX = + "configuration-keycert-wizard-key-help"; + + WKeyPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WKeyPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mParent = parent; + mAdminFrame = frame; + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + wizardInfo = (CertSetupWizardInfo)info; + if (wizardInfo.getOperationType().equals(wizardInfo.INSTALLTYPE)) + return false; + + String title = ""; + String certType = wizardInfo.getCertType(); + if (certType.equals(Constants.PR_CA_SIGNING_CERT)) + title = mResource.getString("KEYWIZARD_BORDER_CASIGNING_LABEL"); + else if (certType.equals(Constants.PR_RA_SIGNING_CERT)) + title = mResource.getString("KEYWIZARD_BORDER_RASIGNING_LABEL"); + else if (certType.equals(Constants.PR_KRA_TRANSPORT_CERT)) + title = mResource.getString("KEYWIZARD_BORDER_KRATRANSPORT_LABEL"); + else if (certType.equals(Constants.PR_OCSP_SIGNING_CERT)) + title = mResource.getString("KEYWIZARD_BORDER_OCSPSIGNING_LABEL"); + else if (certType.equals(Constants.PR_SERVER_CERT) || + certType.equals(Constants.PR_SERVER_CERT_RADM)) + title = mResource.getString("KEYWIZARD_BORDER_SERVER_LABEL"); + else if (certType.equals(Constants.PR_OTHER_CERT)) + title = mResource.getString("KEYWIZARD_BORDER_OTHER_LABEL"); + + setBorder(new TitledBorder(title)); + if (certType.equals(Constants.PR_OTHER_CERT)) { + mNicknamePanel.setVisible(true); + mNicknameLbl.setVisible(true); + mNicknameBox.setVisible(true); + if (mNicknameBox.getItemCount() <= 0) { + String str = wizardInfo.getNicknames(); + StringTokenizer tokenizer1 = new StringTokenizer(str, ","); + while (tokenizer1.hasMoreTokens()) { + mNicknameBox.addItem((String)tokenizer1.nextToken()); + } + } + } else { + mNicknamePanel.setVisible(false); + mNicknameLbl.setVisible(false); + mNicknameBox.setVisible(false); + } + + if (mTokenBox.getItemCount() > 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.put(Constants.PR_KEY_CURVENAME, mKeyCurveText.getText().trim()); + } else { + wizardInfo.addEntry(Constants.PR_KEY_LENGTH, + mKeyLengthText.getText().trim()); + nvps.put(Constants.PR_KEY_LENGTH, mKeyLengthText.getText().trim()); + } + } else { + if (mKeyCurveBox.isVisible()) { // ECC + wizardInfo.addEntry(Constants.PR_KEY_CURVENAME, val.trim()); + nvps.put(Constants.PR_KEY_CURVENAME, val.trim()); + } else { + wizardInfo.addEntry(Constants.PR_KEY_LENGTH, val.trim()); + nvps.put(Constants.PR_KEY_LENGTH, val.trim()); + } + } + + if (mKeyTypeBox.isVisible()) { + wizardInfo.addEntry(Constants.PR_KEY_TYPE, + (String)mKeyTypeBox.getSelectedItem()); + nvps.put(Constants.PR_KEY_TYPE, (String) mKeyTypeBox.getSelectedItem()); + } else if (mDSAKeyTypeBox.isVisible()) { + wizardInfo.addEntry(Constants.PR_KEY_TYPE, + (String)mDSAKeyTypeBox.getSelectedItem()); + nvps.put(Constants.PR_KEY_TYPE, (String) mDSAKeyTypeBox.getSelectedItem()); + } + } + + startProgressStatus(); + + String certType = wizardInfo.getCertType(); + nvps.put(Constants.PR_SUBJECT_NAME, ""); + nvps.put(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.put(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); + } + + String value = response.get(Constants.PR_SUBJECT_NAME); + wizardInfo.addEntry(Constants.PR_SUBJECT_NAME, value); + } + + if (mNewKeyBtn.isSelected()) { + String tokenName = (String)mTokenBox.getSelectedItem(); + if (tokenName.equals("internal")) + tokenName = Constants.PR_INTERNAL_TOKEN_NAME; + nvps.clear(); + nvps.put(Constants.PR_TOKEN_NAME, tokenName); + response = connection.process(DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_TOKEN_STATUS, Constants.RS_ID_CONFIG, nvps); + + String value = response.get(Constants.PR_LOGGED_IN); + wizardInfo.addEntry(Constants.PR_LOGGED_IN, value); + 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/base/console/src/com/netscape/admin/certsrv/keycert/WManualCertRequestPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WManualCertRequestPage.java new file mode 100644 index 000000000..4ad069133 --- /dev/null +++ b/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/base/console/src/com/netscape/admin/certsrv/keycert/WOperationSelectionPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WOperationSelectionPage.java new file mode 100644 index 000000000..f2cdeff3d --- /dev/null +++ b/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/base/console/src/com/netscape/admin/certsrv/keycert/WOtherCertRequest1Page.java b/base/console/src/com/netscape/admin/certsrv/keycert/WOtherCertRequest1Page.java new file mode 100644 index 000000000..1dbd614d1 --- /dev/null +++ b/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/base/console/src/com/netscape/admin/certsrv/keycert/WPasteCertPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WPasteCertPage.java new file mode 100644 index 000000000..50e14a50e --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WPasteCertPage.java @@ -0,0 +1,261 @@ +// --- 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 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.put(Constants.PR_CERT_FILEPATH, mCertFilePath); + wizardInfo.setCertFilePath(mCertFilePath); + wizardInfo.setPKCS10(""); + } else if (mBase64Btn.isSelected()) { + nvps.put(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 (String name : response.keySet()) { + String str = response.get(name); + wizardInfo.addEntry(name, str); + } +/* + for (int i=0; i<response.size(); i++) { + NameValuePair nvp = response.elementAt(i); + String name = nvp.getName(); + String str = nvp.getValue(); + wizardInfo.addEntry(name, str); + } +*/ + } 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); + + introLbl = createTextArea(mResource.getString( + PANELNAME+"_LABEL_INTRO_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(introLbl, gbc); + + mFileBtn = makeJRadioButton("FILE", 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(mFileBtn, gbc); + + mFileText = makeJTextField(50); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.gridwidth = gbc.REMAINDER; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, COMPONENT_SPACE, 0); + add(mFileText, gbc); + mActiveColor = mFileText.getBackground(); + + mBase64Btn = makeJRadioButton("BASE64", false); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE,0, + COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mBase64Btn, gbc); + + JTextArea desc = createTextArea(mResource.getString( + "PASTECERTWIZARD_TEXT_DESC_LABEL")); + + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 0.0; + gbc.insets = new Insets(COMPONENT_SPACE,4*COMPONENT_SPACE,0, + COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(desc, gbc); + + mBase64Text = new JTextArea(null, null, 0, 0); + Font f = new Font("Monospaced", Font.PLAIN, 12); + if (f != null) mBase64Text.setFont(f); + JScrollPane scrollPane = new JScrollPane(mBase64Text, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPane.setPreferredSize(new Dimension(50, 20)); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE, 4*COMPONENT_SPACE, 0, + COMPONENT_SPACE); + gbc.fill = gbc.BOTH; + gbc.gridwidth = gbc.REMAINDER; + add(scrollPane, gbc); + + mPaste = makeJButton("PASTE"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHEAST; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE,0, + COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mPaste, gbc); + + JLabel dummy = new JLabel(" "); + gbc.gridwidth = gbc.REMAINDER; + gbc.anchor = gbc.NORTHWEST; + gbc.weighty = 1.0; + gbc.fill = gbc.BOTH; + add(dummy, gbc); + + ButtonGroup buttonGrp = new ButtonGroup(); + buttonGrp.add(mFileBtn); + buttonGrp.add(mBase64Btn); + + enableFields(mFileText, true, mActiveColor); + enableFields(mBase64Text, false, getBackground()); + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(mPaste)) { + mBase64Text.paste(); + } else if (e.getSource().equals(mFileBtn)) { + enableFields(mFileText, true, mActiveColor); + enableFields(mBase64Text, false, getBackground()); + } else if (e.getSource().equals(mBase64Btn)) { + enableFields(mFileText, false, getBackground()); + enableFields(mBase64Text, true, mActiveColor); + } + } + + private void enableFields(JTextComponent comp1, boolean enable, Color color) { + comp1.setEnabled(enable); + comp1.setEditable(enable); + comp1.setBackground(color); + CMSAdminUtil.repaintComp(comp1); + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WRAKeyPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WRAKeyPage.java new file mode 100644 index 000000000..616deb74f --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WRAKeyPage.java @@ -0,0 +1,72 @@ +// --- 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 WRAKeyPage extends WBaseKeyPage implements IWizardPanel { + private static final String PANELNAME = "RAKEYWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WRAKeyPage() { + super(PANELNAME); + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WRequestStatusPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WRequestStatusPage.java new file mode 100644 index 000000000..a52def44a --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WRequestStatusPage.java @@ -0,0 +1,142 @@ +// --- 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.admin.certsrv.config.install.*; + +/** + * Request status page for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WRequestStatusPage extends WizardBasePanel implements IWizardPanel { + private static final String PANELNAME = "REQUESTSTATUSWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-certrequeststatus-help"; + protected JTextArea mDesc; + + protected String mRequestId; + + WRequestStatusPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WRequestStatusPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mParent = parent; + mAdminFrame = frame; + init(); + } + + public boolean initializePanel(WizardInfo info) { + setBorder(makeTitledBorder(PANELNAME)); + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + + if (!wizardInfo.requestSent()) { + String str = ""; + if (wizardInfo.getOperationType().equals(wizardInfo.REQUESTTYPE) && + (!wizardInfo.getCAType().equals(wizardInfo.SELF_SIGNED))) { + str = mResource.getString( + "REQUESTSTATUSWIZARD_TEXT_REQUEST_LABEL"); + mDesc.setText(str); + return true; + } + return false; + } else { + String status = wizardInfo.getRequestStatus(); + String str = wizardInfo.getRequestID(); + String error = wizardInfo.getRequestError(); + + if (str != null && !str.equals("")) { + if (status != null && status.equals("5")) { + // rejected + mDesc.setText(mResource.getString("REQUESTRESULTWIZARD_TEXT_REJECT_LABEL") + error + "\n\n"+ mResource.getString("REQUESTRESULTWIZARD_TEXT_ID_LABEL") + str + mResource.getString("REQUESTRESULTWIZARD_TEXT_REJECTEND_LABEL")); + } else { + // success + mDesc.setText(mResource.getString("REQUESTRESULTWIZARD_TEXT_DESC_LABEL") + + mResource.getString("REQUESTRESULTWIZARD_TEXT_ID_LABEL") + str + + mResource.getString("REQUESTRESULTWIZARD_TEXT_END_LABEL")); + } + } + else if (error != null) + mDesc.setText(error); + else + mDesc.setText(mResource.getString("REQUESTRESULTWIZARD_TEXT_DESC_LABEL") + + mResource.getString("REQUESTRESULTWIZARD_TEXT_NOID_LABEL")); + } + return true; + } + + public boolean isLastPage() { + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + mDesc = createTextArea(" "); + //mDesc = createTextArea("request id"); + CMSAdminUtil.resetGBC(gbc); + 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(mDesc, gbc); + + JLabel label = new JLabel(" "); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.WEST; + gbc.gridwidth = gbc.REMAINDER; + gbc.gridheight = gbc.REMAINDER; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE); + add(label, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WSSLKeyPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WSSLKeyPage.java new file mode 100644 index 000000000..7065f68b6 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WSSLKeyPage.java @@ -0,0 +1,72 @@ +// --- 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 WSSLKeyPage extends WBaseKeyPage implements IWizardPanel { + private static final String PANELNAME = "SSLKEYWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WSSLKeyPage() { + super(PANELNAME); + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WTokenLogonPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WTokenLogonPage.java new file mode 100644 index 000000000..53a623d0a --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WTokenLogonPage.java @@ -0,0 +1,178 @@ +// --- 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.*; + +/** + * This panel asks for the user to logon to the keycert token . + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WTokenLogonPage extends WizardBasePanel implements IWizardPanel { + protected JLabel mTokenNameText; + protected JPasswordField mPasswordText, mPasswordAgainText; + private static final String EMPTYSTR = " "; + protected JTextArea mDesc; + protected String mTokenName; + private static final String PANELNAME = "TOKENLOGONWIZARD"; + private static final String HELPINDEX = + "configuration-keycert-wizard-tokenlogon-help"; + + WTokenLogonPage(JDialog parent) { + super(PANELNAME); + mParent = parent; + init(); + } + + WTokenLogonPage(JDialog parent, JFrame frame) { + super(PANELNAME); + mParent = parent; + mAdminFrame = frame; + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + setBorder(makeTitledBorder(mPanelName)); + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + + if (!wizardInfo.isNewKey() || wizardInfo.isLoggedIn()) + return false; + + mDesc.setText(mResource.getString(mPanelName+"_TEXT_HEADING_LABEL")); + mTokenNameText.setText(wizardInfo.getTokenName()); + + return true; + } + + public boolean validatePanel() { + String passwd = mPasswordText.getText(); + if (passwd.equals("")) { + setErrorMessage("BLANKPASSWD"); + return false; + } + + return true; + } + + public boolean concludePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + AdminConnection connection = wizardInfo.getAdminConnection(); + String tokenname = mTokenNameText.getText().trim(); + + if (tokenname.equals("internal")) { + tokenname = Constants.PR_INTERNAL_TOKEN_NAME; + } + + String pwd = mPasswordText.getText().trim(); + startProgressStatus(); + + try { + NameValuePairs nvps = new NameValuePairs(); + nvps.put(Constants.PR_TOKEN_NAME, tokenname); + nvps.put(Constants.PR_TOKEN_PASSWD, pwd); + connection.modify(DestDef.DEST_SERVER_ADMIN, + ScopeDef.SC_TOKEN_LOGON, Constants.RS_ID_CONFIG, nvps); + } catch (EAdminException e) { + 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); + + CMSAdminUtil.resetGBC(gbc); + mDesc = createTextArea(""); + 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(mDesc, gbc); + + CMSAdminUtil.resetGBC(gbc); + JLabel tokenLabel = makeJLabel("TOKEN"); + gbc.anchor = gbc.NORTHEAST; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(0, 0, COMPONENT_SPACE, + COMPONENT_SPACE); + add(tokenLabel, gbc); + + CMSAdminUtil.resetGBC(gbc); + mTokenNameText = new JLabel(" "); + gbc.anchor = gbc.NORTHWEST; + //gbc.fill = gbc.NONE; + gbc.gridwidth = gbc.REMAINDER; + gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE); + add(mTokenNameText, gbc); + + CMSAdminUtil.resetGBC(gbc); + JLabel passwordLabel = makeJLabel("PWD"); + gbc.anchor = gbc.NORTHWEST; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE); + add(passwordLabel, gbc); + + CMSAdminUtil.resetGBC(gbc); + mPasswordText = makeJPasswordField(30); + gbc.anchor = gbc.NORTHWEST; + gbc.fill = gbc.NONE; + gbc.gridwidth = gbc.REMAINDER; + gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE); + add(mPasswordText, gbc); + + JLabel dummy = new JLabel(" "); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.gridwidth = gbc.REMAINDER; + gbc.gridheight = gbc.REMAINDER; + gbc.weighty = 1.0; + add(dummy, gbc); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WTokenSelectionPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WTokenSelectionPage.java new file mode 100644 index 000000000..b595e1ffd --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WTokenSelectionPage.java @@ -0,0 +1,158 @@ +// --- 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.*; + +/** + * Token Selection page for certificate setup wizard + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WTokenSelectionPage extends WizardBasePanel implements IWizardPanel { + private JRadioButton mInstallBtn; + private JRadioButton mRequestBtn; + private JComboBox mToken; + private static final String PANELNAME = "TOKENSELECTIONWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WTokenSelectionPage() { + super(PANELNAME); + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + String tokenList = (String)wizardInfo.getEntry(Constants.PR_TOKEN_LIST); + StringTokenizer tokenizer = new StringTokenizer(tokenList, ","); + while (tokenizer.hasMoreTokens()) { + mToken.addItem((String)tokenizer.nextToken()); + } + return true; + } + + public boolean validatePanel() { + return true; + } + + public boolean concludePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + info.addEntry(wizardInfo.TOKENNAME, (String)mToken.getSelectedItem()); + if (mRequestBtn.isSelected()) + info.addEntry(wizardInfo.OPTYPE, wizardInfo.REQUESTTYPE); + else + info.addEntry(wizardInfo.OPTYPE, wizardInfo.INSTALLTYPE); + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + CMSAdminUtil.resetGBC(gbc); + JLabel operationTypeLbl = makeJLabel("OPERATIONTYPE"); + 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); + + ButtonGroup btnGroup = new ButtonGroup(); + CMSAdminUtil.resetGBC(gbc); + mInstallBtn = makeJRadioButton("INSTALL", true); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 0.0; + gbc.insets = new Insets(COMPONENT_SPACE,4*COMPONENT_SPACE, + COMPONENT_SPACE, 0); + gbc.gridwidth = gbc.REMAINDER; + add(mInstallBtn, gbc); + + CMSAdminUtil.resetGBC(gbc); + mRequestBtn = makeJRadioButton("REQUEST", false); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 0.0; + gbc.insets = new Insets(0, 4*COMPONENT_SPACE, 2*COMPONENT_SPACE, + COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mRequestBtn, gbc); + + btnGroup.add(mInstallBtn); + btnGroup.add(mRequestBtn); + + CMSAdminUtil.resetGBC(gbc); + JLabel tokenTypeLbl = makeJLabel("TOKENSELECTION"); + 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(tokenTypeLbl, gbc); + + CMSAdminUtil.resetGBC(gbc); + JLabel tokenLbl = makeJLabel("TOKEN"); + gbc.anchor = gbc.NORTHEAST; + gbc.weighty = 0.0; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(COMPONENT_SPACE,4*COMPONENT_SPACE, COMPONENT_SPACE,0); + add(tokenLbl, gbc); + + mToken = new JComboBox(); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.fill = gbc.NONE; + gbc.weighty = 0.0; + gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + add(mToken, gbc); + + JTextArea dummy2 = createTextArea(" ", 1, 20); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.gridwidth = gbc.REMAINDER; + add(dummy2, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WWarningExecute1Page.java b/base/console/src/com/netscape/admin/certsrv/keycert/WWarningExecute1Page.java new file mode 100644 index 000000000..be844576c --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WWarningExecute1Page.java @@ -0,0 +1,161 @@ +// --- 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.*; + +/** + * Introduction page for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WWarningExecute1Page extends WizardBasePanel implements IWizardPanel { + private JButton mAgree; + private boolean mIsAgree = false; + private static final String PANELNAME = "WARNINGEXECUTE1WIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WWarningExecute1Page() { + super(PANELNAME); + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + if (wizardInfo.getOperationType().equals(wizardInfo.REQUESTTYPE) && + wizardInfo.isNewKey() && + wizardInfo.getCertType().equals(Constants.PR_CA_SIGNING_CERT) && + wizardInfo.getCAType().equals(wizardInfo.SUBORDINATE_CA)) + return true; + + return false; + } + + public boolean validatePanel() { + if (mIsAgree) + return true; + else { + setErrorMessage("PROCEED"); + return false; + } + } + + public boolean concludePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + AdminConnection connection = wizardInfo.getAdminConnection(); + NameValuePairs nvps = wizardInfo.getNameValuePairs(); + try { + NameValuePairs response = connection.process( + DestDef.DEST_SERVER_ADMIN, ScopeDef.SC_CERT_REQUEST, + wizardInfo.getCertType(), nvps); + for (String key : response.keySet()) { + String value = response.get(key); + if (key.equals(Constants.PR_CSR)) { + wizardInfo.addEntry(Constants.PR_CSR, value); + break; + } + } + } catch (EAdminException e) { + setErrorMessage(e.toString()); + return false; + } + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + Icon icon = CMSAdminUtil.getImage(CMSAdminResources.IMAGE_WARN_ICON); + + JLabel label = new JLabel(icon); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(label, gbc); + + JTextArea desc = new JTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "WARNINGEXECUTE1WIZARD_TEXT_DESC_LABEL"), 80), 3, 80); + + desc.setBackground(getBackground()); + desc.setEditable(false); + desc.setCaretColor(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(desc, gbc); + + JTextArea desc1 = new JTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "WARNINGEXECUTE1WIZARD_LABEL_WARNING_LABEL"), 60), 3, 60); + desc1.setBackground(getBackground()); + desc1.setEditable(false); + desc1.setCaretColor(getBackground()); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + add(desc1, gbc); + + mAgree = makeJButton("OK"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mAgree, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(mAgree)) { + mIsAgree = true; + } + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WWarningExecutePage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WWarningExecutePage.java new file mode 100644 index 000000000..a64f67188 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WWarningExecutePage.java @@ -0,0 +1,154 @@ +// --- 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.*; + +/** + * Introduction page for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WWarningExecutePage extends WizardBasePanel implements IWizardPanel { + private JButton mAgree; + private boolean mIsAgree = false; + private static final String PANELNAME = "WARNINGEXECUTEWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WWarningExecutePage() { + super(PANELNAME); + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + if (wizardInfo.getOperationType().equals(wizardInfo.REQUESTTYPE) && + wizardInfo.isNewKey() && + wizardInfo.getCertType().equals(Constants.PR_CA_SIGNING_CERT) && + wizardInfo.getCAType().equals(wizardInfo.SELF_SIGNED)) + return true; + + return false; + } + + public boolean validatePanel() { + if (mIsAgree) + return true; + else { + setErrorMessage("PROCEED"); + return false; + } + } + + public boolean concludePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + AdminConnection connection = wizardInfo.getAdminConnection(); + NameValuePairs nvps = wizardInfo.getNameValuePairs(); + try { + connection.modify( + DestDef.DEST_SERVER_ADMIN, ScopeDef.SC_ISSUE_IMPORT_CERT, + wizardInfo.getCertType(), nvps); + } catch (EAdminException e) { + setErrorMessage(e.toString()); + return false; + } + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + Icon icon = CMSAdminUtil.getImage(CMSAdminResources.IMAGE_WARN_ICON); + + JLabel label = new JLabel(icon); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(label, gbc); + + JTextArea desc = new JTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "WARNINGEXECUTEWIZARD_TEXT_DESC_LABEL"), 80), 3, 80); + + desc.setBackground(getBackground()); + desc.setEditable(false); + desc.setCaretColor(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(desc, gbc); + + JTextArea desc1 = new JTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "WARNINGEXECUTEWIZARD_LABEL_WARNING_LABEL"), 60), 3, 60); + desc1.setBackground(getBackground()); + desc1.setEditable(false); + desc1.setCaretColor(getBackground()); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + add(desc1, gbc); + + mAgree = makeJButton("OK"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mAgree, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(mAgree)) { + mIsAgree = true; + } + } +} diff --git a/base/console/src/com/netscape/admin/certsrv/keycert/WWarningPage.java b/base/console/src/com/netscape/admin/certsrv/keycert/WWarningPage.java new file mode 100644 index 000000000..7a4eabe57 --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/keycert/WWarningPage.java @@ -0,0 +1,143 @@ +// --- 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.*; + +/** + * Introduction page for certificate setup wizard. + * + * @author Christine Ho + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.keycert + */ +class WWarningPage extends WizardBasePanel implements IWizardPanel { + private JButton mAgree; + private boolean mIsAgree = false; + private static final String PANELNAME = "WARNINGWIZARD"; + private static final String HELPINDEX = + "configuration-kra-wizard-change-keyscheme-help"; + + WWarningPage() { + super(PANELNAME); + init(); + } + + public boolean isLastPage() { + return false; + } + + public boolean initializePanel(WizardInfo info) { + CertSetupWizardInfo wizardInfo = (CertSetupWizardInfo)info; + + if (wizardInfo.getOperationType().equals(wizardInfo.REQUESTTYPE) && + wizardInfo.isNewKey() && + wizardInfo.getCertType().equals(Constants.PR_CA_SIGNING_CERT)) + return true; + + return false; + } + + public boolean validatePanel() { + if (mIsAgree) + return true; + else { + setErrorMessage("PROCEED"); + return false; + } + } + + public boolean concludePanel(WizardInfo info) { + return true; + } + + public void callHelp() { + CMSAdminUtil.help(HELPINDEX); + } + + protected void init() { + GridBagLayout gb = new GridBagLayout(); + GridBagConstraints gbc = new GridBagConstraints(); + setLayout(gb); + + Icon icon = CMSAdminUtil.getImage(CMSAdminResources.IMAGE_WARN_ICON); + + JLabel label = new JLabel(icon); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.fill = gbc.NONE; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(label, gbc); + + JTextArea desc = new JTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "WARNINGWIZARD_TEXT_DESC_LABEL"), 80), 3, 80); + + desc.setBackground(getBackground()); + desc.setEditable(false); + desc.setCaretColor(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(desc, gbc); + + JTextArea desc1 = new JTextArea( + CMSAdminUtil.wrapText(mResource.getString( + "WARNINGWIZARD_LABEL_WARNING_LABEL"), 80), 1, 80); + desc1.setBackground(getBackground()); + desc1.setEditable(false); + desc1.setCaretColor(getBackground()); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + add(desc1, gbc); + + mAgree = makeJButton("OK"); + CMSAdminUtil.resetGBC(gbc); + gbc.anchor = gbc.NORTHWEST; + gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE, + COMPONENT_SPACE,COMPONENT_SPACE); + gbc.gridwidth = gbc.REMAINDER; + add(mAgree, gbc); + + super.init(); + } + + public void getUpdateInfo(WizardInfo info) { + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(mAgree)) { + mIsAgree = true; + } + } +} |