summaryrefslogtreecommitdiffstats
path: root/pki/base/console/src/com/netscape/admin/certsrv/managecert
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/console/src/com/netscape/admin/certsrv/managecert')
-rw-r--r--pki/base/console/src/com/netscape/admin/certsrv/managecert/CertificateInfoDialog.java354
-rw-r--r--pki/base/console/src/com/netscape/admin/certsrv/managecert/ManageCertDialog.java364
-rw-r--r--pki/base/console/src/com/netscape/admin/certsrv/managecert/ManageCertModel.java55
3 files changed, 773 insertions, 0 deletions
diff --git a/pki/base/console/src/com/netscape/admin/certsrv/managecert/CertificateInfoDialog.java b/pki/base/console/src/com/netscape/admin/certsrv/managecert/CertificateInfoDialog.java
new file mode 100644
index 000000000..fb3c78bbd
--- /dev/null
+++ b/pki/base/console/src/com/netscape/admin/certsrv/managecert/CertificateInfoDialog.java
@@ -0,0 +1,354 @@
+// --- 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.managecert;
+
+import com.netscape.admin.certsrv.*;
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.border.*;
+import java.awt.event.*;
+import java.awt.*;
+import java.util.*;
+import com.netscape.management.client.*;
+import com.netscape.management.client.util.*;
+import javax.swing.table.*;
+import com.netscape.admin.certsrv.connection.*;
+import com.netscape.certsrv.common.*;
+
+/**
+ * Certificate Information dialog
+ *
+ * @author Christine Ho
+ * @version $Revision$, $Date$
+ * @see com.netscape.admin.certsrv.managecert
+ */
+public class CertificateInfoDialog extends JDialog
+ implements ActionListener {
+ private String PREFIX = "CERTINFODIALOG";
+
+ private JFrame mParent;
+ private ResourceBundle mResource;
+ private JTextArea mTextArea;
+ private JLabel mCertNameField, mStatusLbl;
+ private JButton mClose, mHelp, mTrust;
+ private AdminConnection mConn;
+ private String mCertName;
+ private String mCertDate;
+ private JButton mActionBtn;
+ private static final String HELPINDEX =
+ "configuration-managecert-wizard-trustcert-help";
+
+ JLabel changeLbl = null;
+
+ public CertificateInfoDialog(JFrame parent) {
+ super(parent,true);
+ mParent = parent;
+ mResource = ResourceBundle.getBundle(CMSAdminResources.class.getName());
+ setSize(650, 400);
+ setTitle(mResource.getString(PREFIX+"_TITLE"));
+ setLocationRelativeTo(parent);
+ getRootPane().setDoubleBuffered(true);
+ setDisplay();
+ }
+
+ public void showDialog(String name, String content, String trust) {
+ mCertNameField.setText(name);
+ mTextArea.setText(content);
+ String actionStr = "";
+ String statusStr = "";
+ if (trust.equals("Trust")) {
+ //mTrust.setText(" Trust ");
+ actionStr = mResource.getString(PREFIX+"_BUTTON_UNTRUST_LABEL");
+ statusStr = mResource.getString(PREFIX+"_LABEL_TRUSTSTATUS_LABEL");
+ mActionBtn.setText(actionStr);
+ mStatusLbl.setText(statusStr);
+ } else if (trust.equals("Untrust")){
+ //mTrust.setText(trust);
+ actionStr = mResource.getString(PREFIX+"_BUTTON_TRUST_LABEL");
+ statusStr = mResource.getString(PREFIX+"_LABEL_UNTRUSTSTATUS_LABEL");
+ mActionBtn.setText(actionStr);
+ mStatusLbl.setText(statusStr);
+ } else { /* user certs can't be changed */
+ actionStr = mResource.getString(PREFIX+"_BUTTON_USER_LABEL");
+ statusStr = mResource.getString(PREFIX+"_LABEL_USER_LABEL");
+ mActionBtn.setText(actionStr);
+ mActionBtn.setEnabled(false);
+ mStatusLbl.setText(statusStr);
+ changeLbl.setEnabled(false);
+ }
+ this.show();
+ }
+
+ public void showDialog(String name, String content, String trust,
+ String date, AdminConnection conn) {
+ mConn = conn;
+ mCertName = name;
+ mCertDate = date;
+ showDialog(name, content, trust);
+ }
+
+ public void actionPerformed(ActionEvent evt) {
+ if (evt.getSource().equals(mClose)) {
+ this.hide();
+ this.dispose();
+ } else if (evt.getSource().equals(mActionBtn)) {
+ String trustLbl = mActionBtn.getText().trim();
+ String trustaction = mResource.getString(PREFIX+"_BUTTON_TRUST_LABEL");
+ String untrustaction = mResource.getString(PREFIX+"_BUTTON_UNTRUST_LABEL");
+ String trust = "";
+ if (trustLbl.equals(trustaction))
+ trust = "Trust";
+ else if (trustLbl.equals(untrustaction))
+ trust = "Untrust";
+ else // user certs not to be changable
+ return;
+
+ NameValuePairs nvps = new NameValuePairs();
+ String value = mCertName+";"+mCertDate;
+ nvps.add("certName0", value);
+
+ try {
+ mConn.modify(DestDef.DEST_SERVER_ADMIN, ScopeDef.SC_TRUST,
+ trust, nvps);
+ String actionStr = "";
+ String statusStr = "";
+ if (trust.equals("Trust")) {
+ actionStr = mResource.getString(PREFIX+"_BUTTON_UNTRUST_LABEL");
+ statusStr = mResource.getString(PREFIX+"_LABEL_TRUSTSTATUS_LABEL");
+ } else {
+ actionStr = mResource.getString(PREFIX+"_BUTTON_TRUST_LABEL");
+ statusStr = mResource.getString(PREFIX+"_LABEL_UNTRUSTSTATUS_LABEL");
+ }
+
+ mActionBtn.setText(actionStr);
+ mStatusLbl.setText(statusStr);
+ } catch (EAdminException ex) {
+ CMSAdminUtil.showErrorDialog(mParent, mResource, ex.toString(),
+ CMSAdminUtil.ERROR_MESSAGE);
+ }
+ } else if (evt.getSource().equals(mHelp)) {
+ CMSAdminUtil.help(HELPINDEX);
+ }
+ }
+
+/*
+ private void refresh() {
+ try {
+ NameValuePairs results = mConn.process(
+ DestDef.DEST_SERVER_ADMIN, ScopeDef.SC_CERT_PRETTY_PRINT,
+ Constants.RS_ID_CONFIG, nvps);
+ if (nvps.size() <= 0)
+ return;
+ NameValuePair nvp = results.elementAt(0);
+ String name = nvp.getName();
+ String value = nvp.getValue();
+ CertificateInfoDialog dialog = new CertificateInfoDialog(mParent);
+ dialog.showDialog(name, value);
+ } catch (EAdminException ex) {
+ CMSAdminUtil.showErrorDialog(mParent, mResource, ex.toString(),
+ CMSAdminUtil.ERROR_MESSAGE);
+ }
+ }
+*/
+
+ private void setDisplay() {
+ getContentPane().setLayout(new BorderLayout());
+ JPanel center = new JPanel();
+ GridBagLayout gb = new GridBagLayout();
+ GridBagConstraints gbc = new GridBagConstraints();
+ center.setLayout(gb);
+
+ //content panel
+ JPanel content = makeContentPane();
+ CMSAdminUtil.resetGBC(gbc);
+ gbc.fill = gbc.BOTH;
+ gbc.anchor = gbc.NORTH;
+ gbc.gridwidth = gbc.REMAINDER;
+ gbc.weightx = 1.0;
+ gbc.weighty = 1.0;
+ gb.setConstraints(content, gbc);
+ center.add(content);
+
+ //action panel
+ JPanel action = makeActionPane();
+ CMSAdminUtil.resetGBC(gbc);
+ gbc.anchor = gbc.NORTH;
+ gbc.gridwidth = gbc.REMAINDER;
+ gbc.gridheight = gbc.REMAINDER;
+ gbc.weightx = 1.0;
+ gb.setConstraints(action, gbc);
+ center.add(action);
+
+ getContentPane().add("Center",center);
+ }
+
+ private JPanel makeActionPane() {
+ mClose = CMSAdminUtil.makeJButton(mResource, PREFIX, "CLOSE",
+ null, this);
+
+ mHelp = CMSAdminUtil.makeJButton(mResource, PREFIX, "HELP", null, this);
+ Dimension d = mClose.getMinimumSize();
+ if (d.width < CMSAdminUtil.DEFAULT_BUTTON_SIZE) {
+ d.width = CMSAdminUtil.DEFAULT_BUTTON_SIZE;
+ mClose.setMinimumSize(d);
+ }
+ d = mHelp.getMinimumSize();
+ if (d.width < CMSAdminUtil.DEFAULT_BUTTON_SIZE) {
+ d.width = CMSAdminUtil.DEFAULT_BUTTON_SIZE;
+ mHelp.setMinimumSize(d);
+ }
+ JButton[] buttons = {mClose, mHelp};
+ return CMSAdminUtil.makeJButtonPanel( buttons );
+ }
+
+ private JPanel makeContentPane() {
+ JPanel content = new JPanel();
+ GridBagLayout gb3 = new GridBagLayout();
+ GridBagConstraints gbc = new GridBagConstraints();
+ content.setLayout(gb3);
+ content.setBorder(CMSAdminUtil.makeTitledBorder(mResource,
+ "CERTINFODIALOG", "CERT"));
+
+ JPanel panel = new JPanel();
+ GridBagLayout gb = new GridBagLayout();
+ panel.setLayout(gb);
+
+ CMSAdminUtil.resetGBC(gbc);
+ gbc.insets = new Insets(0, 0, 0, 0);
+ gbc.gridwidth = gbc.REMAINDER;
+ gbc.fill = gbc.BOTH;
+ content.add(panel, gbc);
+
+ CMSAdminUtil.resetGBC(gbc);
+ JLabel label1 = CMSAdminUtil.makeJLabel(mResource, PREFIX, "CERTNAME",
+ null);
+ gbc.fill = gbc.NONE;
+ gbc.anchor = gbc.EAST;
+ gbc.insets = new Insets(CMSAdminUtil.COMPONENT_SPACE,
+ 0, //CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE, CMSAdminUtil.COMPONENT_SPACE);
+ gb.setConstraints(label1, gbc);
+ panel.add(label1);
+
+ CMSAdminUtil.resetGBC(gbc);
+ mCertNameField = new JLabel(" ");
+ gbc.gridwidth = gbc.REMAINDER;
+ gbc.anchor = gbc.WEST;
+ gbc.weightx=1.0;
+ //gbc.fill = gbc.NONE;
+ gbc.insets = new Insets(CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE, CMSAdminUtil.COMPONENT_SPACE);
+ gb.setConstraints(mCertNameField, gbc);
+ panel.add(mCertNameField);
+
+
+ //CMSAdminUtil.addEntryField(content, label1, mCertNameField, gbc);
+
+ CMSAdminUtil.resetGBC(gbc);
+ JLabel label2 = CMSAdminUtil.makeJLabel(mResource, PREFIX, "CONTENT", null);
+ gbc.fill = gbc.NONE;
+ gbc.anchor = gbc.WEST;
+ //gbc.gridwidth = gbc.REMAINDER;
+ gbc.insets = new Insets(0,
+ CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE, CMSAdminUtil.COMPONENT_SPACE);
+ gb.setConstraints(label2, gbc);
+ panel.add(label2);
+
+ CMSAdminUtil.resetGBC(gbc);
+ JLabel label3 = new JLabel(" ");
+ //gbc.fill = gbc.NONE;
+ gbc.weightx = 1.0;
+ gbc.anchor = gbc.WEST;
+ gbc.gridwidth = gbc.REMAINDER;
+ gbc.gridheight = gbc.REMAINDER;
+ gbc.insets = new Insets(0,
+ CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE, CMSAdminUtil.COMPONENT_SPACE);
+ gb.setConstraints(label3, gbc);
+ panel.add(label3);
+
+ CMSAdminUtil.resetGBC(gbc);
+ mTextArea = new JTextArea("",100,90);
+ 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.weightx=1.0;
+ gbc.weighty=1.0;
+ gbc.insets = new Insets(0,
+ CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE, CMSAdminUtil.COMPONENT_SPACE);
+ gb3.setConstraints(scrollPanel, gbc);
+ content.add(scrollPanel);
+
+ CMSAdminUtil.resetGBC(gbc);
+ mStatusLbl = CMSAdminUtil.makeJLabel(mResource, PREFIX, "TRUSTSTATUS", null);
+ gbc.anchor = gbc.WEST;
+ gbc.gridwidth = gbc.REMAINDER;
+ gbc.insets = new Insets(0,
+ CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE, CMSAdminUtil.COMPONENT_SPACE);
+ gb3.setConstraints(mStatusLbl, gbc);
+ content.add(mStatusLbl);
+
+ CMSAdminUtil.resetGBC(gbc);
+ changeLbl = CMSAdminUtil.makeJLabel(mResource, PREFIX, "MODIFY", null);
+ gbc.anchor = gbc.WEST;
+ gbc.insets = new Insets(0,
+ CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE, CMSAdminUtil.COMPONENT_SPACE);
+ gb3.setConstraints(changeLbl, gbc);
+ content.add(changeLbl);
+
+ CMSAdminUtil.resetGBC(gbc);
+ mActionBtn = CMSAdminUtil.makeJButton(mResource, PREFIX,"UNTRUST", null, this);
+ gbc.anchor = gbc.WEST;
+ gbc.insets = new Insets(0,
+ CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE, CMSAdminUtil.COMPONENT_SPACE);
+ gbc.gridwidth = gbc.REMAINDER;
+ gbc.gridheight = gbc.REMAINDER;
+ gbc.fill = gbc.NONE;
+ gb3.setConstraints(mActionBtn, gbc);
+ content.add(mActionBtn);
+/*
+ CMSAdminUtil.resetGBC(gbc);
+ mTrust = CMSAdminUtil.makeJButton(mResource, PREFIX, "TRUST", null, this);
+ gbc.fill = gbc.NONE;
+ gbc.anchor = gbc.EAST;
+ gbc.insets = new Insets(0,
+ CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE, CMSAdminUtil.COMPONENT_SPACE);
+ gbc.gridwidth = gbc.REMAINDER;
+ gb3.setConstraints(mTrust, gbc);
+ content.add(mTrust);
+*/
+
+ return content;
+ }
+}
+
diff --git a/pki/base/console/src/com/netscape/admin/certsrv/managecert/ManageCertDialog.java b/pki/base/console/src/com/netscape/admin/certsrv/managecert/ManageCertDialog.java
new file mode 100644
index 000000000..dc848f376
--- /dev/null
+++ b/pki/base/console/src/com/netscape/admin/certsrv/managecert/ManageCertDialog.java
@@ -0,0 +1,364 @@
+// --- 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.managecert;
+
+import java.util.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.table.*;
+import javax.swing.*;
+import javax.swing.border.*;
+import com.netscape.admin.certsrv.*;
+import com.netscape.management.client.util.*;
+import com.netscape.admin.certsrv.connection.*;
+import com.netscape.certsrv.common.*;
+
+/**
+ * This class lists out all the CA certificates from the internal token.
+ *
+ * @author chrisho
+ * @version $Revision$, $Date$
+ * @see com.netscape.admin.certsrv.managecert
+ */
+public class ManageCertDialog extends JDialog implements ActionListener,
+ MouseListener {
+ private static final String PANELNAME = "MANAGECERTDIALOG";
+ static final Dimension DEFAULT_SIZE = new Dimension(460,500);
+ static final Dimension BUTTON_MIN_SIZE = new Dimension(100,30);
+
+ protected ResourceBundle mResource;
+ private JFrame mParent;
+ private JTable mTable;
+ private ManageCertModel mDataModel;
+ private JButton mClose, mDelete, mEdit, mHelp;
+ private AdminConnection mConn;
+ private static final String HELPINDEX =
+ "configuration-managecert-wizard-certlists-help";
+
+ public ManageCertDialog(JFrame parent) {
+ super(parent, true);
+ mParent = parent;
+ setSize(460,500);
+ getRootPane().setDoubleBuffered(true);
+ setLocationRelativeTo(parent);
+ mResource = ResourceBundle.getBundle(CMSAdminResources.class.getName());
+ setTitle(mResource.getString(PANELNAME+"_TITLE"));
+ setDisplay();
+ }
+
+ public void showDialog(AdminConnection conn) {
+ mConn = conn;
+ refresh();
+ this.show();
+ }
+
+ private void refresh() {
+ NameValuePairs response=null;
+ try {
+ response = mConn.search(DestDef.DEST_SERVER_ADMIN, ScopeDef.SC_ALL_CERTLIST,
+ new NameValuePairs());
+ } catch (EAdminException e) {
+ CMSAdminUtil.showErrorDialog(mParent, mResource, e.toString(),
+ CMSAdminUtil.ERROR_MESSAGE);
+ }
+
+ if (response == null) { /* we must have gotten timed out */
+ return;
+ }
+
+ mDataModel.removeAllRows();
+
+ String[] vals = new String[response.size()];
+ int i=0;
+ for (Enumeration e = response.getNames(); e.hasMoreElements() ;) {
+ String entry = ((String)e.nextElement()).trim();
+ vals[i++] = entry;
+ }
+
+ CMSAdminUtil.bubbleSort(vals);
+
+ for (i=0; i<vals.length; i++) {
+ String entry = vals[i];
+ String value = response.getValue(entry);
+ addRows(entry, value);
+ }
+ mTable.getSelectionModel().clearSelection();
+ setButtons();
+ }
+
+ private void addRows(String entry, String value) {
+ StringTokenizer tokenizer = new StringTokenizer(value, ";");
+ int numTokens = tokenizer.countTokens();
+ while (tokenizer.hasMoreTokens()) {
+ String token = (String)tokenizer.nextToken();
+ String expiredDate = token.substring(0, token.length()-2);
+ String trust = token.substring(token.length()-1);
+ Vector v = new Vector();
+ v.addElement(entry);
+ v.addElement(expiredDate);
+ if (trust.equals("T"))
+ v.addElement("Trusted");
+ else if (trust.equals("U"))
+ v.addElement("Untrusted");
+ else if (trust.equals("u"))
+ v.addElement("N/A");
+ mDataModel.addRow(v);
+ }
+ }
+
+ private void setDisplay() {
+ getContentPane().setLayout(new BorderLayout());
+ JPanel center = new JPanel();
+ GridBagLayout gb = new GridBagLayout();
+ GridBagConstraints gbc = new GridBagConstraints();
+ center.setLayout(gb);
+
+ //content panel
+ JPanel content = makeContentPane();
+ CMSAdminUtil.resetGBC(gbc);
+ gbc.anchor = gbc.NORTH;
+ gbc.gridwidth = gbc.REMAINDER;
+ gbc.fill = gbc.BOTH;
+ gbc.weightx = 1.0;
+ gbc.weighty = 1.0;
+ gb.setConstraints(content, gbc);
+ center.add(content);
+
+ //action panel
+ JPanel action = makeActionPane();
+ CMSAdminUtil.resetGBC(gbc);
+ gbc.anchor = gbc.NORTH;
+ gbc.gridwidth = gbc.REMAINDER;
+ gbc.gridheight = gbc.REMAINDER;
+ gbc.weightx = 1.0;
+ gb.setConstraints(action, gbc);
+ center.add(action);
+
+ getContentPane().add("Center",center);
+ }
+
+ public JPanel makeActionPane() {
+ JPanel panel = new JPanel();
+
+ mClose = new JButton();
+ mClose.setText(mResource.getString(
+ "MANAGECERTDIALOG_BUTTON_CLOSE_LABEL"));
+ mClose.addActionListener(this);
+
+ mEdit = new JButton();
+ mEdit.setText(mResource.getString(
+ "MANAGECERTDIALOG_BUTTON_EDIT_VIEW_LABEL"));
+ mEdit.addActionListener(this);
+
+ mDelete = new JButton();
+ mDelete.setText(mResource.getString(
+ "MANAGECERTDIALOG_BUTTON_DELETE_LABEL"));
+ mDelete.addActionListener(this);
+
+ mHelp = new JButton();
+ mHelp.setText(mResource.getString(
+ "MANAGECERTDIALOG_BUTTON_HELP_LABEL"));
+ mHelp.addActionListener(this);
+
+ JButton[] buttons = {mClose, mEdit, mDelete, mHelp};
+ return CMSAdminUtil.makeJButtonPanel(buttons, true);
+ }
+
+ public JPanel makeContentPane() {
+ JPanel content = new JPanel();
+ content.setBorder(CMSAdminUtil.makeTitledBorder(mResource,
+ "MANAGECERTDIALOG", "CERT"));
+ GridBagLayout gb = new GridBagLayout();
+ GridBagConstraints gbc = new GridBagConstraints();
+ content.setLayout(gb);
+
+ CMSAdminUtil.resetGBC(gbc);
+ mDataModel = new ManageCertModel();
+ mTable = new JTable(mDataModel);
+ JScrollPane scrollPane = JTable.createScrollPaneForTable(mTable);
+ scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ mTable.setPreferredScrollableViewportSize(new Dimension(200, 350));
+ mTable.setAutoscrolls(true);
+ mTable.sizeColumnsToFit(true);
+ mTable.addMouseListener(this);
+ scrollPane.setBackground(Color.white);
+ setLabelCellRenderer(mTable, 0);
+ setLabelCellRenderer(mTable, 1);
+ setLabelCellRenderer(mTable, 2);
+
+ CMSAdminUtil.resetGBC(gbc);
+ gbc.anchor = gbc.NORTH;
+ gbc.gridwidth = gbc.REMAINDER;
+ gbc.weightx = 1.0;
+ gbc.weighty = 1.0;
+ gbc.fill = gbc.BOTH;
+ gbc.gridheight = gbc.REMAINDER;
+ gbc.insets = new Insets(CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE,
+ CMSAdminUtil.COMPONENT_SPACE, CMSAdminUtil.COMPONENT_SPACE);
+ gb.setConstraints(scrollPane, gbc);
+ content.add(scrollPane);
+
+ return content;
+ }
+
+ protected void setLabelCellRenderer(JTable table, int index) {
+ table.getColumnModel().getColumn(index).setCellRenderer(
+ new DefaultTableCellRenderer());
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ Object source = e.getSource();
+ if (source.equals(mClose)) {
+ this.hide();
+ this.dispose();
+ } else if (source.equals(mDelete)) {
+ try {
+ // make sure selected cert is not a user cert
+ boolean userCert = false;
+ int[] rows = mTable.getSelectedRows();
+ for (int i=0; i<rows.length; i++) {
+ String trust =
+ (String)mDataModel.getValueAt(rows[i], 2);
+ if (trust.equals("N/A")) {
+ userCert = true;
+ }
+
+ String value = (String)mDataModel.getValueAt(rows[i], 0);
+ if (
+ (value.indexOf(Constants.PR_CA_SIGNING_NICKNAME) != -1) || (value.indexOf(Constants.PR_OCSP_SIGNING_CERT) != -1) ) {
+ userCert = true;
+ }
+ }
+
+ if (userCert == false) {
+ NameValuePairs nvps = getCerts();
+ mConn.modify(DestDef.DEST_SERVER_ADMIN, ScopeDef.SC_DELETE_CERTS,
+ Constants.RS_ID_CONFIG, nvps);
+ refresh();
+ } else {
+ // user certs can't be removed from here
+ CMSAdminUtil.showErrorDialog(mParent, mResource,
+ mResource.getString("CERTIMPORTDIALOG_DIALOG_CANTDELETE_MESSAGE"),
+ CMSAdminUtil.ERROR_MESSAGE);
+ }
+ } catch (EAdminException ex) {
+ CMSAdminUtil.showErrorDialog(mParent, mResource, ex.toString(),
+ CMSAdminUtil.ERROR_MESSAGE);
+ }
+ } else if (source.equals(mEdit)) {
+ displayCert();
+ } else if (source.equals(mHelp)) {
+ CMSAdminUtil.help(HELPINDEX);
+ }
+ }
+
+ private void displayCert() {
+ try {
+ NameValuePairs nvps = getCerts();
+ NameValuePairs results = mConn.process(
+ DestDef.DEST_SERVER_ADMIN, ScopeDef.SC_CERT_PRETTY_PRINT,
+ Constants.RS_ID_CONFIG, nvps);
+ if (nvps.size() <= 0)
+ return;
+ NameValuePair nvp = results.elementAt(0);
+ String name = nvp.getName();
+ String print = nvp.getValue();
+ CertificateInfoDialog dialog = new CertificateInfoDialog(mParent);
+ dialog.showDialog(name, print, getTrustLbl(), getDate(),mConn);
+ refresh();
+ } catch (EAdminException ex) {
+ CMSAdminUtil.showErrorDialog(mParent, mResource, ex.toString(),
+ CMSAdminUtil.ERROR_MESSAGE);
+ }
+ }
+
+ //==== MOUSELISTENER ======================
+ public void mouseClicked(MouseEvent e) {
+ setButtons();
+
+ //we track the double click action on the table entry - View op
+ if(mTable.getSelectedRow() >= 0) {
+ if(e.getClickCount() == 2) {
+ displayCert();
+ }
+ }
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ public void mousePressed(MouseEvent e) {
+ }
+
+ public void mouseEntered(MouseEvent e) {
+ }
+
+ public void mouseExited(MouseEvent e) {
+ }
+
+ private void setButtons() {
+ //enable and disable buttons accordingly
+ if (mTable.getSelectionModel().isSelectionEmpty()) {
+ mDelete.setEnabled(false);
+ mEdit.setEnabled(false);
+ return;
+ }
+
+ if(mDataModel.getRowCount()< 0) {
+ mDelete.setEnabled(false);
+ mEdit.setEnabled(false);
+ return;
+ }
+
+ mDelete.setEnabled(true);
+ mEdit.setEnabled(true);
+ }
+
+ private NameValuePairs getCerts() {
+ int[] rows = mTable.getSelectedRows();
+ NameValuePairs nvps = new NameValuePairs();
+ String name = "certName";
+ for (int i=0; i<rows.length; i++) {
+ String value = (String)mDataModel.getValueAt(rows[i], 0);
+ String date = (String)mDataModel.getValueAt(rows[i], 1);
+ nvps.add(name+i, value+";"+date);
+ }
+ return nvps;
+ }
+
+ private String getTrustLbl() {
+ int row = mTable.getSelectedRow();
+ String trust = (String)mDataModel.getValueAt(row, 2);
+ if (trust.equals("Trusted"))
+ return "Trust";
+ else if (trust.equals("Untrusted"))
+ return "Untrust";
+ else if (trust.equals("N/A"))
+ return "N/A";
+ else
+ return "Unknown";
+
+ }
+
+ private String getDate() {
+ int row = mTable.getSelectedRow();
+ return (String)mDataModel.getValueAt(row, 1);
+ }
+}
diff --git a/pki/base/console/src/com/netscape/admin/certsrv/managecert/ManageCertModel.java b/pki/base/console/src/com/netscape/admin/certsrv/managecert/ManageCertModel.java
new file mode 100644
index 000000000..2cae90759
--- /dev/null
+++ b/pki/base/console/src/com/netscape/admin/certsrv/managecert/ManageCertModel.java
@@ -0,0 +1,55 @@
+// --- 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.managecert;
+
+import java.util.*;
+import javax.swing.*;
+import com.netscape.admin.certsrv.*;
+import com.netscape.certsrv.common.*;
+
+/**
+ * Manage certificate data model - represents the instance
+ * table information
+ *
+ * @author Christine Ho
+ * @version $Revision$, $Date$
+ */
+public class ManageCertModel extends CMSTableModel
+{
+
+ /*==========================================================
+ * variables
+ *==========================================================*/
+ public static final String COL1 = "CERTNAME";
+ public static final String COL2 = "EXPIRED";
+ public static final String COL3 = "TRUST";
+
+ private static String[] mColumns = {COL1, COL2, COL3};
+
+ /*==========================================================
+ * constructors
+ *==========================================================*/
+ public ManageCertModel() {
+ super();
+ init(mColumns);
+ }
+
+ public boolean isCellEditable(int row, int col) {
+ return false;
+ }
+}