summaryrefslogtreecommitdiffstats
path: root/pki/base/console/src/com/netscape/admin/certsrv/config/CMSUserCertSettingPanel.java
blob: a4b7740f51747a239d5922182797bc397c60f511 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// --- 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.certsrv.common.*;
import com.netscape.management.client.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 * User Certificate Setting
 *
 * @author Christine Ho
 * @author Jack Pan-Chen
 * @version $Revision$, $Date$
 */
public class CMSUserCertSettingPanel extends CMSCertSettingPanel {

    /*==========================================================
     * variables
     *==========================================================*/
    private String _servletName;    //destination name
    private CMSTabPanel mParent;
    private PanelMapperConfigDialog mDialog = null;
    private static final String RAHELPINDEX =
     "configuration-ra-ldappublish-usercert-help";
    private static final String CAHELPINDEX =
     "configuration-ca-ldappublish-usercert-help";

	/*==========================================================
     * constructors
     *==========================================================*/
    public CMSUserCertSettingPanel(String panelName, CMSTabPanel parent) {
        super(panelName, parent);
        _servletName = getServletName(panelName);
        mParent = parent;
        if (panelName.equals("RAUSERCERTSETTING"))
            mHelpToken = RAHELPINDEX;
        else 
            mHelpToken = CAHELPINDEX;
    }

    /*==========================================================
	 * public methods
     *==========================================================*/
     
    /**
     * Actual UI construction
     */
    public void init() {
        super.init(); 
        
        //XXX B1 - disable the publisher configuration
        mPublisher.setEnabled(false);
        //XXX B1 - disable the publisher configuration        
        
        refresh();
    }

    public void refresh() {
        _model.progressStart();
        NameValuePairs nvp = new NameValuePairs();
        nvp.add(Constants.PR_MAPPER, "");
        nvp.add(Constants.PR_PUBLISHER, "");

        try {
            NameValuePairs val = _admin.read(_servletName,
              ScopeDef.SC_USERCERT, Constants.RS_ID_CONFIG, nvp);

            populate(val);
        } catch (EAdminException e) {
            showErrorDialog(e.toString());
            _model.progressStop();
        }
        _model.progressStop();
        clearDirtyFlag();
        mParent.setOKCancel();
    }


    /**
     * Implementation for saving panel information
     * @return true if save successful; otherwise, false.
     */
    public boolean applyCallback() {
        clearDirtyFlag();
        return true;
    }

    /**
     * Implementation for reset values
     * @return true if save successful; otherwise, false.
     */
    public boolean resetCallback() {
        refresh();
        return true;
    }

    /*==========================================================
	 * EVNET HANDLER METHODS
     *==========================================================*/ 
     
    //=== ACTIONLISTENER =====================
    public void actionPerformed(ActionEvent e) {
        if (e.getSource().equals(mMapper)) {
            Debug.println("Edit Mapper Config");
            mDialog = new PanelMapperConfigDialog(_model.getFrame(), _admin);
            mDialog.showDialog(_mapper.getText(), 
                _servletName, ScopeDef.SC_USERCERT);
            if (!mDialog.isOK())
                return;
            refresh();
        } else if (e.getSource().equals(mPublisher)) {
            //Debug.println("Edit Publisher Config");
        }
    }

    /*==========================================================
	 * private methods
     *==========================================================*/
    private String getServletName(String panelName) {
        if (panelName.equals("CAUSERCERTSETTING"))
            return DestDef.DEST_CA_ADMIN;
        return DestDef.DEST_RA_ADMIN;
    }

    private void populate(NameValuePairs nvps) {
        for (int i=0; i<nvps.size(); i++) {
            NameValuePair nvp = nvps.elementAt(i);
            String name = nvp.getName();
            if (name.equals(Constants.PR_MAPPER)) {
                _mapper.setText(nvp.getValue());
            } else if (name.equals(Constants.PR_PUBLISHER)) {
                _publisher.setText(nvp.getValue());
            }
        }
    }
     
}