diff options
Diffstat (limited to 'rse/plugins/org.eclipse.rse.dstore.security/src')
26 files changed, 0 insertions, 3368 deletions
diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/ImageRegistry.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/ImageRegistry.java deleted file mode 100644 index a517d1e17..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/ImageRegistry.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - - -package org.eclipse.rse.internal.dstore.security; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Iterator; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.Image; - -public class ImageRegistry { - - private static URL fgIconBaseURL= null; - - static { - try { - fgIconBaseURL= new URL(UniversalSecurityPlugin.getDefault().getBundle().getEntry("/"), "icons/full/" ); //$NON-NLS-1$ //$NON-NLS-2$ - } catch (MalformedURLException e) { - UniversalSecurityPlugin.getDefault().log(e); - } - } - - /* - * Set of predefined Image Descriptors. - * the following String are all $NON-NLS-1$ - */ - public static final String T_OBJ = "obj16"; //$NON-NLS-1$ - public static final String T_WIZBAN = "wizban"; //$NON-NLS-1$ - - public static final String IMG_CERTIF_FILE = "certif_file.gif"; //$NON-NLS-1$ - public static final String IMG_WZ_IMPORT_CERTIF = "import_cert_wiz.gif";//"newjprj_wiz.gif";//$NON-NLS-1$ - - public static final ImageDescriptor DESC_IMG_CERTIF_FILE = createManaged(T_OBJ,IMG_CERTIF_FILE); - public static final ImageDescriptor DESC_IMG_WZ_IMPORT_CERTIF = createManaged(T_WIZBAN,IMG_WZ_IMPORT_CERTIF); - - protected static HashMap _images; - protected static HashMap _imageDescriptors; - - public static Image getImage(String name) - { - return (Image)_images.get(name); - } - - - /** - * Insert the method's description here. - * Creation date: (2/16/2001 4:57:29 PM) - * @return ImageDescriptor - * @param name java.lang.String - */ - public static ImageDescriptor getImageDescriptor(String name) { - - return (ImageDescriptor) _imageDescriptors.get(name); - } - - private static ImageDescriptor createManaged(String prefix, String name) { - try { - ImageDescriptor result = - ImageDescriptor.createFromURL(makeIconFileURL(prefix, name)); - - if (_images == null || _imageDescriptors == null) { - _images = new HashMap(); - _imageDescriptors = new HashMap(); - } - - _imageDescriptors.put(name, result); - _images.put(name, result.createImage()); - return result; - - } catch (MalformedURLException e) { - return ImageDescriptor.getMissingImageDescriptor(); - } - } - - public static void setImageDescriptors( - IAction action, - String type, - String relPath) { - try { - ImageDescriptor id = - ImageDescriptor.createFromURL(makeIconFileURL("d" + type, relPath)); //$NON-NLS-1$ - //$NON-NLS-1$ - if (id != null) { - action.setDisabledImageDescriptor(id); - } - } catch (MalformedURLException e) { - } - - try { - ImageDescriptor id = - ImageDescriptor.createFromURL(makeIconFileURL("c" + type, relPath));//$NON-NLS-1$ - if (id != null) { - action.setHoverImageDescriptor(id); - } - } catch (MalformedURLException e) { - } - - action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$ - } - - private static URL makeIconFileURL(String prefix, String name) - throws MalformedURLException { - if (fgIconBaseURL == null) - throw new MalformedURLException(); - - StringBuffer buffer; - if (prefix != null) { - buffer = new StringBuffer(prefix); - buffer.append('/'); - buffer.append(name); - } else { - buffer = new StringBuffer(name); - } - return new URL(fgIconBaseURL, buffer.toString()); - } - - private static ImageDescriptor create(String prefix, String name) { - try { - return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name)); - } catch (MalformedURLException e) { - return ImageDescriptor.getMissingImageDescriptor(); - } - } - - public static void shutdown() { - if (_images == null) - return; - - for (Iterator e = _images.values().iterator(); e.hasNext();) { - Object next = e.next(); - if (next instanceof Image && !((Image) next).isDisposed()) { - ((Image) next).dispose(); - } - } - - _images.clear(); - _images = null; - _imageDescriptors.clear(); - _imageDescriptors = null; - } -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalKeystoreProvider.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalKeystoreProvider.java deleted file mode 100644 index f93dbd7d8..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalKeystoreProvider.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security; - - -import java.util.List; - -import org.eclipse.rse.core.comm.ISystemKeystoreProvider; -import org.eclipse.rse.internal.dstore.security.wizards.SystemImportCertAction; -import org.eclipse.swt.widgets.Display; - - -public class UniversalKeystoreProvider implements ISystemKeystoreProvider -{ - public class ImportCertificateRunnable implements Runnable - { - private List _certificates; - private ISystemKeystoreProvider _provider; - private boolean _wasCancelled = false; - private String _systemName; - - public ImportCertificateRunnable(ISystemKeystoreProvider provider, List certs, String systemName) - { - _certificates = certs; - _provider = provider; - _systemName = systemName; - } - - public boolean wasCancelled() - { - return _wasCancelled; - } - - public void run() - { - SystemImportCertAction importAction = new SystemImportCertAction(_provider, _certificates, _systemName); - importAction.run(); - _wasCancelled = importAction.wasCancelled(); - } - } - - public String getKeyStorePassword() - { - return UniversalSecurityPlugin.getKeyStorePassword(); - } - - public String getKeyStorePath() - { - return UniversalSecurityPlugin.getKeyStoreLocation(); - } - - public boolean importCertificates(List certs, String systemName) - { - Display display = Display.getDefault(); - ImportCertificateRunnable impRun = new ImportCertificateRunnable(this, certs, systemName); - display.syncExec(impRun); - - return !impRun.wasCancelled(); - } -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalSecurityPlugin.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalSecurityPlugin.java deleted file mode 100644 index d41f9625c..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalSecurityPlugin.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format - *******************************************************************************/ - - -package org.eclipse.rse.internal.dstore.security; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; - -public class UniversalSecurityPlugin extends AbstractUIPlugin -{ - private final static String KEYSTORE = "dstorekeystore.dat"; //$NON-NLS-1$ - private static UniversalSecurityPlugin inst; - public static final String PLUGIN_ID = "org.eclipse.rse.dstore.security"; //$NON-NLS-1$ - - public UniversalSecurityPlugin() { - if (inst == null) - inst = this; - } - - public static UniversalSecurityPlugin getDefault() { - return inst; - } - - public static String getPluginId() { - return PLUGIN_ID; - } - - public static String getKeyStoreLocation() { - - Bundle bundle = Platform.getBundle(PLUGIN_ID); - return Platform.getStateLocation(bundle).append(KEYSTORE).toOSString(); - } - - public static String getKeyStorePassword() - { - return "dstore"; //$NON-NLS-1$ - } - - public static String getWorkspaceName(){ - IPath workspace = Platform.getLocation(); - int nr = workspace.segmentCount(); - String workspaceName = workspace.segment(nr - 1); - return workspaceName; - } - - /* (non-Javadoc) - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - - super.stop(context); - - savePluginPreferences(); - ImageRegistry.shutdown(); - } - - public static Shell getActiveWorkbenchShell() { - return getActiveWorkbenchWindow().getShell(); - } - public static IWorkbenchWindow getActiveWorkbenchWindow() { - return getDefault().getWorkbench().getActiveWorkbenchWindow(); - } - - public void log(IStatus status) { - getLog().log(status); - } - - public void log(Throwable e) { - log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Error", e)); //$NON-NLS-1$ - } - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalSecurityProperties.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalSecurityProperties.java deleted file mode 100644 index 0d4b9a937..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalSecurityProperties.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [181112] NLS missing messages - * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security; - -import org.eclipse.osgi.util.NLS; - -public class UniversalSecurityProperties extends NLS -{ - private static String BUNDLE_NAME = "org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties"; //$NON-NLS-1$ - - public static String RESID_SECURITY_CERTIFICATE_PROP_TITLE; - public static String RESID_SECURITY_VALIDITY_PERIOD; - public static String RESID_SECURITY_CERTIF_VERSION_LBL; - public static String RESID_SECURITY_PROP_ALIAS_LBL; - public static String RESID_SECURITY_ISSUED_TO_LBL; - public static String RESID_SECURITY_ISSUED_BY_LBL; - public static String RESID_SECURITY_ALGORITHM_LBL; - public static String RESID_SECURITY_KEY_ENTRY; - public static String RESID_SECURITY_ADD_CERT_DLG_TITLE; - public static String RESID_SECURITY_RENAME_CERT_DLG_TITLE; - public static String RESID_SECURITY_CERTIFICATE_ALIAS; - public static String RESID_SECURITY_SEC_MSG; - public static String RESID_SECURITY_TRUSTED_CERTIFICATE; - public static String RESID_SECURITY_CERTIFICATE_FILE; - public static String RESID_SECURITY_BROWSE; - public static String RESID_SECURITY_ADD_LBL; - public static String RESID_SECURITY_REMOVE_LBL; - public static String RESID_SECURITY_RENAME_LBL; - public static String RESID_SECURITY_PREF_ALIAS_NAME; - public static String RESID_SECURITY_PREF_ISSUED_TO; - public static String RESID_SECURITY_PREF_ISSUED_FROM; - public static String RESID_SECURITY_PREF_EXPIRES; - - public static String RESID_SECURITY_KEY_IO_ERROR_; - public static String RESID_SECURITY_KEY_STORE_ERROR_; - public static String RESID_SECURITY_KEYSTORE_SAVE_ERROR_; - public static String RESID_SECURITY_IO_SAVE_ERROR_; - public static String RESID_SECURITY_CERTIFICATE_STORE_ERROR_; - public static String RESID_SECURITY_UNINIT_KEYSTORE_ERROR_; - public static String RESID_SECURITY_ALGORITHM_ERROR_; - public static String RESID_SECURITY_LOAD_KEYSTORE_ERROR_; - public static String RESID_SECURITY_KEY_LOAD_ERROR_; - public static String RESID_SECURITY_INITIALIZE_ERROR_; - public static String RESID_SECURITY_SECURITY_PROVIDER_ERROR_; - public static String RESID_SECURITY_CERTIFICATE_EXC_; - public static String RESID_SECURITY_LOAD_IO_EXC_; - public static String RESID_SECURITY_CERTIFICATE_LOAD_EXC_; - public static String RESID_SECURITY_PREF_SEC_DESCRIPTION; - public static String RESID_SECURITY_PROPERTIES_LBL; - - public static String RESID_SECURITY_TRUST_WIZ_ALIAS_TITLE; - public static String RESID_SECURITY_TRUST_WIZ_ALIAS_DESC; - - public static String RESID_SECURITY_TRUST_WIZ_CERTIFICATE_TITLE; - public static String RESID_SECURITY_TRUST_WIZ_CERTIFICATE_DESC; - - public static String RESID_SECURITY_TRUST_IMPORT_CERTIFICATE_WIZARD; - public static String RESID_SECURITY_CERTIFICATE_INFORMATION; - - public static String RESID_SECURITY_VALIDITY_LBL; - - static - { - // load message values from bundle file - initializeMessages(BUNDLE_NAME, UniversalSecurityProperties.class); - } - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalSecurityProperties.properties b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalSecurityProperties.properties deleted file mode 100644 index aefd0f186..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/UniversalSecurityProperties.properties +++ /dev/null @@ -1,73 +0,0 @@ -############################################################################### -# Copyright (c) 2006, 2008 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Initial Contributors: -# The following IBM employees contributed to the Remote System Explorer -# component that contains this file: David McKnight, Kushal Munir, -# Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, -# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. -# -# Contributors: -# Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format -# David McKnight (IBM) - [235718] [nls] Missing PII Strings in dstore.security / UniversalSecurityProperties -############################################################################### - -# NLS_MESSAGEFORMAT_NONE -# NLS_ENCODING=UTF-8 - - RESID_SECURITY_CERTIFICATE_PROP_TITLE = Certificate Properties - RESID_SECURITY_VALIDITY_PERIOD = Valid from %1 to %2 - RESID_SECURITY_CERTIF_VERSION_LBL = Version: - RESID_SECURITY_PROP_ALIAS_LBL = Alias Name: - RESID_SECURITY_ISSUED_TO_LBL = Issued To: - RESID_SECURITY_ISSUED_BY_LBL = Issued By: - RESID_SECURITY_VALIDITY_LBL = Validity: - RESID_SECURITY_ALGORITHM_LBL = Algorithm: - RESID_SECURITY_KEY_ENTRY = Key - RESID_SECURITY_ADD_CERT_DLG_TITLE = Add Certificate - RESID_SECURITY_RENAME_CERT_DLG_TITLE = Rename Certificate - RESID_SECURITY_CERTIFICATE_ALIAS = Alias Name: - RESID_SECURITY_SEC_MSG = Security Message - RESID_SECURITY_TRUSTED_CERTIFICATE = Trusted Certificate - RESID_SECURITY_CERTIFICATE_FILE = Security Certificate File: - RESID_SECURITY_BROWSE = Browse... - RESID_SECURITY_ADD_LBL = Add... - RESID_SECURITY_REMOVE_LBL = Remove - RESID_SECURITY_RENAME_LBL = Rename... - RESID_SECURITY_PREF_ALIAS_NAME = Alias - RESID_SECURITY_PREF_ISSUED_TO = Issued To - RESID_SECURITY_PREF_ISSUED_FROM = Issued By - RESID_SECURITY_PREF_EXPIRES = Expiration Date - - RESID_SECURITY_KEY_IO_ERROR_ = File not found \n%1. - RESID_SECURITY_KEY_STORE_ERROR_ = Key store exception, for operations dealing with key store in\n%1. - RESID_SECURITY_KEYSTORE_SAVE_ERROR_ = Unable to persist key store. - RESID_SECURITY_IO_SAVE_ERROR_ = A input-output exception occurred while saving key store \n%1. - RESID_SECURITY_CERTIFICATE_STORE_ERROR_ = One or more certificates in the\n%1\nkey store could not be stored. - RESID_SECURITY_UNINIT_KEYSTORE_ERROR_ = Keystore %1 \nhas not been initialized. -# FIXME MISSING STRINGS START - RESID_SECURITY_ALGORITHM_ERROR_ = The algorithm used to check the integrity of the key store\n%1\ncannot be found. - RESID_SECURITY_LOAD_KEYSTORE_ERROR_ = Failed to load key store. - RESID_SECURITY_KEY_LOAD_ERROR_ = One or more certificates in the\n%1\nkey store could not be loaded. - RESID_SECURITY_INITIALIZE_ERROR_ = Unable to initialize key store \n%1. - RESID_SECURITY_SECURITY_PROVIDER_ERROR_ = Requested security provider not available. -# FIXME MISSING STRINGS END - RESID_SECURITY_CERTIFICATE_EXC_ = A certificate exception occurred while loading the file\n%1 - RESID_SECURITY_LOAD_IO_EXC_ = A input-output exception occurred while loading the file\n%1 - RESID_SECURITY_CERTIFICATE_LOAD_EXC_ = Unable to load certificate. - RESID_SECURITY_PREF_SEC_DESCRIPTION = Create, remove or edit Security Certificate definitions. - RESID_SECURITY_PROPERTIES_LBL = Properties... - - RESID_SECURITY_TRUST_WIZ_CERTIFICATE_TITLE = Untrusted Certificate - RESID_SECURITY_TRUST_WIZ_CERTIFICATE_DESC = An untrusted certificate has been received from host.\n If you want to start trusting this certificate, continue to the next page. - - RESID_SECURITY_TRUST_WIZ_ALIAS_TITLE = Certificate Alias - RESID_SECURITY_TRUST_WIZ_ALIAS_DESC = Specify an alias to use when referencing the new certificate. - - RESID_SECURITY_TRUST_IMPORT_CERTIFICATE_WIZARD = Import Host Certificate - RESID_SECURITY_CERTIFICATE_INFORMATION = Certificate Information: - diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertPropertiesDialog.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertPropertiesDialog.java deleted file mode 100644 index e76241770..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertPropertiesDialog.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format - *******************************************************************************/ - - -package org.eclipse.rse.internal.dstore.security.preference; - - -import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; -import org.eclipse.rse.internal.dstore.security.widgets.CertificatePropertiesForm; -import org.eclipse.rse.ui.dialogs.SystemPromptDialog; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - - - - -public class CertPropertiesDialog extends SystemPromptDialog -{ - private Object _cert; - - public CertPropertiesDialog(Shell parentShell, Object cert) - { - super(parentShell, UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_PROP_TITLE); - _cert = cert; - } - - - - public Control getInitialFocusControl() - { - return getOkButton(); - } - - protected Control createInner(Composite parent) - { - CertificatePropertiesForm form = new CertificatePropertiesForm(getShell(), _cert, true); - return form.createContents(parent); - } - - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertTableContentProvider.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertTableContentProvider.java deleted file mode 100644 index dac689e7a..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertTableContentProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.preference; -import java.util.ArrayList; - -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; - -public class CertTableContentProvider implements IStructuredContentProvider -{ - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements(Object element) { - if (element instanceof ArrayList) - return ((ArrayList)element).toArray(); - - return new Object[0]; - } - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertTableLabelProvider.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertTableLabelProvider.java deleted file mode 100644 index 4e652a808..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertTableLabelProvider.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.preference; - - - -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; - - - -public class CertTableLabelProvider - extends LabelProvider - implements ITableLabelProvider - { - - public Image getColumnImage(Object element, int columnIndex) - { - if (columnIndex == 0) - { - if (element instanceof Element) - { - return ((Element)element).getImage(); - } - } - return null; - } - /** - * @see ITableLabelProvider#getColumnText(Object, int) - */ - public String getColumnText(Object element, int columnIndex) - { - if (element instanceof Element) - { - X509CertificateElement myTableElement = (X509CertificateElement) element; - - switch (columnIndex) - { - case 0: // alias - return myTableElement.getAlias(); - case 1: // issued to - { - String name = myTableElement.getSubjectName(); - if (name == null || name.length() == 0) - { - name = myTableElement.getSubjectUnit(); - if (name == null || name.length() == 0) - { - name = myTableElement.getSubjectOrg(); - } - } - return name; - } - case 2: // issuer - { - String name = myTableElement.getIssuerName(); - if (name == null || name.length() == 0) - { - name = myTableElement.getIssuerUnit(); - if (name == null || name.length() == 0) - { - name = myTableElement.getIssuerOrg(); - } - } - - return name; - } - case 3: // expires - return myTableElement.getNotAfter(); - - default: - break; - } - } - return ""; //$NON-NLS-1$ - } - - - - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertTableSorter.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertTableSorter.java deleted file mode 100644 index 717787764..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/CertTableSorter.java +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.preference; - - -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.TableColumn; - -public class CertTableSorter -extends ViewerSorter -{ - private final static String ASC_SYMBOL = "^"; //$NON-NLS-1$ - private final static String DESC_SYMBOL = "."; //$NON-NLS-1$ - - private TableViewer tableViewer; - private int currentColumn; - private boolean asc; - private boolean addDirectionSymbol; - - private SelectionListener headerListener; - - public CertTableSorter(TableViewer tableViewer, int defaultColumn, boolean asc, boolean addDirectionSymbol, boolean addHeaderListener) - { - this.tableViewer = tableViewer; - this.addDirectionSymbol = addDirectionSymbol; - - setSort(defaultColumn, asc); - - tableViewer.setSorter(this); - if(addHeaderListener) - addColumnHeaderListeners(); - } - - public static void setTableSorter(TableViewer tableViewer, int defaultColumn, boolean asc) - { - new CertTableSorter(tableViewer, defaultColumn, asc, false, true); - } - - private void initializeHeaderListener() - { - headerListener = new SelectionListener() - { - public void widgetDefaultSelected(SelectionEvent e) - { - } - - public void widgetSelected(SelectionEvent e) - { - String text = null; - - if(currentColumn >= 0) - { - TableColumn currentTableColumn = tableViewer.getTable().getColumn(currentColumn); - if(addDirectionSymbol && (currentTableColumn != null)) - { - text = currentTableColumn.getText(); - if((text != null) && (text.startsWith(ASC_SYMBOL) || text.startsWith(DESC_SYMBOL))) - { - text = text.substring(1); - currentTableColumn.setText(text); - } - } - } - - TableColumn tableColumn = (TableColumn)e.widget; - text = tableColumn.getText(); - - int index = tableViewer.getTable().indexOf(tableColumn); - if(index == currentColumn) - { - asc = !asc; - } - else - { - asc = true; - currentColumn = index; - } - - if(addDirectionSymbol && (text != null)) - { - if(asc) - text = ASC_SYMBOL + text; - else - text = DESC_SYMBOL + text; - - tableColumn.setText(text); - } - - tableViewer.getTable().setRedraw(false); - tableViewer.refresh(); - tableViewer.getTable().setRedraw(true); - } - }; - } - - public void addColumnHeaderListeners() - { - for(int i=0, length=tableViewer.getTable().getColumnCount(); i<length; i++) - { - TableColumn column = tableViewer.getTable().getColumn(i); - - column.removeSelectionListener(getHeaderListener()); - column.addSelectionListener(getHeaderListener()); - } - } - - public void setSort(int currentColumn) - { - this.currentColumn = currentColumn; - } - - public void setSort(int currentColumn, boolean asc) - { - setSort(currentColumn); - setSort(asc); - } - public void setSort(boolean asc) - { - this.asc = asc; - } - - public int getCurrentColumn() - { - return currentColumn; - } - - public SelectionListener getHeaderListener() - { - if(headerListener == null) - initializeHeaderListener(); - - return headerListener; - } - - public boolean isAsc() - { - return asc; - } - - public int compare(Viewer viewer, Object e1, Object e2) - { - if(viewer != tableViewer) - return super.compare(viewer, e1, e2); - - int ret = compareAsc(e1, e2); - return (asc?ret:-1*ret); - } - - protected int compareAsc(Object e1, Object e2) - { - int defaultRet = super.compare(tableViewer, e1, e2); - - Object o = tableViewer.getLabelProvider(); - if((o == null) || (!(o instanceof ITableLabelProvider))) - return defaultRet; - - ITableLabelProvider labelProvider = (ITableLabelProvider)o; - String value1 = labelProvider.getColumnText(e1, currentColumn); - String value2 = labelProvider.getColumnText(e2, currentColumn); - - if(value1 == null) - return -1; - - if(value2 == null) - return 1; - - return compareAsc(value1, value2); - } - - protected int compareAsc(String value1, String value2) - { - return value1.compareToIgnoreCase(value2); - } -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/Element.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/Element.java deleted file mode 100644 index 2b8075d17..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/Element.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.preference; - -import org.eclipse.rse.internal.dstore.security.ImageRegistry; -import org.eclipse.swt.graphics.Image; - - - -public abstract class Element -{ - String _alias; - Object _value; - - public Element(String alias, String value) - { - this._alias = alias; - this._value = value; - } - - public String getAlias() - { - return _alias; - } - - public void setAlias(String text) - { - this._alias = text; - } - - public Image getImage() - { - return ImageRegistry.getImage(ImageRegistry.IMG_CERTIF_FILE); - } - - public abstract String getType(); - public abstract String getAlgorithm(); - public abstract String getFormat(); - public abstract Object getCert(); -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/KeyElement.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/KeyElement.java deleted file mode 100644 index a3f72c5d3..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/KeyElement.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.preference; - - -import java.security.Key; - -import org.eclipse.rse.internal.dstore.security.ImageRegistry; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; -import org.eclipse.swt.graphics.Image; - - - -public class KeyElement extends Element -{ - private Key _key; - public KeyElement(String alias, String value, Key key) - { - super(alias, value); - _key = key; - } - - public String getType() - { - return UniversalSecurityProperties.RESID_SECURITY_KEY_ENTRY; - } - - public String getAlgorithm() - { - return _key.getAlgorithm(); - } - - public String getFormat() - { - return _key.getFormat(); - } - - public Image getImage() - { - return org.eclipse.rse.internal.dstore.security.ImageRegistry.getImage(ImageRegistry.IMG_CERTIF_FILE); - } - - public Object getCert() - { - return _key; - } -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/KeyPropertiesDialog.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/KeyPropertiesDialog.java deleted file mode 100644 index 5ca24cde7..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/KeyPropertiesDialog.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.preference; - -import org.eclipse.swt.widgets.Shell; - -public class KeyPropertiesDialog extends CertPropertiesDialog -{ - public KeyPropertiesDialog(Shell parentShell, KeyElement element) - { - super(parentShell, element.getCert()); - } - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/NewCertDialog.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/NewCertDialog.java deleted file mode 100644 index 8d1b8c07e..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/NewCertDialog.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.preference; - - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.security.KeyStoreException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; - -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityPlugin; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; -import org.eclipse.rse.internal.dstore.security.util.GridUtil; -import org.eclipse.rse.internal.dstore.security.util.StringModifier; -import org.eclipse.rse.internal.dstore.security.widgets.CertificateForm; -import org.eclipse.rse.ui.dialogs.SystemPromptDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; - -public class NewCertDialog extends SystemPromptDialog implements Listener -{ - - /** - * - */ - private final UniversalSecurityPreferencePage page; - private CertificateForm _certForm; - private Certificate _certificate; - private Shell _shell; - - public NewCertDialog(UniversalSecurityPreferencePage page, Shell shell){ - super(shell, UniversalSecurityProperties.RESID_SECURITY_ADD_CERT_DLG_TITLE); - this.page = page; - _shell = shell; - } - - public Control getInitialFocusControl() - { - return _certForm.getInitialFocusControl(); - } - - protected Control createInner(Composite parent) - { - Composite content = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - GridData data = GridUtil.createFill(); - layout.numColumns = 1; - content.setLayout(layout); - content.setLayoutData(data); - - _certForm = new CertificateForm(_shell, getMessageLine()); - _certForm.createContents(content); - _certForm.registerListener(this); - return content; - } - - protected Control createButtonBar(Composite parent) - { - Control control = super.createButtonBar(parent); - - getOkButton().setEnabled(false); - return control; - } - - protected boolean processOK(){ - - try{ - _certificate = _certForm.loadCertificate(this.page._keyStore); - } - catch(FileNotFoundException e){ - - String text = UniversalSecurityProperties.RESID_SECURITY_KEY_IO_ERROR_; - text = StringModifier.change(text, "%1", _certForm.getPath()); //$NON-NLS-1$ - String msg = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_; - - Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,e); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - return false; - - } - catch(IOException e){ - - String text = UniversalSecurityProperties.RESID_SECURITY_LOAD_IO_EXC_; - text = StringModifier.change(text, "%1", _certForm.getPath()); //$NON-NLS-1$ - - text = StringModifier.change(text, "%1", UniversalSecurityPlugin.getKeyStoreLocation()); //$NON-NLS-1$ - String msg = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_; - - Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,e); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - return false; - - } - catch(CertificateException exc){ - - String text = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_EXC_; - text = StringModifier.change(text, "%1", _certForm.getPath()); //$NON-NLS-1$ - - String msg = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_; - - Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,exc); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - return false; - - } - catch(KeyStoreException exc){ - String text = UniversalSecurityProperties.RESID_SECURITY_KEY_STORE_ERROR_; - text = StringModifier.change(text, "%1", UniversalSecurityPlugin.getKeyStoreLocation()); //$NON-NLS-1$ - String msg = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_; - - Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,exc); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - return false; - } - - if (_certificate instanceof X509Certificate) - { - X509CertificateElement elem = new X509CertificateElement(_certForm.getAliasName(), UniversalSecurityProperties.RESID_SECURITY_TRUSTED_CERTIFICATE, - (X509Certificate) _certificate); - this.page._tableItems.add(elem); - } - - return true; - } - - public void handleEvent(Event e){ - getButton(IDialogConstants.OK_ID).setEnabled(_certForm.validateDialog()); - } - - - public Certificate getCertificate(){ - return _certificate; - } - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/RenameCertDialog.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/RenameCertDialog.java deleted file mode 100644 index 52576b82e..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/RenameCertDialog.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format - *******************************************************************************/ - - -package org.eclipse.rse.internal.dstore.security.preference; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; -import org.eclipse.rse.internal.dstore.security.util.GridUtil; -import org.eclipse.rse.ui.dialogs.SystemPromptDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -public class RenameCertDialog extends SystemPromptDialog implements Listener{ - - - private Text txtName; - String newAlias; - private String oldAlias; - - public RenameCertDialog(UniversalSecurityPreferencePage page, Shell shell, String oldValue) - { - super(shell, UniversalSecurityProperties.RESID_SECURITY_RENAME_CERT_DLG_TITLE); - oldAlias = oldValue; - } - - public Control getInitialFocusControl() - { - return txtName; - } - - protected Control createInner(Composite parent) - { - - Composite content = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - GridData data = GridUtil.createFill(); - data.widthHint = 350; - layout.numColumns = 2; - content.setLayout(layout); - content.setLayoutData(data); - - Label lblName = new Label(content, SWT.NONE); - lblName.setText(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_ALIAS); - - txtName = new Text(content, SWT.BORDER); - txtName.setText(oldAlias); - txtName.selectAll(); - txtName.addListener(SWT.Modify, this); - - data = GridUtil.createHorizontalFill(); - data.widthHint = 200; - txtName.setLayoutData(data); - - return content; - } - - private void validateDialog(){ - if(txtName.getText().trim().length()==0) - getButton(IDialogConstants.OK_ID).setEnabled(false); - else - getButton(IDialogConstants.OK_ID).setEnabled(true); - } - - public void handleEvent(Event e){ - if(e.widget.equals(txtName)) - validateDialog(); - } - - protected Control createButtonBar(Composite parent) { - Control control = super.createButtonBar(parent); - validateDialog(); - return control; - - } - - public String getNewAlias() - { - return newAlias; - } - - protected boolean processOK() - { - newAlias = txtName.getText(); - return super.processOK(); - } - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/UniversalSecurityPreferencePage.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/UniversalSecurityPreferencePage.java deleted file mode 100644 index dae03012a..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/UniversalSecurityPreferencePage.java +++ /dev/null @@ -1,504 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - [232131] fix minor layout problems along with date formats - * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.preference; - - -import java.io.IOException; -import java.security.Key; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.UnrecoverableKeyException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Iterator; - -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.dstore.core.util.ssl.DStoreKeyStore; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.jface.viewers.ColumnPixelData; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.window.Window; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityPlugin; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; -import org.eclipse.rse.internal.dstore.security.util.GridUtil; -import org.eclipse.rse.internal.dstore.security.util.StringModifier; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -public class UniversalSecurityPreferencePage extends PreferencePage implements - IWorkbenchPreferencePage, Listener, SelectionListener -{ - - private TableViewer _viewer; - - ArrayList _tableItems = new ArrayList(); - - private Button _addButton; - - private Button _removeButton; - - private Button _renameButton; - - private Button _propertiesButton; - - KeyStore _keyStore; - - public UniversalSecurityPreferencePage() - { - super(); - setPreferenceStore(UniversalSecurityPlugin.getDefault() - .getPreferenceStore()); - } - - protected Control createContents(Composite parent) - { - Composite composite = SystemWidgetHelpers.createComposite(parent, 1); - - GridLayout layout = new GridLayout(); - layout.marginWidth = 5; - layout.verticalSpacing = 10; - layout.numColumns = 1; - composite.setLayout(layout); - composite.setLayoutData(GridUtil.createFill()); - - Text label = new Text(composite, SWT.READ_ONLY); - label.setBackground(composite.getBackground()); - label.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_SEC_DESCRIPTION); - GridData data = new GridData(); - data.horizontalSpan = 2; - label.setLayoutData(data); - - createTableViewer(composite); - - Composite buttons = new Composite(composite, SWT.NONE); - data = new GridData(GridData.FILL_HORIZONTAL); - buttons.setLayoutData(data); - layout = new GridLayout(); - layout.numColumns = 1; - buttons.setLayout(layout); - - createButtons(buttons); - initializeValues(); - - SystemWidgetHelpers.setCompositeHelp(parent, RSEUIPlugin.HELPPREFIX + "ssls0000"); //$NON-NLS-1$ - return composite; - } - - private void createTableViewer(Composite parent) - { - // Create the table viewer. - _viewer = new TableViewer(parent, SWT.BORDER | SWT.SINGLE - | SWT.FULL_SELECTION); - - // Create the table control. - Table table = _viewer.getTable(); - table.setHeaderVisible(true); - table.setLinesVisible(true); - GridData data = GridUtil.createFill(); - data.heightHint = 50; - table.setLayoutData(data); - - TableLayout tableLayout = new TableLayout(); - - - TableColumn aliasColumn = new TableColumn(table, SWT.LEFT); - aliasColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_ALIAS_NAME); - tableLayout.addColumnData(new ColumnPixelData(100)); - - TableColumn toColumn = new TableColumn(table, SWT.LEFT); - toColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_TO); - tableLayout.addColumnData(new ColumnPixelData(150)); - - TableColumn frmColumn = new TableColumn(table, SWT.LEFT); - frmColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_FROM); - tableLayout.addColumnData(new ColumnPixelData(150)); - - TableColumn expColumn = new TableColumn(table, SWT.LEFT); - expColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_EXPIRES); - tableLayout.addColumnData(new ColumnPixelData(150)); - table.setLayout(tableLayout); - - // Adjust the table viewer. - String[] properties = new String[] {"STRING", "STRING", "STRING", "STRING"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - _viewer.setColumnProperties(properties); - _viewer.setContentProvider(new CertTableContentProvider()); - _viewer.setLabelProvider(new CertTableLabelProvider()); - _viewer.getTable().addSelectionListener(this); - - CertTableSorter.setTableSorter(_viewer, 0, true); - } - - private void createButtons(Composite parent) - { - Composite buttonComposite = SystemWidgetHelpers.createComposite(parent, 4); - - _addButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityProperties.RESID_SECURITY_ADD_LBL, this); - - - _removeButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityProperties.RESID_SECURITY_REMOVE_LBL, this); - _removeButton.setEnabled(false); - - _renameButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityProperties.RESID_SECURITY_RENAME_LBL, this); - _renameButton.setEnabled(false); - - _propertiesButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityProperties.RESID_SECURITY_PROPERTIES_LBL, this); - _propertiesButton.setEnabled(false); - } - - - /** - * @see IWorkbenchPreferencePage#init(IWorkbench) - */ - public void init(IWorkbench workbench) - { - } - - /** - * @see PreferencePage#performDefaults() - */ - protected void performDefaults() - { - super.performDefaults(); - - } - - /** - * @see PreferencePage#performOk() - */ - public boolean performOk() - { - - String storePath = UniversalSecurityPlugin.getKeyStoreLocation(); - String passw = UniversalSecurityPlugin.getKeyStorePassword(); - try - { - - DStoreKeyStore.persistKeyStore(_keyStore, storePath, passw); - - } - catch (IOException e) - { - - String text = UniversalSecurityProperties.RESID_SECURITY_IO_SAVE_ERROR_; - text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$ - - text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$ - String msg = UniversalSecurityProperties.RESID_SECURITY_KEYSTORE_SAVE_ERROR_; - - Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, - IStatus.ERROR, text, e); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - return false; - - } - catch (CertificateException exc) - { - - String text = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_STORE_ERROR_; - text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$ - String msg = UniversalSecurityProperties.RESID_SECURITY_KEYSTORE_SAVE_ERROR_; - - Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, - IStatus.ERROR, text, exc); - ErrorDialog.openError(UniversalSecurityPlugin - .getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - return false; - - } - catch (KeyStoreException exc) - { - String text = UniversalSecurityProperties.RESID_SECURITY_UNINIT_KEYSTORE_ERROR_; - text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$ - .getKeyStoreLocation()); - String msg = UniversalSecurityProperties.RESID_SECURITY_KEYSTORE_SAVE_ERROR_; - - Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, - IStatus.ERROR, text, exc); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - return false; - - } - catch (NoSuchAlgorithmException exc2) - { - String text = UniversalSecurityProperties.RESID_SECURITY_ALGORITHM_ERROR_; - text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$ - .getKeyStoreLocation()); - String msg = UniversalSecurityProperties.RESID_SECURITY_KEYSTORE_SAVE_ERROR_; - - Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, - IStatus.ERROR, text, exc2); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - return false; - - } - return true; - - } - - /** - * Loads certificates from the key store. - */ - private void initializeValues() - { - - String storePath = UniversalSecurityPlugin.getKeyStoreLocation(); - String passw = UniversalSecurityPlugin.getKeyStorePassword(); - // String passw = "dstore"; - - try - { - _keyStore = DStoreKeyStore.getKeyStore(storePath, passw); - - Enumeration aliases = _keyStore.aliases(); - - while (aliases.hasMoreElements()) - { - String alias = (String) (aliases.nextElement()); - /* The alias may be either a key or a certificate */ - java.security.cert.Certificate cert = _keyStore - .getCertificate(alias); - if (cert != null) - { - if (cert instanceof X509Certificate) - { - X509CertificateElement elem = new X509CertificateElement( - alias, - UniversalSecurityProperties.RESID_SECURITY_TRUSTED_CERTIFICATE, - (X509Certificate) cert); - _tableItems.add(elem); - } - } - else - { - try - { - Key key = _keyStore.getKey(alias, passw.toCharArray()); - KeyElement elem = new KeyElement(alias, - UniversalSecurityProperties.RESID_SECURITY_KEY_ENTRY, - key); - _tableItems.add(elem); - } - catch (UnrecoverableKeyException e) - { - /* Probably ignore the key in this case */ - } - } - - } - } - catch (IOException e) - { - - String text = UniversalSecurityProperties.RESID_SECURITY_LOAD_IO_EXC_; - text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$ - String msg = UniversalSecurityProperties.RESID_SECURITY_LOAD_KEYSTORE_ERROR_; - - Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, - IStatus.ERROR, text, e); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - - } - catch (CertificateException exc) - { - - String text = UniversalSecurityProperties.RESID_SECURITY_KEY_LOAD_ERROR_; - text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$ - String msg = UniversalSecurityProperties.RESID_SECURITY_LOAD_KEYSTORE_ERROR_; - - Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, - IStatus.ERROR, text, exc); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - - } - catch (KeyStoreException exc) - { - - String text = UniversalSecurityProperties.RESID_SECURITY_INITIALIZE_ERROR_; - text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$ - .getKeyStoreLocation()); - String msg = UniversalSecurityProperties.RESID_SECURITY_LOAD_KEYSTORE_ERROR_; - - Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, - IStatus.ERROR, text, exc); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - - } - catch (NoSuchProviderException exc2) - { - - String text = UniversalSecurityProperties.RESID_SECURITY_SECURITY_PROVIDER_ERROR_; - String msg = UniversalSecurityProperties.RESID_SECURITY_INITIALIZE_ERROR_; - msg = StringModifier.change(msg, "%1", UniversalSecurityPlugin //$NON-NLS-1$ - .getKeyStoreLocation()); - Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, - IStatus.ERROR, text, exc2); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - - } - catch (NoSuchAlgorithmException exc2) - { - String text = UniversalSecurityProperties.RESID_SECURITY_ALGORITHM_ERROR_; - text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$ - .getKeyStoreLocation()); - String msg = UniversalSecurityProperties.RESID_SECURITY_LOAD_KEYSTORE_ERROR_; - - Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, - IStatus.ERROR, text, exc2); - ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err); - - } - - _viewer.setInput(_tableItems); - } - - public void handleEvent(Event event) - { - // TODO Auto-generated method stub - if (event.widget == _addButton) - { - NewCertDialog dlg = new NewCertDialog(this, getShell()); - dlg.open(); - - if (dlg.getReturnCode() == Window.OK) - { - _viewer.refresh(); - } - - } - else if (event.widget == _removeButton) - { - IStructuredSelection elem = (IStructuredSelection) _viewer.getSelection(); - if (elem.size() > 0) - { - Iterator i = elem.iterator(); - while (i.hasNext()) - { - try - { - Element current = (Element) i.next(); - _keyStore.deleteEntry(current.getAlias()); - _tableItems.remove(current); - } - catch (KeyStoreException e) - { - } - } - - _viewer.refresh(); - } - - } - else if (event.widget == _renameButton) - { - IStructuredSelection elem = (IStructuredSelection) _viewer - .getSelection(); - if (elem.size() == 1) - { - Element sel = (Element) elem.getFirstElement(); - RenameCertDialog dlg = new RenameCertDialog(this, getShell(), - sel.getAlias()); - dlg.open(); - - if (dlg.getReturnCode() == Window.OK) - { - try - { - DStoreKeyStore.addCertificateToKeyStore( - UniversalSecurityPreferencePage.this._keyStore, - (Certificate) sel.getCert(), dlg.getNewAlias()); - _keyStore.deleteEntry(sel.getAlias()); - sel.setAlias(dlg.getNewAlias()); - _viewer.refresh(); - } - catch (KeyStoreException e) - { - } - } - } - - } - else if (event.widget == _propertiesButton) - { - IStructuredSelection elem = (IStructuredSelection) _viewer - .getSelection(); - if (elem.size() == 1) - { - Element sel = (Element) elem.getFirstElement(); - CertPropertiesDialog dlg = null; - if (sel instanceof X509CertificateElement) - { - dlg = new X509CertificatePropertiesDialog(getShell(), (X509CertificateElement)sel); - } - else - { - dlg = new KeyPropertiesDialog(getShell(), (KeyElement)sel); - } - - dlg.open(); - - } - - } - - boolean sel = _viewer.getSelection().isEmpty(); - _renameButton.setEnabled(!sel); - _removeButton.setEnabled(!sel); - _propertiesButton.setEnabled(!sel); - } - - public void widgetSelected(SelectionEvent e) - { - // TODO Auto-generated method stub - boolean sel = _viewer.getSelection().isEmpty(); - _renameButton.setEnabled(!sel); - _removeButton.setEnabled(!sel); - _propertiesButton.setEnabled(!sel); - } - - public void widgetDefaultSelected(SelectionEvent e) - { - widgetSelected(e); - } - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/X509CertificateElement.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/X509CertificateElement.java deleted file mode 100644 index 0cf6b08c2..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/X509CertificateElement.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - use ICU for date formats - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.preference; - - -import java.security.cert.X509Certificate; -import java.util.Date; - -import com.ibm.icu.text.DateFormat; - - -public class X509CertificateElement extends Element -{ - public static int CERT_NAME = 0; - public static int CERT_UNIT = 1; - public static int CERT_ORGANIZATION = 2; - public static int CERT_CITY = 3; - public static int CERT_PROVINCE = 4; - public static int CERT_COUNTRY = 5; - - - private X509Certificate _cert; - public X509CertificateElement(String alias, String value, X509Certificate cert) - { - super(alias, value); - _cert = cert; - } - - public String getType() - { - return _cert.getType(); - } - - public String getVersion() - { - return "V." + _cert.getVersion(); //$NON-NLS-1$ - } - - private String[] parse(String full) - { - StringBuffer result = new StringBuffer(); - char[] chars = full.toCharArray(); - boolean inQuotes = false; - for (int i = 0; i < chars.length; i++) - { - char c = chars[i]; - if (c == '\"') - { - inQuotes = !inQuotes; - } - else - { - if (c == ',') - { - if (!inQuotes) - { - c = ';'; - } - } - } - result.append(c); - } - return result.toString().split(";"); //$NON-NLS-1$ - } - - private String extract(String full, int index) - { - String[] pairs = parse(full); - String match = pairs[index].split("=")[1]; //$NON-NLS-1$ - return match; - } - - - public String getIssuerDN() - { - String full = _cert.getIssuerDN().getName(); - return full; - } - - public String getIssuerName() - { - String full = _cert.getIssuerDN().getName(); - return extract(full, CERT_NAME); - } - - public String getIssuerUnit() - { - String full = _cert.getIssuerDN().getName(); - return extract(full, CERT_UNIT); - } - - public String getIssuerOrg() - { - String full = _cert.getIssuerDN().getName(); - return extract(full, CERT_ORGANIZATION); - } - - public String getIssuerCity() - { - String full = _cert.getIssuerDN().getName(); - return extract(full, CERT_CITY); - } - - public String getIssuerProvince() - { - String full = _cert.getIssuerDN().getName(); - return extract(full, CERT_PROVINCE); - } - - public String getIssuerCountry() - { - String full = _cert.getIssuerDN().getName(); - return extract(full, CERT_COUNTRY); - } - - public String getSubjectDN() - { - String full = _cert.getSubjectDN().getName(); - return full; - } - - public String getSubjectName() - { - String full = _cert.getSubjectDN().getName(); - return extract(full, CERT_NAME); - } - - public String getSubjectUnit() - { - String full = _cert.getSubjectDN().getName(); - return extract(full, CERT_UNIT); - } - - public String getSubjectOrg() - { - String full = _cert.getSubjectDN().getName(); - return extract(full, CERT_ORGANIZATION); - } - - public String getSubjectCity() - { - String full = _cert.getSubjectDN().getName(); - return extract(full, CERT_CITY); - } - - public String getSubjectProvince() - { - String full = _cert.getSubjectDN().getName(); - return extract(full, CERT_PROVINCE); - } - - public String getSubjectCountry() - { - String full = _cert.getSubjectDN().getName(); - return extract(full, CERT_COUNTRY); - } - - public String getNotBefore() - { - Date date = _cert.getNotBefore(); - String result = DateFormat.getDateInstance(DateFormat.LONG).format(date); - return result; - } - - public String getNotAfter() - { - Date date = _cert.getNotAfter(); - String result = DateFormat.getDateInstance(DateFormat.LONG).format(date); - return result; - } - - public String getExpirationDate() - { - return getNotAfter(); - } - - - public String getSigAlgName() - { - return _cert.getSigAlgName(); - } - - public String getSerialNumber() - { - return _cert.getSerialNumber().toString(); - } - - public String getAlgorithm() - { - return _cert.getPublicKey().getAlgorithm(); - } - - public String getFormat() - { - return _cert.getPublicKey().getFormat(); - } - - public Object getCert() - { - return _cert; - } -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/X509CertificatePropertiesDialog.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/X509CertificatePropertiesDialog.java deleted file mode 100644 index 1cdb60ec8..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/preference/X509CertificatePropertiesDialog.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.preference; - -import org.eclipse.swt.widgets.Shell; - -public class X509CertificatePropertiesDialog extends CertPropertiesDialog -{ - public X509CertificatePropertiesDialog(Shell parentShell, X509CertificateElement element) - { - super(parentShell, element.getCert()); - } - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/util/GridUtil.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/util/GridUtil.java deleted file mode 100644 index 47a415d01..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/util/GridUtil.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.util; - -import org.eclipse.swt.layout.GridData; - -/** - * A utility class to create convenient grid data objects. - */ -public class GridUtil -{ - /** - * GridUtil constructor comment. - */ - public GridUtil() - { - super(); - } - - /** - * Creates a grid data object that occupies vertical and horizontal space. - */ - static public GridData createFill() - { - GridData gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - gd.verticalAlignment = GridData.FILL; - gd.grabExcessVerticalSpace = true; - return gd; - } - - /** - * Creates a grid data object that occupies horizontal space. - */ - static public GridData createHorizontalFill() - { - GridData gd = new GridData(); - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - return gd; - } - - /** - * Creates a grid data object that occupies vertical space. - */ - static public GridData createVerticalFill() - { - GridData gd = new GridData(); - gd.verticalAlignment = GridData.FILL; - gd.grabExcessVerticalSpace = true; - return gd; - } -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/util/StringModifier.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/util/StringModifier.java deleted file mode 100644 index ba7934865..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/util/StringModifier.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.util; -/** - * This class provides static methods for some of the - * very used IString operations - */ - -public class StringModifier -{ - // change all occurrences of oldPat to newPat - public static String change(String in, String oldPat, String newPat) - { - if (oldPat.length() == 0) - return in; - if (oldPat.length() == 1 && newPat.length() == 1) - return in.replace(oldPat.charAt(0), newPat.charAt(0)); - - int lastIndex = 0; - int newIndex = 0; - StringBuffer newString = new StringBuffer(); - for(;;) - { - newIndex = in.indexOf(oldPat, lastIndex); - if (newIndex != -1) - { - newString.append(in.substring(lastIndex, newIndex) + newPat); - lastIndex = newIndex + oldPat.length(); - } - else - { - newString.append(in.substring(lastIndex)); - break; - } - } - return newString.toString(); - } - } diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/widgets/CertificateForm.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/widgets/CertificateForm.java deleted file mode 100644 index 385f7da16..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/widgets/CertificateForm.java +++ /dev/null @@ -1,186 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - [230815] fix layout problems with long labels - * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format - *******************************************************************************/ - - -package org.eclipse.rse.internal.dstore.security.widgets; - -import java.io.File; -import java.io.IOException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.util.ArrayList; - -import org.eclipse.dstore.core.util.ssl.DStoreKeyStore; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; -import org.eclipse.rse.internal.dstore.security.util.GridUtil; -import org.eclipse.rse.ui.SystemBaseForm; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - - -public class CertificateForm extends SystemBaseForm -{ - private Text _pathField; - private Text _aliasField; - private String _aliasStr; - private String _pathStr; - private ArrayList listenerList; - - private Button _browseButton; - public Shell _shell; - - public CertificateForm(Shell shell, ISystemMessageLine msgLine) - { - super(shell, msgLine); - listenerList = new ArrayList(); - _shell = shell; - } - - public Control getInitialFocusControl() - { - return _pathField; - } - - public Control createContents(Composite c){ - - GridData data; - Composite nameGroup = new Composite(c, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - data = GridUtil.createFill(); - nameGroup.setLayoutData(data); - nameGroup.setLayout(layout); - - Label lblPath = new Label(nameGroup, SWT.NONE); - lblPath.setText(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_FILE); - _pathField = new Text(nameGroup, SWT.BORDER); - _pathField.setLayoutData(GridUtil.createHorizontalFill()); - ((GridData)_pathField.getLayoutData()).widthHint = 150; - _pathField.setText(""); //$NON-NLS-1$ - - _browseButton = new Button(nameGroup, SWT.PUSH); - _browseButton.setText(UniversalSecurityProperties.RESID_SECURITY_BROWSE); - - _browseButton.addListener(SWT.Selection, this); - - Label lblName = new Label(nameGroup, SWT.NONE); - lblName.setText(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_ALIAS); - _aliasField = new Text(nameGroup, SWT.BORDER); - _aliasField.setText(""); //$NON-NLS-1$ - - _aliasField.setLayoutData(GridUtil.createHorizontalFill()); - - _aliasField.addListener(SWT.Modify, this); - _pathField.addListener(SWT.Modify, this); - - return _pathField; - - } - - /** - * Handle all events and enablements for widgets in this dialog - * - * @param event Event - */ - public void handleEvent(Event event) { - - if(event.widget == _browseButton){ - showFileDialog(); - NotifyListeners(event); - } - if(event.widget==_aliasField || event.widget==_pathField){ - //setButtonState(); - _pathStr = _pathField.getText(); - _aliasStr = _aliasField.getText(); - NotifyListeners(event); - } - - } - - public void NotifyListeners(Event event){ - for(int i=0;i<listenerList.size();i++){ - ((Listener)listenerList.get(i)).handleEvent(event); - } - } - - public boolean validateDialog(){ - return (_aliasField.getText().trim().length()>0 && _pathField.getText().trim().length()>0); - } - - private void showFileDialog(){ - String currentSource = _pathField.getText(); - - FileDialog dlg = new FileDialog(_shell, SWT.OPEN); - - dlg.setFileName(currentSource); - dlg.setFilterExtensions(new String[]{"*.cer", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ - - String source = dlg.open(); - - if(source!=null) - { - _pathField.setText(source); - File f = new File(source); - String alias = f.getName(); - int dotIndex = alias.indexOf('.'); - if (dotIndex > 0) - { - alias = alias.substring(0, dotIndex); - } - _aliasField.setText(alias); - } - - } - - public Certificate loadCertificate(KeyStore ks) throws IOException, CertificateException, KeyStoreException { - - - Certificate fCertificate = DStoreKeyStore.loadCertificate(getPath()); - DStoreKeyStore.addCertificateToKeyStore(ks, fCertificate, getAliasName()); - return fCertificate; - - } - - public void registerListener(Listener listener){ - listenerList.add(listener); - - } - public String getAliasName() - { - return _aliasStr; - } - - public String getPath() - { - return _pathStr; - } - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/widgets/CertificatePropertiesForm.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/widgets/CertificatePropertiesForm.java deleted file mode 100644 index f6c1eeca1..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/widgets/CertificatePropertiesForm.java +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David Dykstal (IBM) - [231913] increasing width of form to accommodate translation - * David Dykstal (IBM) - [232131] using ICU for DateFormat - * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.widgets; - -import java.security.Key; -import java.security.cert.X509Certificate; - -import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; -import org.eclipse.rse.internal.dstore.security.util.GridUtil; -import org.eclipse.rse.internal.dstore.security.util.StringModifier; -import org.eclipse.rse.ui.SystemBaseForm; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import com.ibm.icu.text.DateFormat; - -public class CertificatePropertiesForm extends SystemBaseForm -{ - private Object _certificate; - private String _alias; - private boolean _advanced; - - public CertificatePropertiesForm(Shell shell, Object certificate, String alias) - { - this(shell, certificate, alias, false); - } - - public CertificatePropertiesForm(Shell shell, Object certificate) - { - this(shell, certificate, false); - } - - public CertificatePropertiesForm(Shell shell, Object certificate, String alias, boolean advanced) - { - super(shell, null); - _certificate = certificate; - _alias = alias; - _advanced = advanced; - } - - public CertificatePropertiesForm(Shell shell, Object certificate, boolean advanced) - { - this(shell, certificate, null, advanced); - } - - - public Control createContents(Composite parent) - { - if (_advanced) - { - return createAdvancedContents(parent); - } - else - { - return createSimpleContents(parent); - } - } - - public Control createSimpleContents(Composite parent) - { - Composite content = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - GridData data = GridUtil.createFill(); - data.widthHint = 450; - //data.heightHint = 300; - layout.numColumns = 2; - content.setLayout(layout); - content.setLayoutData(data); - - if (_alias != null) - { - Label lblAlias = new Label(content, SWT.NONE); - lblAlias.setText(UniversalSecurityProperties.RESID_SECURITY_PROP_ALIAS_LBL); - data = new GridData(); - data.horizontalIndent = 5; - lblAlias.setLayoutData(data); - - Label lblAliasValue = new Label(content, SWT.NONE); - lblAliasValue.setText(_alias); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 5; - lblAliasValue.setLayoutData(data); - } - - Label lblVersion = new Label(content, SWT.NONE); - lblVersion.setText(UniversalSecurityProperties.RESID_SECURITY_CERTIF_VERSION_LBL); - data = new GridData(); - data.horizontalIndent = 5; - lblVersion.setLayoutData(data); - - Label lblVersionValue = new Label(content, SWT.NONE); - - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 5; - lblVersionValue.setLayoutData(data); - - Label lblIssuedTo = new Label(content, SWT.NONE); - lblIssuedTo.setText(UniversalSecurityProperties.RESID_SECURITY_ISSUED_TO_LBL); - data = new GridData(); - data.verticalAlignment = GridData.BEGINNING; - data.horizontalIndent = 5; - lblIssuedTo.setLayoutData(data); - - Text lblIssuedToValue = new Text(content, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP) ; - data = new GridData(GridData.FILL_HORIZONTAL); - data.heightHint = 60; - data.horizontalIndent = 5; - lblIssuedToValue.setLayoutData(data); - - Label lblIssuedBy = new Label(content, SWT.NONE); - lblIssuedBy.setText(UniversalSecurityProperties.RESID_SECURITY_ISSUED_BY_LBL); - data = new GridData(); - data.horizontalIndent = 5; - data.verticalAlignment = GridData.BEGINNING; - lblIssuedBy.setLayoutData(data); - - Text lblIssuedByValue = new Text(content, SWT.BORDER |SWT.READ_ONLY | SWT.WRAP); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 5; - data.heightHint = 60; - lblIssuedByValue.setLayoutData(data); - - Label lblValidity = new Label(content, SWT.NONE); - lblValidity.setText(UniversalSecurityProperties.RESID_SECURITY_VALIDITY_LBL); - data = new GridData(); - data.horizontalIndent = 5; - lblValidity.setLayoutData(data); - - Label lblValidityValue = new Label(content, SWT.NONE); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 5; - lblValidityValue.setLayoutData(data); - - Label lblAlgorithm = new Label(content, SWT.NONE); - lblAlgorithm.setText(UniversalSecurityProperties.RESID_SECURITY_ALGORITHM_LBL); - data = new GridData(); - data.horizontalIndent = 5; - lblAlgorithm.setLayoutData(data); - - Label lblAlgorithmValue = new Label(content, SWT.NONE); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 5; - lblAlgorithmValue.setLayoutData(data); - - if(_certificate instanceof X509Certificate){ - lblVersionValue.setText(((X509Certificate)_certificate).getType() + " V."+((X509Certificate)_certificate).getVersion()); //$NON-NLS-1$ - lblIssuedToValue.setText(((X509Certificate)_certificate).getSubjectDN().getName()); - lblIssuedByValue.setText(((X509Certificate)_certificate).getIssuerDN().getName()); - DateFormat df = DateFormat.getDateInstance(DateFormat.LONG); - - String validity = UniversalSecurityProperties.RESID_SECURITY_VALIDITY_PERIOD; - validity = StringModifier.change(validity,"%1", df.format(((X509Certificate)_certificate).getNotBefore())); //$NON-NLS-1$ - validity = StringModifier.change(validity,"%2", df.format(((X509Certificate)_certificate).getNotAfter())); //$NON-NLS-1$ - - lblValidityValue.setText(validity); - lblAlgorithmValue.setText(((X509Certificate)_certificate).getSigAlgName()); - }else if(_certificate instanceof Key){ - lblVersionValue.setText(((Key)_certificate).getFormat()); - lblAlgorithmValue.setText(((Key)_certificate).getAlgorithm()); - } - - return content; - } - - - public Control createAdvancedContents(Composite parent) - { - Composite content = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - GridData data = GridUtil.createFill(); - data.widthHint = 600; - //data.heightHint = 300; - layout.numColumns = 2; - content.setLayout(layout); - content.setLayoutData(data); - - if (_alias != null) - { - Label lblAlias = new Label(content, SWT.NONE); - lblAlias.setText(UniversalSecurityProperties.RESID_SECURITY_PROP_ALIAS_LBL); - data = new GridData(); - data.horizontalIndent = 5; - lblAlias.setLayoutData(data); - - Label lblAliasValue = new Label(content, SWT.NONE); - lblAliasValue.setText(_alias); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 5; - lblAliasValue.setLayoutData(data); - } - - Label lblVersion = new Label(content, SWT.NONE); - lblVersion.setText(UniversalSecurityProperties.RESID_SECURITY_CERTIF_VERSION_LBL); - data = new GridData(); - data.horizontalIndent = 5; - lblVersion.setLayoutData(data); - - Label lblVersionValue = new Label(content, SWT.NONE); - - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 5; - lblVersionValue.setLayoutData(data); - - Label lblIssuedTo = new Label(content, SWT.NONE); - lblIssuedTo.setText(UniversalSecurityProperties.RESID_SECURITY_ISSUED_TO_LBL); - data = new GridData(); - data.verticalAlignment = GridData.BEGINNING; - data.horizontalIndent = 5; - lblIssuedTo.setLayoutData(data); - - Text lblIssuedToValue = new Text(content, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP) ; - data = new GridData(GridData.FILL_HORIZONTAL); - data.heightHint = 60; - data.horizontalIndent = 5; - lblIssuedToValue.setLayoutData(data); - - Label lblIssuedBy = new Label(content, SWT.NONE); - lblIssuedBy.setText(UniversalSecurityProperties.RESID_SECURITY_ISSUED_BY_LBL); - data = new GridData(); - data.horizontalIndent = 5; - data.verticalAlignment = GridData.BEGINNING; - lblIssuedBy.setLayoutData(data); - - Text lblIssuedByValue = new Text(content, SWT.BORDER |SWT.READ_ONLY | SWT.WRAP); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 5; - data.heightHint = 60; - lblIssuedByValue.setLayoutData(data); - - Label lblValidity = new Label(content, SWT.NONE); - lblValidity.setText(UniversalSecurityProperties.RESID_SECURITY_VALIDITY_LBL); - data = new GridData(); - data.horizontalIndent = 5; - lblValidity.setLayoutData(data); - - Label lblValidityValue = new Label(content, SWT.NONE); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 5; - lblValidityValue.setLayoutData(data); - - Label lblAlgorithm = new Label(content, SWT.NONE); - lblAlgorithm.setText(UniversalSecurityProperties.RESID_SECURITY_ALGORITHM_LBL); - data = new GridData(); - data.horizontalIndent = 5; - lblAlgorithm.setLayoutData(data); - - Label lblAlgorithmValue = new Label(content, SWT.NONE); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 5; - lblAlgorithmValue.setLayoutData(data); - - if(_certificate instanceof X509Certificate){ - lblVersionValue.setText(((X509Certificate)_certificate).getType() + " V."+((X509Certificate)_certificate).getVersion()); //$NON-NLS-1$ - lblIssuedToValue.setText(((X509Certificate)_certificate).getSubjectDN().getName()); - lblIssuedByValue.setText(((X509Certificate)_certificate).getIssuerDN().getName()); - DateFormat df = DateFormat.getDateInstance(DateFormat.LONG); - - String validity = UniversalSecurityProperties.RESID_SECURITY_VALIDITY_PERIOD; - validity = StringModifier.change(validity,"%1", df.format(((X509Certificate)_certificate).getNotBefore())); //$NON-NLS-1$ - validity = StringModifier.change(validity,"%2", df.format(((X509Certificate)_certificate).getNotAfter())); //$NON-NLS-1$ - - lblValidityValue.setText(validity); - lblAlgorithmValue.setText(((X509Certificate)_certificate).getSigAlgName()); - }else if(_certificate instanceof Key){ - lblVersionValue.setText(((Key)_certificate).getFormat()); - lblAlgorithmValue.setText(((Key)_certificate).getAlgorithm()); - } - - return content; - } -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/NewCertTableLabelProvider.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/NewCertTableLabelProvider.java deleted file mode 100644 index b40458935..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/NewCertTableLabelProvider.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.wizards; - - - -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.rse.internal.dstore.security.preference.Element; -import org.eclipse.rse.internal.dstore.security.preference.X509CertificateElement; -import org.eclipse.swt.graphics.Image; - - - -public class NewCertTableLabelProvider - extends LabelProvider - implements ITableLabelProvider - { - - public Image getColumnImage(Object element, int columnIndex) - { - if (columnIndex == 0) - { - if (element instanceof Element) - { - return ((Element)element).getImage(); - } - } - return null; - } - /** - * @see ITableLabelProvider#getColumnText(Object, int) - */ - public String getColumnText(Object element, int columnIndex) - { - if (element instanceof Element) - { - X509CertificateElement myTableElement = (X509CertificateElement) element; - - switch (columnIndex) - { - case 0: // issued to - { - String name = myTableElement.getSubjectName(); - if (name == null || name.length() == 0) - { - name = myTableElement.getSubjectUnit(); - if (name == null || name.length() == 0) - { - name = myTableElement.getSubjectOrg(); - } - } - return name; - } - case 1: // issuer - { - String name = myTableElement.getIssuerName(); - if (name == null || name.length() == 0) - { - name = myTableElement.getIssuerUnit(); - if (name == null || name.length() == 0) - { - name = myTableElement.getIssuerOrg(); - } - } - - return name; - } - case 2: // expires - return myTableElement.getNotAfter(); - - default: - break; - } - } - return ""; //$NON-NLS-1$ - } - - - - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertAction.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertAction.java deleted file mode 100644 index 0c85758a5..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertAction.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * David McKnight (IBM) - [235756] [dstore] Unable to connect to host with SSL via REXEC - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.wizards; - -import java.util.List; - -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.rse.core.comm.ISystemKeystoreProvider; -import org.eclipse.rse.internal.dstore.security.ImageRegistry; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.rse.ui.actions.SystemBaseWizardAction; - -public class SystemImportCertAction extends SystemBaseWizardAction - { - private List _certificates; - private ISystemKeystoreProvider _provider; - private String _systemName; - - public SystemImportCertAction(ISystemKeystoreProvider provider, List certs, String systemName) - { - super(UniversalSecurityProperties.RESID_SECURITY_TRUST_IMPORT_CERTIFICATE_WIZARD, - ImageRegistry.getImageDescriptor(ImageRegistry.IMG_CERTIF_FILE), - SystemBasePlugin.getActiveWorkbenchShell() - ); - _certificates = certs; - _provider = provider; - _systemName = systemName; - } - - public IWizard createWizard() - { - SystemImportCertWizard importWiz = new SystemImportCertWizard(_provider, _systemName); - importWiz.setInputObject(_certificates); - return importWiz; - } -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertWizard.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertWizard.java deleted file mode 100644 index 5625aa65f..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertWizard.java +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin - ********************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.wizards; - -import java.security.KeyStore; -import java.security.cert.X509Certificate; -import java.util.List; - -import org.eclipse.dstore.core.util.ssl.DStoreKeyStore; -import org.eclipse.rse.core.comm.ISystemKeystoreProvider; -import org.eclipse.rse.internal.dstore.security.ImageRegistry; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.rse.ui.wizards.AbstractSystemWizard; - -public class SystemImportCertWizard - extends AbstractSystemWizard -{ - - private SystemImportCertWizardMainPage _mainPage; - private SystemImportCertWizardAliasPage _aliasPage; - private ISystemKeystoreProvider _provider; - private String _systemName; - - - /** - * Constructor - */ - public SystemImportCertWizard(ISystemKeystoreProvider provider, String systemName) - { - super(UniversalSecurityProperties.RESID_SECURITY_TRUST_IMPORT_CERTIFICATE_WIZARD, - ImageRegistry.getImageDescriptor(ImageRegistry.IMG_WZ_IMPORT_CERTIF)); - _provider = provider; - _systemName = systemName; - } - - /** - * Creates the wizard pages. - * This method is an override from the parent Wizard class. - */ - public void addPages() - { - try { - _mainPage = createMainPage(); - addPage(_mainPage); - - _aliasPage = createAliasPage(); - addPage(_aliasPage); - //super.addPages(); - } catch (Exception exc) - { - SystemBasePlugin.logError("New File: Error in createPages: ",exc); //$NON-NLS-1$ - } - } - - /** - * Creates the wizard's main page. - * This method is an override from the parent class. - */ - protected SystemImportCertWizardMainPage createMainPage() - { - // SystemMessage errMsg = null; - - _mainPage = new SystemImportCertWizardMainPage(this, getCertificates()); -// if (errMsg != null) - // _mainPage.setErrorMessage(errMsg); - return _mainPage; - } - - /** - * Creates the wizard's main page. - * This method is an override from the parent class. - */ - protected SystemImportCertWizardAliasPage createAliasPage() - { - // SystemMessage errMsg = null; - - _aliasPage = new SystemImportCertWizardAliasPage(this, getCertificates(), _systemName); - // if (errMsg != null) - // _aliasPage.setErrorMessage(errMsg); - return _aliasPage; - } - - /** - * Completes processing of the wizard. If this - * method returns true, the wizard will close; - * otherwise, it will stay active. - * This method is an override from the parent Wizard class. - * - * @return whether the wizard finished successfully - */ - public boolean performFinish() - { - boolean ok = false; - if (_aliasPage.performFinish()) - { - List certs = getCertificates(); - for (int i = 0; i < certs.size(); i++) - { - X509Certificate cert = (X509Certificate)certs.get(i); - if (cert != null) - { - String alias = _aliasPage.getAlias(); - - try - { - KeyStore ks = DStoreKeyStore.getKeyStore(_provider.getKeyStorePath(), _provider.getKeyStorePassword()); - DStoreKeyStore.addCertificateToKeyStore(ks, cert, alias); - DStoreKeyStore.persistKeyStore(ks, _provider.getKeyStorePath(), _provider.getKeyStorePassword()); - ok = true; - } - catch (Exception e) - { - e.printStackTrace(); - ok = false; - } - } - } - } - return ok; - } - - - public List getCertificates() - { - return (List)getInputObject(); - } - - - -} // end class
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertWizardAliasPage.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertWizardAliasPage.java deleted file mode 100644 index ef7e015b4..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertWizardAliasPage.java +++ /dev/null @@ -1,204 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.wizards; - -import java.security.KeyStore; -import java.security.cert.X509Certificate; -import java.util.Enumeration; -import java.util.List; - -import org.eclipse.dstore.core.util.ssl.DStoreKeyStore; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityPlugin; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; -import org.eclipse.rse.internal.dstore.security.preference.X509CertificateElement; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.rse.ui.wizards.AbstractSystemWizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Text; - - -public class SystemImportCertWizardAliasPage - extends AbstractSystemWizardPage -{ - - - protected SystemMessage errorMessage; - protected ISystemValidator nameValidator; - protected ISystemMessageLine msgLine; - private String _systemName; - - private Text _alias; - /** - * Constructor. - */ - public SystemImportCertWizardAliasPage(Wizard wizard, List certs, String systemName) - { - super(wizard, "SpecifyAlias", //$NON-NLS-1$ - UniversalSecurityProperties.RESID_SECURITY_TRUST_WIZ_ALIAS_TITLE, - UniversalSecurityProperties.RESID_SECURITY_TRUST_WIZ_ALIAS_DESC); - _systemName = systemName; - } - - /** - * CreateContents is the one method that must be overridden from the parent class. - * In this method, we populate an SWT container with widgets and return the container - * to the caller (JFace). This is used as the contents of this page. - */ - public Control createContents(Composite parent) - { - Composite content = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - GridData data = new GridData(GridData.FILL_BOTH); - layout.numColumns = 3; - content.setLayout(layout); - content.setLayoutData(data); - - SystemWidgetHelpers.createLabel(content, UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_ALIAS); - _alias = SystemWidgetHelpers.createTextField(content, null); - _alias.addModifyListener( - new ModifyListener() - { - public void modifyText(ModifyEvent e) - { - validateNameInput(); - } - } - ); - initializeInput(); - return _alias; - } - - - public X509CertificateElement getElement(Object cert) - { - if (cert instanceof X509Certificate) - { - return new X509CertificateElement(null, - UniversalSecurityProperties.RESID_SECURITY_TRUSTED_CERTIFICATE, - (X509Certificate)cert); - } - return null; - } - - - - /** - * Return the Control to be given initial focus. - * Override from parent. Return control to be given initial focus. - */ - protected Control getInitialFocusControl() - { - return _alias; - } - - /** - * Init values using input data - */ - protected void initializeInput() - { - _alias.setText(getAlias()); - } - - /** - * This hook method is called whenever the text changes in the input field. - * The default implementation delegates the request to an <code>ISystemValidator</code> object. - * If the <code>ISystemValidator</code> reports an error the error message is displayed - * in the Dialog's message line. - */ - protected SystemMessage validateNameInput() - { - errorMessage = null; - this.clearErrorMessage(); - if (nameValidator != null) - errorMessage= nameValidator.validate(_alias.getText()); - if (errorMessage != null) - setErrorMessage(errorMessage); - setPageComplete(errorMessage==null); - return errorMessage; - } - - /** - * Completes processing of the wizard. If this - * method returns true, the wizard will close; - * otherwise, it will stay active. - * This method is an override from the parent Wizard class. - * - * @return whether the wizard finished successfully - */ - public boolean performFinish() - { - - return true; - } - - // --------------------------------- // - // METHODS FOR EXTRACTING USER DATA ... - // --------------------------------- // - /** - * Return user-entered new file name. - * Call this after finish ends successfully. - */ - public String getAlias() - { - String alias = _alias.getText().trim(); - if (alias.equals("")) //$NON-NLS-1$ - { - try - { - int count = 0; - String storePath = UniversalSecurityPlugin.getKeyStoreLocation(); - String passw = UniversalSecurityPlugin.getKeyStorePassword(); - KeyStore keyStore = DStoreKeyStore.getKeyStore(storePath, passw); - Enumeration aliases = keyStore.aliases(); - while (aliases.hasMoreElements()) - { - String existingalias = (String) (aliases.nextElement()); - if (existingalias.toLowerCase().startsWith(_systemName.toLowerCase())) count++; - } - count++; - alias = _systemName + count; - } - catch (Exception e) - { - alias = _systemName; - } - } - return alias; - } - - /** - * Return true if the page is complete, so to enable Finish. - * Called by wizard framework. - */ - public boolean isPageComplete() - { - return (errorMessage==null); - } - - -} diff --git a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertWizardMainPage.java b/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertWizardMainPage.java deleted file mode 100644 index 87643e66b..000000000 --- a/rse/plugins/org.eclipse.rse.dstore.security/src/org/eclipse/rse/internal/dstore/security/wizards/SystemImportCertWizardMainPage.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format - *******************************************************************************/ - -package org.eclipse.rse.internal.dstore.security.wizards; - -import java.security.cert.X509Certificate; -import java.util.List; - -import org.eclipse.jface.viewers.ColumnPixelData; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; -import org.eclipse.rse.internal.dstore.security.preference.CertTableContentProvider; -import org.eclipse.rse.internal.dstore.security.preference.X509CertificateElement; -import org.eclipse.rse.internal.dstore.security.preference.X509CertificatePropertiesDialog; -import org.eclipse.rse.internal.dstore.security.util.GridUtil; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.rse.ui.wizards.AbstractSystemWizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; - - -public class SystemImportCertWizardMainPage - extends AbstractSystemWizardPage - implements Listener -{ - protected SystemMessage errorMessage; - protected ISystemValidator nameValidator; - protected ISystemMessageLine msgLine; - - private List _certificates; - private Button _propertiesButton; - - private TableViewer _viewer; - - /** - * Constructor. - */ - public SystemImportCertWizardMainPage(Wizard wizard, List certs) - { - super(wizard, "NewCertificate", //$NON-NLS-1$ - UniversalSecurityProperties.RESID_SECURITY_TRUST_WIZ_CERTIFICATE_TITLE, - UniversalSecurityProperties.RESID_SECURITY_TRUST_WIZ_CERTIFICATE_DESC); - _certificates = certs; - } - - /** - * CreateContents is the one method that must be overridden from the parent class. - * In this method, we populate an SWT container with widgets and return the container - * to the caller (JFace). This is used as the contents of this page. - */ - public Control createContents(Composite parent) - { - - Composite verbiage = new Composite(parent, SWT.NULL); - GridLayout vlayout = new GridLayout(); - GridData vdata = new GridData(GridData.FILL_BOTH); - vlayout.numColumns = 1; - verbiage.setLayout(vlayout); - verbiage.setLayoutData(vdata); - - SystemWidgetHelpers.createLabel(verbiage, UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_INFORMATION); - createTableViewer(verbiage); - - Composite b = new Composite(parent, SWT.NULL); - GridLayout blayout = new GridLayout(); - GridData bdata = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.END); - blayout.numColumns = 3; - b.setLayout(blayout); - b.setLayoutData(bdata); - _propertiesButton = SystemWidgetHelpers.createPushButton(b, UniversalSecurityProperties.RESID_SECURITY_PROPERTIES_LBL, this); - - return _propertiesButton; - } - - - private void createTableViewer(Composite parent) - { - // Create the table viewer. - _viewer = new TableViewer(parent, SWT.BORDER | SWT.READ_ONLY); - - // Create the table control. - Table table = _viewer.getTable(); - table.setHeaderVisible(true); - table.setLinesVisible(true); - GridData data = GridUtil.createFill(); - data.heightHint = 30; - data.widthHint = 80; - table.setLayoutData(data); - - TableLayout tableLayout = new TableLayout(); - - TableColumn toColumn = new TableColumn(table, SWT.LEFT); - toColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_TO); - tableLayout.addColumnData(new ColumnPixelData(90)); - - TableColumn frmColumn = new TableColumn(table, SWT.LEFT); - frmColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_FROM); - tableLayout.addColumnData(new ColumnPixelData(90)); - - TableColumn expColumn = new TableColumn(table, SWT.RIGHT); - expColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_EXPIRES); - tableLayout.addColumnData(new ColumnPixelData(180)); - table.setLayout(tableLayout); - - // Adjust the table viewer. - String[] properties = new String[] {"STRING", "STRING", "NUMBER"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - _viewer.setColumnProperties(properties); - _viewer.setContentProvider(new CertTableContentProvider()); - _viewer.setLabelProvider(new NewCertTableLabelProvider()); - - if (_certificates != null) - { - for (int i = 0; i < _certificates.size(); i++) - { - _viewer.add(getElement(_certificates.get(i))); - } - } - } - - - - public void handleEvent(Event e) - { - if (e.widget == _propertiesButton) - { - IStructuredSelection sel = (IStructuredSelection)_viewer.getSelection(); - sel.getFirstElement(); - - X509CertificatePropertiesDialog dlg = new X509CertificatePropertiesDialog(getShell(), (X509CertificateElement)sel.getFirstElement()); - dlg.open(); - } - } - - public X509CertificateElement getElement(Object cert) - { - if (cert instanceof X509Certificate) - { - return new X509CertificateElement(null, - UniversalSecurityProperties.RESID_SECURITY_TRUSTED_CERTIFICATE, - (X509Certificate)cert); - } - return null; - } - - /** - * Return the Control to be given initial focus. - * Override from parent. Return control to be given initial focus. - */ - protected Control getInitialFocusControl() - { - return _propertiesButton; - } - - /** - * Init values using input data - */ - protected void initializeInput() - { - } - - - - /** - * Completes processing of the wizard. If this - * method returns true, the wizard will close; - * otherwise, it will stay active. - * This method is an override from the parent Wizard class. - * - * @return whether the wizard finished successfully - */ - public boolean performFinish() - { - - return true; - } - - - - /** - * Return true if the page is complete, so to enable Finish. - * Called by wizard framework. - */ - public boolean isPageComplete() - { - return true; - } - - -} |