summaryrefslogtreecommitdiffstats
path: root/base/console/src/com/netscape/admin/certsrv/config/CMSCACertSettingPanel.java
blob: 9e898ed052f1f6773c6e2298ceb8700326f86756 (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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// --- 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 java.awt.event.*;

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

    /*==========================================================
     * variables
     *==========================================================*/
    private static String PANEL_NAME = "CACERTSETTING";
    private PanelMapperConfigDialog mDialog = null;
    private CMSTabPanel mParent;
    private static final String HELPINDEX =
      "configuration-ca-ldappublish-cacert-help";

	/*==========================================================
     * constructors
     *==========================================================*/
    public CMSCACertSettingPanel(CMSTabPanel parent) {
        super(PANEL_NAME, parent);
        mParent = parent;
        mHelpToken = HELPINDEX;
    }

    /*==========================================================
	 * 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.put(Constants.PR_MAPPER, "");
        nvp.put(Constants.PR_PUBLISHER, "");

        try {
            NameValuePairs val = _admin.read(DestDef.DEST_CA_ADMIN,
              ScopeDef.SC_CACERT, 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(),
                    DestDef.DEST_CA_ADMIN, ScopeDef.SC_CACERT);
            if (!mDialog.isOK())
                return;
            refresh();
        } else if (e.getSource().equals(mPublisher)) {
            //Debug.println("Edit Publisher Config");
        }
    }

    /*==========================================================
	 * private methods
     *==========================================================*/

    /* get config parameters associated with each mapper
    private NameValueParis getConfig() throws EAdminException {

        NameValuePairs response = _admin.read(DestDef.DEST_CA_ADMIN,
              ScopeDef.SC_CAMAPPER, _mapper.getText()],
              new NameValuePairs());
        return response;
    }
    */

    /*send configuration to server
    private void sendConfig(NameValuePairs response) {

        response.add(Constants.PR_MAPPER, MAPPER[_mapper.getSelectedIndex()]);
        _model.progressStart();
        try {
            _admin.modify(DestDef.DEST_CA_ADMIN,
              ScopeDef.SC_CACERT, Constants.RS_ID_CONFIG, response);
        } catch (EAdminException e) {
            showErrorDialog(e.toString());
            _model.progressStop();
            return false;
        }
        _model.progressStop();

    }
    */

    private void populate(NameValuePairs nvps) {
        for (String name : nvps.keySet()) {
            String value = nvps.get(name);
            if (name.equals(Constants.PR_MAPPER)) {
                _mapper.setText(value);
            } else if (name.equals(Constants.PR_PUBLISHER)) {
                _publisher.setText(value);
            }
        }
    }
}