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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
// --- 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.security.CipherPreferenceDialog;
import com.netscape.management.client.util.*;
import javax.swing.*;
import java.awt.*;
/**
* Allows user to select the SSL cipher preferences.
*
* @author Christine Ho
* @version $Revision: 14593 $, $Date: 2007-05-01 16:35:45 -0700 (Tue, 01 May 2007) $
* @see com.netscape.admin.certsrv.config
*/
public class CMSCipherPreferenceDialog extends AbstractDialog {
CMSSSL2CipherPreference ssl2CipherPref = null;
CMSSSL3CipherPreference ssl3CipherPref = null;
public final static int SSL2 = 1;
public final static int SSL3 = 2;
private JPanel cipherPreferencePane;
boolean modified = true;
private static final ResourceSet mHelpResource =
new ResourceSet("com.netscape.admin.certsrv.certsrv-help");
Help help;
public CMSCipherPreferenceDialog(JFrame parent, boolean isDomestic) {
this(parent, isDomestic, false);
}
public CMSCipherPreferenceDialog(JFrame parent, boolean isDomestic,
boolean hasFortezza) {
this(parent, isDomestic, hasFortezza, SSL2|SSL3);
}
public CMSCipherPreferenceDialog(JFrame parent, boolean isDomestic,
boolean hasFortezza, int SSLVersion) {
super(parent, "", true, OK | CANCEL | HELP);
cipherPreferencePane = new JPanel();
cipherPreferencePane.setLayout(new BoxLayout(cipherPreferencePane, BoxLayout.Y_AXIS));
if ((SSL2 & SSLVersion) == SSL2) {
ssl2CipherPref = new CMSSSL2CipherPreference(isDomestic);
cipherPreferencePane.add(ssl2CipherPref);
}
if ((SSL3 & SSLVersion) == SSL3) {
ssl3CipherPref = new CMSSSL3CipherPreference(isDomestic, hasFortezza);
cipherPreferencePane.add(ssl3CipherPref);
}
cipherPreferencePane.add(Box.createRigidArea(new Dimension(0,4)));
getContentPane().add(cipherPreferencePane);
pack();
}
public void removeSSLVersion(int sslVersion) {
switch (sslVersion) {
case SSL2:
cipherPreferencePane.remove(ssl2CipherPref);
break;
case SSL3:
cipherPreferencePane.remove(ssl3CipherPref);
break;
}
pack();
}
public boolean isCipherEnabled(String cipher) {
return (((ssl2CipherPref == null)?false:ssl2CipherPref.isCipherEnabled(cipher))||
((ssl3CipherPref == null)?false:ssl3CipherPref.isCipherEnabled(cipher)));
}
public void setCipherEnabled(String cipher, boolean enable) {
if (ssl2CipherPref != null) {
ssl2CipherPref.setCipherEnabled(cipher, enable);
}
if (ssl3CipherPref != null) {
ssl3CipherPref.setCipherEnabled(cipher, enable);
}
}
public String[] getSSLPreference(int sslVersion) {
String[] cipher = null;
switch(sslVersion) {
case SSL2:
cipher = ssl2CipherPref.getCipherList();
break;
case SSL3:
cipher = ssl3CipherPref.getCipherList();
break;
default:
break;
}
return cipher;
}
public boolean isSSLEnabled(int sslVersion) {
boolean enable = false;
switch (sslVersion) {
case SSL2:
enable = ssl2CipherPref.isEnabled();
break;
case SSL3:
enable = ssl3CipherPref.isEnabled();
break;
default:
break;
}
return enable;
}
public void setSSLEnabled(int sslVersion, boolean enable) {
switch (sslVersion) {
case SSL2:
ssl2CipherPref.setEnabled(enable);
break;
case SSL3:
ssl3CipherPref.setEnabled(enable);
break;
default:
break;
}
}
public boolean isModified() {
return modified;
}
public void reset() {
if (ssl2CipherPref != null)
ssl2CipherPref.reset();
if (ssl3CipherPref != null)
ssl3CipherPref.reset();
}
public void setSaved() {
if (ssl2CipherPref != null) {
ssl2CipherPref.setSaved();
}
if (ssl3CipherPref != null) {
ssl3CipherPref.setSaved();
}
}
public void setSaved(boolean saved) {
if (saved) {
if (ssl2CipherPref != null) {
ssl2CipherPref.setSaved();
}
if (ssl3CipherPref != null) {
ssl3CipherPref.setSaved();
}
}
}
protected void cancelInvoked() {
reset();
modified = false;
super.cancelInvoked();
}
protected void okInvoked() {
modified = (((ssl2CipherPref==null)?false:ssl2CipherPref.isModified()) ||
((ssl3CipherPref==null)?false:ssl3CipherPref.isModified()));
setSaved();
super.okInvoked();
}
protected void helpInvoked() {
new Help(mHelpResource).help("configuration-overview");
// help.help("SSL", "Preference");
}
}
|