001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id$
023: */
024:
025: package com.bostechcorp.cbesb.ui.ide.security;
026:
027: import org.eclipse.jface.wizard.IWizardPage;
028: import org.eclipse.jface.wizard.WizardPage;
029: import org.eclipse.swt.SWT;
030: import org.eclipse.swt.events.SelectionAdapter;
031: import org.eclipse.swt.events.SelectionEvent;
032:
033: import org.eclipse.swt.layout.GridData;
034: import org.eclipse.swt.layout.GridLayout;
035: import org.eclipse.swt.widgets.Button;
036: import org.eclipse.swt.widgets.Composite;
037: import org.eclipse.swt.widgets.Group;
038:
039: import com.bostechcorp.cbesb.common.i18n.I18N;
040: import com.bostechcorp.cbesb.common.i18n.Messages;
041:
042: public class CMWAdvancedSelectPage extends CMWContextAwarePage {
043:
044: private Button deleteCertificateFromButton;
045:
046: private Button viewACertificateButton;
047:
048: private Button generateAPublicprivateButton;
049:
050: private Button exportACertificateButton;
051:
052: private Button exportPublicKeyButton;
053:
054: private Button importASignedButton;
055:
056: private Button viewAKeyfileButton;
057:
058: private Button importCertificateIntoButton;
059:
060: private Button exportCertificateFromButton;
061:
062: private Button viewATrustButton;
063:
064: private WizardPage nextPage;
065:
066: /**
067: (1) Generate a private/public key pair and self-signed certificate.
068: (2) Export a Certificate Signing Request from a key file.
069: (3) Export a public key certificate from a key file.
070: (4) Import a signed certificate into a key file.
071: (5) View a key file.
072: (6) Import a certificate into a trust file.
073: (7) Export a certificate from a trust file.
074: (8) Delete a certificate from a trust file.
075: (9) View a trust file.
076: (10) View a certificate export file.
077: */
078:
079: protected CMWAdvancedSelectPage(String pageName) {
080: super (pageName);
081:
082: setTitle(I18N.getString(Messages.CMW_ADVANCED_TITLE));
083: setDescription(I18N
084: .getString(Messages.CMW_ADVANCED_DESCRIPTION));
085: }
086:
087: public void createControl(Composite parent) {
088:
089: final Composite top = new Composite(parent, SWT.NONE);
090: top.setLayout(new GridLayout());
091: top.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false,
092: false));
093: final Group selectAFunctionGroup = new Group(top, SWT.NONE);
094: selectAFunctionGroup.setLayout(new GridLayout());
095: final GridData gridData = new GridData(SWT.FILL, SWT.BOTTOM,
096: true, false);
097: //gridData.heightHint = 201;
098: selectAFunctionGroup.setLayoutData(gridData);
099: selectAFunctionGroup.setText(I18N
100: .getString(Messages.CMW_ADVANCED_GROUP));
101:
102: generateAPublicprivateButton = new Button(selectAFunctionGroup,
103: SWT.RADIO);
104: generateAPublicprivateButton.setLayoutData(new GridData(
105: SWT.FILL, SWT.CENTER, true, false));
106: generateAPublicprivateButton.setSelection(true);
107: generateAPublicprivateButton
108: .addSelectionListener(new SelectionAdapter() {
109: public void widgetDefaultSelected(
110: final SelectionEvent e) {
111: checkSelection();
112: }
113:
114: public void widgetSelected(final SelectionEvent e) {
115: checkSelection();
116: }
117: });
118: generateAPublicprivateButton.setText(I18N
119: .getString(Messages.CMW_ADVANCED_GENERATE));
120:
121: exportACertificateButton = new Button(selectAFunctionGroup,
122: SWT.RADIO);
123: exportACertificateButton.setLayoutData(new GridData(SWT.FILL,
124: SWT.CENTER, true, false));
125: exportACertificateButton
126: .addSelectionListener(new SelectionAdapter() {
127: public void widgetSelected(final SelectionEvent e) {
128: checkSelection();
129: }
130: });
131: exportACertificateButton.setText(I18N
132: .getString(Messages.CMW_ADVANCED_EXPORT_CSR));
133:
134: exportPublicKeyButton = new Button(selectAFunctionGroup,
135: SWT.RADIO);
136: exportPublicKeyButton.setLayoutData(new GridData(SWT.FILL,
137: SWT.CENTER, true, false));
138: exportPublicKeyButton
139: .addSelectionListener(new SelectionAdapter() {
140: public void widgetSelected(final SelectionEvent e) {
141: checkSelection();
142: }
143: });
144: exportPublicKeyButton.setText(I18N
145: .getString(Messages.CMW_ADVANCED_EXPORT_PKC));
146:
147: importASignedButton = new Button(selectAFunctionGroup,
148: SWT.RADIO);
149: importASignedButton.setLayoutData(new GridData(SWT.FILL,
150: SWT.CENTER, true, false));
151: importASignedButton
152: .addSelectionListener(new SelectionAdapter() {
153: public void widgetSelected(final SelectionEvent e) {
154: checkSelection();
155: }
156: });
157: importASignedButton.setText(I18N
158: .getString(Messages.CMW_ADVANCED_IMPORT_SC));
159:
160: viewAKeyfileButton = new Button(selectAFunctionGroup, SWT.RADIO);
161: viewAKeyfileButton.setLayoutData(new GridData(SWT.FILL,
162: SWT.CENTER, true, false));
163: viewAKeyfileButton.addSelectionListener(new SelectionAdapter() {
164: public void widgetSelected(final SelectionEvent e) {
165: checkSelection();
166: }
167: });
168: viewAKeyfileButton.setText(I18N
169: .getString(Messages.CMW_ADVANCED_VIEW_KF));
170:
171: importCertificateIntoButton = new Button(selectAFunctionGroup,
172: SWT.RADIO);
173: importCertificateIntoButton.setLayoutData(new GridData(
174: SWT.FILL, SWT.CENTER, true, false));
175: importCertificateIntoButton
176: .addSelectionListener(new SelectionAdapter() {
177: public void widgetSelected(final SelectionEvent e) {
178: checkSelection();
179: }
180: });
181: importCertificateIntoButton.setText(I18N
182: .getString(Messages.CMW_ADVANCED_IMPORT_C));
183:
184: exportCertificateFromButton = new Button(selectAFunctionGroup,
185: SWT.RADIO);
186: exportCertificateFromButton.setLayoutData(new GridData(
187: SWT.FILL, SWT.CENTER, true, false));
188: exportCertificateFromButton
189: .addSelectionListener(new SelectionAdapter() {
190: public void widgetSelected(final SelectionEvent e) {
191: checkSelection();
192: }
193: });
194: exportCertificateFromButton.setText(I18N
195: .getString(Messages.CMW_ADVANCED_EXPORT_C));
196:
197: deleteCertificateFromButton = new Button(selectAFunctionGroup,
198: SWT.RADIO);
199: deleteCertificateFromButton.setLayoutData(new GridData(
200: SWT.FILL, SWT.CENTER, false, false));
201: deleteCertificateFromButton
202: .addSelectionListener(new SelectionAdapter() {
203: public void widgetSelected(final SelectionEvent e) {
204: checkSelection();
205: }
206: });
207: deleteCertificateFromButton.setText(I18N
208: .getString(Messages.CMW_ADVANCED_DELETE_C));
209:
210: viewATrustButton = new Button(selectAFunctionGroup, SWT.RADIO);
211: viewATrustButton.setLayoutData(new GridData(SWT.FILL,
212: SWT.CENTER, false, false));
213: viewATrustButton.addSelectionListener(new SelectionAdapter() {
214: public void widgetSelected(final SelectionEvent e) {
215: checkSelection();
216: }
217: });
218: viewATrustButton.setText(I18N
219: .getString(Messages.CMW_ADVANCED_VIEW_TF));
220:
221: viewACertificateButton = new Button(selectAFunctionGroup,
222: SWT.RADIO);
223: viewACertificateButton.setLayoutData(new GridData(SWT.FILL,
224: SWT.CENTER, false, false));
225: viewACertificateButton
226: .addSelectionListener(new SelectionAdapter() {
227: public void widgetSelected(final SelectionEvent e) {
228: checkSelection();
229: }
230: });
231: viewACertificateButton.setText(I18N
232: .getString(Messages.CMW_ADVANCED_VIEW_CEF));
233: initialize();
234:
235: setControl(top);
236: checkSelection();
237: }
238:
239: private void checkSelection() {
240: CertificateManagerWizard parent = (CertificateManagerWizard) this
241: .getWizard();
242: if (getGenerateAPublicprivateButton().getSelection()) {
243: setPageComplete(true);
244: nextPage = parent.getAdvGenerateKey();
245: return;
246: } else if (getDeleteCertificateFromButton().getSelection()) {
247: setPageComplete(true);
248: nextPage = parent.getAdvDeleteCertificate();
249: return;
250: } else if (getViewACertificateButton().getSelection()) {
251: setPageComplete(true);
252: nextPage = parent.getAdvViewCEF();
253: return;
254: } else if (getExportACertificateButton().getSelection()) {
255: setPageComplete(true);
256: nextPage = parent.getAdvExportCSR();
257: return;
258: } else if (getExportPublicKeyButton().getSelection()) {
259: setPageComplete(true);
260: nextPage = parent.getAdvExportPKC();
261: return;
262: } else if (getExportCertificateFromButton().getSelection()) {
263: setPageComplete(true);
264: nextPage = parent.getAdvExportCertificate();
265: return;
266: } else if (getImportASignedButton().getSelection()) {
267: setPageComplete(true);
268: nextPage = parent.getAdvImportSC();
269: return;
270: } else if (getViewAKeyfileButton().getSelection()) {
271: setPageComplete(true);
272: nextPage = parent.getAdvViewKF();
273: return;
274: } else if (getImportCertificateIntoButton().getSelection()) {
275: setPageComplete(true);
276: nextPage = parent.getAdvImportCertificate();
277: return;
278: } else if (getViewATrustButton().getSelection()) {
279: setPageComplete(true);
280: nextPage = parent.getAdvViewTF();
281: return;
282: }
283: setPageComplete(false);
284: }
285:
286: @Override
287: public IWizardPage getNextPage() {
288: CertificateManagerWizard parent = (CertificateManagerWizard) getWizard();
289: parent.setNext(null);
290: parent.setPrevious(this );
291: return nextPage;
292: }
293:
294: @Override
295: public IWizardPage getPreviousPage() {
296: CertificateManagerWizard parent = (CertificateManagerWizard) this
297: .getWizard();
298: parent.setNext(this );
299: parent.setPrevious(null);
300: return parent.getMainPage();
301: }
302:
303: private void initialize() {
304: }
305:
306: protected Button getViewATrustButton() {
307: return viewATrustButton;
308: }
309:
310: public Button getExportCertificateFromButton() {
311: return exportCertificateFromButton;
312: }
313:
314: public Button getImportCertificateIntoButton() {
315: return importCertificateIntoButton;
316: }
317:
318: public Button getViewAKeyfileButton() {
319: return viewAKeyfileButton;
320: }
321:
322: public Button getImportASignedButton() {
323: return importASignedButton;
324: }
325:
326: public Button getExportPublicKeyButton() {
327: return exportPublicKeyButton;
328: }
329:
330: public Button getExportACertificateButton() {
331: return exportACertificateButton;
332: }
333:
334: public Button getGenerateAPublicprivateButton() {
335: return generateAPublicprivateButton;
336: }
337:
338: protected Button getViewACertificateButton() {
339: return viewACertificateButton;
340: }
341:
342: public Button getDeleteCertificateFromButton() {
343: return deleteCertificateFromButton;
344: }
345:
346: @Override
347: protected void updatePageComplete() {
348:
349: }
350:
351: }
|