// --- 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.config; import com.netscape.admin.certsrv.*; import com.netscape.admin.certsrv.ug.*; import com.netscape.admin.certsrv.config.*; import com.netscape.admin.certsrv.connection.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.*; import javax.swing.text.*; import java.awt.event.*; import java.awt.*; import java.util.*; import com.netscape.management.client.*; import com.netscape.management.client.util.*; import com.netscape.certsrv.common.*; /** * Connector Editor * * @author Christine Ho * @version $Revision$, $Date$ * @see com.netscape.admin.certsrv.config */ public class ConnectorEditor extends JDialog implements ActionListener, MouseListener { private final static String PREFIX = "CONNECTOREDITOR"; private final static String HELPINDEX = "configuration-ra-connector-editor-help"; private final static String HELPINDEX1 = "configuration-overview"; private JButton mOK, mCancel, mHelp; private String mName; private ListCertsModel mDataModel; // Changed by beomsuk //private JTextField mLocalText, mURIText, mHostText, mPortText; private JTextField mLocalText, mURIText, mHostText, mPortText, mTimeoutText, mNicknameText; // Change end private ResourceBundle mResource; private JFrame mParentFrame; private AdminConnection mAdmin; // Changed by beomsuk //private JLabel idLabel, uriLabel, hostLabel, portLabel; private JLabel idLabel, uriLabel, hostLabel, portLabel, timeoutLabel, timeunitLabel, nicknameLabel; // Change end private Color mActiveColor; private String mDest; private JCheckBox mEnableBox; private boolean mEnable = false; private String mInstanceName; private boolean mColocated; private JTable mCertTable; private JTextArea mHeading; public ConnectorEditor(AdminConnection admin, JFrame parent, String name, String dest, String instanceName, boolean colocated) { super(parent,true); mParentFrame = parent; mResource = ResourceBundle.getBundle(CMSAdminResources.class.getName()); mAdmin = admin; mName = name; mInstanceName = instanceName; mDest = dest; mColocated = colocated; setSize(460, 516); setTitle(mResource.getString(PREFIX+"_TITLE")); setLocationRelativeTo(parent); getRootPane().setDoubleBuffered(true); setDisplay(); } 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 = makeContentPanel(); CMSAdminUtil.resetGBC(gbc); gbc.anchor = gbc.NORTH; gbc.gridwidth = gbc.REMAINDER; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = gbc.BOTH; //gbc.insets = CMSAdminUtil.DEFAULT_EMPTY_INSETS; gb.setConstraints(content, gbc); center.add(content); NameValuePairs response = getCertsList(ScopeDef.SC_USERCERTSLIST); mDataModel.removeAllRows(); if (response != null) { 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; } int sindex = 0; String snickname = ""; CMSAdminUtil.quickSort(vals, 0, response.size()-1); for (i=0; i -1) { sindex = i; snickname = fullnickname; } } else { if (fullnickname.indexOf("raSigningCert") > -1) { sindex = i; snickname = fullnickname; } } v.addElement(nickname); v.addElement(entry.substring(lastindex+1)); v.addElement(value); v.addElement(tokenname); mDataModel.addRow(v); } } mCertTable.setRowSelectionInterval(sindex, sindex); mNicknameText.setText(snickname); } //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); } protected void setLabelCellRenderer(JTable table, int index) { table.getColumnModel().getColumn(index).setCellRenderer( new DefaultTableCellRenderer()); } private void displayCert(int row) { String nickname = (String)(mCertTable.getValueAt(row, 3)) + ":" + (String)(mCertTable.getValueAt(row, 0)); String serialno = (String)(mCertTable.getValueAt(row, 1)); String issuername = (String)(mCertTable.getValueAt(row, 2)); try { NameValuePairs nvps = new NameValuePairs(); nvps.add(Constants.PR_NICK_NAME, nickname); nvps.add(Constants.PR_SERIAL_NUMBER, serialno); nvps.add(Constants.PR_ISSUER_NAME, issuername); NameValuePairs results = mAdmin.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(); CertViewDialog certdialog = new CertViewDialog(mParentFrame); certdialog.showDialog(nickname, print); } catch (EAdminException ex) { CMSAdminUtil.showErrorDialog(mParentFrame, mResource, ex.toString(), CMSAdminUtil.ERROR_MESSAGE); } } public void mouseClicked(MouseEvent e) { //setButtons(); //we track the double click action on the table entry - View op int row = mCertTable.getSelectedRow(); if(row >= 0) { mNicknameText.setText((String)(mCertTable.getValueAt(row, 0))); if(e.getClickCount() == 2) { displayCert(row); } } } public void mouseReleased(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void showDialog(NameValuePairs values) { for (int i=0; i