1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 13:05:22 +02:00

[235626] Convert dstore.security to MessageBundle format

This commit is contained in:
Martin Oberhuber 2008-06-04 22:48:52 +00:00
parent e97b62b224
commit e4d6db8c8f
11 changed files with 311 additions and 360 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others. * Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,20 +7,17 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.dstore.security; package org.eclipse.rse.internal.dstore.security;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
@ -35,14 +32,13 @@ public class UniversalSecurityPlugin extends AbstractUIPlugin
{ {
private final static String KEYSTORE = "dstorekeystore.dat"; //$NON-NLS-1$ private final static String KEYSTORE = "dstorekeystore.dat"; //$NON-NLS-1$
private static UniversalSecurityPlugin inst; private static UniversalSecurityPlugin inst;
private static ResourceBundle aResourceBundle;
public static final String PLUGIN_ID = "org.eclipse.rse.dstore.security"; //$NON-NLS-1$ public static final String PLUGIN_ID = "org.eclipse.rse.dstore.security"; //$NON-NLS-1$
public UniversalSecurityPlugin() { public UniversalSecurityPlugin() {
if (inst == null) if (inst == null)
inst = this; inst = this;
} }
public static UniversalSecurityPlugin getDefault() { public static UniversalSecurityPlugin getDefault() {
return inst; return inst;
} }
@ -51,30 +47,8 @@ public class UniversalSecurityPlugin extends AbstractUIPlugin
return PLUGIN_ID; return PLUGIN_ID;
} }
public static ResourceBundle getResourceBundle() {
if(aResourceBundle == null)
{
try {
aResourceBundle = Platform.getResourceBundle(Platform.getBundle(PLUGIN_ID));
} catch (Exception e) {
aResourceBundle = null;
}
}
return aResourceBundle;
}
public static String getString(String key) {
try {
return getResourceBundle().getString(key);
} catch (MissingResourceException e) {
return key;
}
}
public static String getKeyStoreLocation() { public static String getKeyStoreLocation() {
Bundle bundle = Platform.getBundle(PLUGIN_ID); Bundle bundle = Platform.getBundle(PLUGIN_ID);
return Platform.getStateLocation(bundle).append(KEYSTORE).toOSString(); return Platform.getStateLocation(bundle).append(KEYSTORE).toOSString();
} }
@ -83,12 +57,12 @@ public class UniversalSecurityPlugin extends AbstractUIPlugin
{ {
return "dstore"; //$NON-NLS-1$ return "dstore"; //$NON-NLS-1$
} }
public static String getWorkspaceName(){ public static String getWorkspaceName(){
IPath workspace = Platform.getLocation(); IPath workspace = Platform.getLocation();
int nr = workspace.segmentCount(); int nr = workspace.segmentCount();
String workspaceName = workspace.segment(nr - 1); String workspaceName = workspace.segment(nr - 1);
return workspaceName; return workspaceName;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -97,7 +71,7 @@ public class UniversalSecurityPlugin extends AbstractUIPlugin
public void stop(BundleContext context) throws Exception { public void stop(BundleContext context) throws Exception {
super.stop(context); super.stop(context);
savePluginPreferences(); savePluginPreferences();
ImageRegistry.shutdown(); ImageRegistry.shutdown();
} }
@ -108,13 +82,13 @@ public class UniversalSecurityPlugin extends AbstractUIPlugin
public static IWorkbenchWindow getActiveWorkbenchWindow() { public static IWorkbenchWindow getActiveWorkbenchWindow() {
return getDefault().getWorkbench().getActiveWorkbenchWindow(); return getDefault().getWorkbench().getActiveWorkbenchWindow();
} }
public void log(IStatus status) { public void log(IStatus status) {
getLog().log(status); getLog().log(status);
} }
public void log(Throwable e) { public void log(Throwable e) {
log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Error", e)); //$NON-NLS-1$ log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "Error", e)); //$NON-NLS-1$
} }
} }

View file

@ -7,28 +7,25 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [181112] NLS missing messages * 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; package org.eclipse.rse.internal.dstore.security;
import org.eclipse.osgi.util.NLS; import org.eclipse.osgi.util.NLS;
public class UniversalSecurityProperties extends NLS public class UniversalSecurityProperties extends NLS
{ {
private static String BUNDLE_NAME = "org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties";//$NON-NLS-1$ 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_CERTIFICATE_PROP_TITLE;
public static String RESID_SECURITY_VALIDITY_PERIOD; public static String RESID_SECURITY_VALIDITY_PERIOD;
public static String RESID_SECURITY_CERTIF_VERSION_LBL; public static String RESID_SECURITY_CERTIF_VERSION_LBL;
public static String RESID_SECURITY_PROP_ALIAS_LBL; public static String RESID_SECURITY_PROP_ALIAS_LBL;
public static String RESID_SECURITY_ISSUED_TO_LBL; public static String RESID_SECURITY_ISSUED_TO_LBL;
@ -56,27 +53,32 @@ public class UniversalSecurityProperties extends NLS
public static String RESID_SECURITY_IO_SAVE_ERROR_; public static String RESID_SECURITY_IO_SAVE_ERROR_;
public static String RESID_SECURITY_CERTIFICATE_STORE_ERROR_; public static String RESID_SECURITY_CERTIFICATE_STORE_ERROR_;
public static String RESID_SECURITY_UNINIT_KEYSTORE_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_CERTIFICATE_EXC_;
public static String RESID_SECURITY_LOAD_IO_EXC_; public static String RESID_SECURITY_LOAD_IO_EXC_;
public static String RESID_SECURITY_CERTIFICATE_LOAD_EXC_; public static String RESID_SECURITY_CERTIFICATE_LOAD_EXC_;
public static String RESID_SECURITY_PREF_SEC_DESCRIPTION; public static String RESID_SECURITY_PREF_SEC_DESCRIPTION;
public static String RESID_SECURITY_PROPERTIES_LBL; public static String RESID_SECURITY_PROPERTIES_LBL;
public static String RESID_SECURITY_TRUST_WIZ_ALIAS_TITLE; 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_ALIAS_DESC;
public static String RESID_SECURITY_TRUST_WIZ_CERTIFICATE_TITLE; public static String RESID_SECURITY_TRUST_WIZ_CERTIFICATE_TITLE;
public static String RESID_SECURITY_TRUST_WIZ_CERTIFICATE_DESC; public static String RESID_SECURITY_TRUST_WIZ_CERTIFICATE_DESC;
public static String RESID_SECURITY_TRUST_IMPORT_CERTIFICATE_WIZARD; public static String RESID_SECURITY_TRUST_IMPORT_CERTIFICATE_WIZARD;
public static String RESID_SECURITY_CERTIFICATE_INFORMATION; public static String RESID_SECURITY_CERTIFICATE_INFORMATION;
public static String RESID_SECURITY_VALIDITY_LBL; public static String RESID_SECURITY_VALIDITY_LBL;
static static
{ {
// load message values from bundle file // load message values from bundle file
initializeMessages(BUNDLE_NAME, UniversalSecurityProperties.class); initializeMessages(BUNDLE_NAME, UniversalSecurityProperties.class);
} }
} }

View file

@ -12,7 +12,7 @@
# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. # Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
# #
# Contributors: # Contributors:
# {Name} (company) - description of contribution. # Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format
############################################################################### ###############################################################################
# NLS_MESSAGEFORMAT_NONE # NLS_MESSAGEFORMAT_NONE
@ -48,6 +48,13 @@
RESID_SECURITY_IO_SAVE_ERROR_ = A input-output exception occurred while saving key store \n%1. 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_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. RESID_SECURITY_UNINIT_KEYSTORE_ERROR_ = Keystore %1 \nhas not been initialized.
# FIXME MISSING STRINGS START
RESID_SECURITY_ALGORITHM_ERROR_ = Algorithm error in Keystore %1
RESID_SECURITY_LOAD_KEYSTORE_ERROR_ = An error occurred when processing Keystore.
RESID_SECURITY_KEY_LOAD_ERROR_ = Error loading key from %1
RESID_SECURITY_INITIALIZE_ERROR_ = Error initializing keystore at %1
RESID_SECURITY_SECURITY_PROVIDER_ERROR_ = Missing Security Provider
# FIXME MISSING STRINGS END
RESID_SECURITY_CERTIFICATE_EXC_ = A certificate exception occurred while loading the file\n%1 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_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_CERTIFICATE_LOAD_EXC_ = Unable to load certificate.

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others. * Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,19 +7,18 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.dstore.security.preference; package org.eclipse.rse.internal.dstore.security.preference;
import org.eclipse.rse.internal.dstore.security.UniversalSecurityPlugin;
import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties;
import org.eclipse.rse.internal.dstore.security.widgets.CertificatePropertiesForm; import org.eclipse.rse.internal.dstore.security.widgets.CertificatePropertiesForm;
import org.eclipse.rse.ui.dialogs.SystemPromptDialog; import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
@ -30,25 +29,25 @@ import org.eclipse.swt.widgets.Shell;
public class CertPropertiesDialog extends SystemPromptDialog public class CertPropertiesDialog extends SystemPromptDialog
{ {
private Object _cert; private Object _cert;
public CertPropertiesDialog(Shell parentShell, Object cert) public CertPropertiesDialog(Shell parentShell, Object cert)
{ {
super(parentShell, UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_PROP_TITLE)); super(parentShell, UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_PROP_TITLE);
_cert = cert; _cert = cert;
} }
public Control getInitialFocusControl() public Control getInitialFocusControl()
{ {
return getOkButton(); return getOkButton();
} }
protected Control createInner(Composite parent) protected Control createInner(Composite parent)
{ {
CertificatePropertiesForm form = new CertificatePropertiesForm(getShell(), _cert, true); CertificatePropertiesForm form = new CertificatePropertiesForm(getShell(), _cert, true);
return form.createContents(parent); return form.createContents(parent);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others. * Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,12 +7,12 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.dstore.security.preference; package org.eclipse.rse.internal.dstore.security.preference;
@ -21,7 +21,6 @@ package org.eclipse.rse.internal.dstore.security.preference;
import java.security.Key; import java.security.Key;
import org.eclipse.rse.internal.dstore.security.ImageRegistry; import org.eclipse.rse.internal.dstore.security.ImageRegistry;
import org.eclipse.rse.internal.dstore.security.UniversalSecurityPlugin;
import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
@ -35,27 +34,27 @@ public class KeyElement extends Element
super(alias, value); super(alias, value);
_key = key; _key = key;
} }
public String getType() public String getType()
{ {
return UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_KEY_ENTRY); return UniversalSecurityProperties.RESID_SECURITY_KEY_ENTRY;
} }
public String getAlgorithm() public String getAlgorithm()
{ {
return _key.getAlgorithm(); return _key.getAlgorithm();
} }
public String getFormat() public String getFormat()
{ {
return _key.getFormat(); return _key.getFormat();
} }
public Image getImage() public Image getImage()
{ {
return org.eclipse.rse.internal.dstore.security.ImageRegistry.getImage(ImageRegistry.IMG_CERTIF_FILE); return org.eclipse.rse.internal.dstore.security.ImageRegistry.getImage(ImageRegistry.IMG_CERTIF_FILE);
} }
public Object getCert() public Object getCert()
{ {
return _key; return _key;

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others. * Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,12 +7,12 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.dstore.security.preference; package org.eclipse.rse.internal.dstore.security.preference;
@ -49,26 +49,26 @@ public class NewCertDialog extends SystemPromptDialog implements Listener
{ {
/** /**
* *
*/ */
private final UniversalSecurityPreferencePage page; private final UniversalSecurityPreferencePage page;
private CertificateForm _certForm; private CertificateForm _certForm;
private Certificate _certificate; private Certificate _certificate;
private Shell _shell; private Shell _shell;
public NewCertDialog(UniversalSecurityPreferencePage page, Shell shell){ public NewCertDialog(UniversalSecurityPreferencePage page, Shell shell){
super(shell,UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_ADD_CERT_DLG_TITLE) ); super(shell, UniversalSecurityProperties.RESID_SECURITY_ADD_CERT_DLG_TITLE);
this.page = page; this.page = page;
_shell = shell; _shell = shell;
} }
public Control getInitialFocusControl() public Control getInitialFocusControl()
{ {
return _certForm.getInitialFocusControl(); return _certForm.getInitialFocusControl();
} }
protected Control createInner(Composite parent) protected Control createInner(Composite parent)
{ {
Composite content = new Composite(parent, SWT.NULL); Composite content = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
GridData data = GridUtil.createFill(); GridData data = GridUtil.createFill();
@ -82,81 +82,82 @@ public class NewCertDialog extends SystemPromptDialog implements Listener
return content; return content;
} }
protected Control createButtonBar(Composite parent) protected Control createButtonBar(Composite parent)
{ {
Control control = super.createButtonBar(parent); Control control = super.createButtonBar(parent);
getOkButton().setEnabled(false); getOkButton().setEnabled(false);
return control; return control;
} }
protected boolean processOK(){ protected boolean processOK(){
try{ try{
_certificate = _certForm.loadCertificate(this.page._keyStore); _certificate = _certForm.loadCertificate(this.page._keyStore);
} }
catch(FileNotFoundException e){ catch(FileNotFoundException e){
String text = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_KEY_IO_ERROR_); String text = UniversalSecurityProperties.RESID_SECURITY_KEY_IO_ERROR_;
text = StringModifier.change(text, "%1", _certForm.getPath()); //$NON-NLS-1$ text = StringModifier.change(text, "%1", _certForm.getPath()); //$NON-NLS-1$
String msg = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_); String msg = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_;
Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,e); Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,e);
ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(),UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_SEC_MSG), msg,err); ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
return false; return false;
} }
catch(IOException e){ catch(IOException e){
String text = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_LOAD_IO_EXC_); String text = UniversalSecurityProperties.RESID_SECURITY_LOAD_IO_EXC_;
text = StringModifier.change(text, "%1", _certForm.getPath()); //$NON-NLS-1$ text = StringModifier.change(text, "%1", _certForm.getPath()); //$NON-NLS-1$
text = StringModifier.change(text, "%1", UniversalSecurityPlugin.getKeyStoreLocation()); //$NON-NLS-1$ text = StringModifier.change(text, "%1", UniversalSecurityPlugin.getKeyStoreLocation()); //$NON-NLS-1$
String msg = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_); String msg = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_;
Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,e); Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,e);
ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(),UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_SEC_MSG), msg,err); ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
return false; return false;
} }
catch(CertificateException exc){ catch(CertificateException exc){
String text = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_EXC_); String text = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_EXC_;
text = StringModifier.change(text, "%1", _certForm.getPath()); //$NON-NLS-1$ text = StringModifier.change(text, "%1", _certForm.getPath()); //$NON-NLS-1$
String msg = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_); String msg = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_;
Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,exc); Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,exc);
ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(),UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_SEC_MSG), msg,err); ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
return false; return false;
} }
catch(KeyStoreException exc){ catch(KeyStoreException exc){
String text = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_KEY_STORE_ERROR_); String text = UniversalSecurityProperties.RESID_SECURITY_KEY_STORE_ERROR_;
text = StringModifier.change(text, "%1", UniversalSecurityPlugin.getKeyStoreLocation()); //$NON-NLS-1$ text = StringModifier.change(text, "%1", UniversalSecurityPlugin.getKeyStoreLocation()); //$NON-NLS-1$
String msg = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_); String msg = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_LOAD_EXC_;
Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,exc); Status err = new Status(IStatus.ERROR,ResourcesPlugin.PI_RESOURCES,IStatus.ERROR,text,exc);
ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(),UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_SEC_MSG), msg,err); ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
return false; return false;
} }
if (_certificate instanceof X509Certificate) if (_certificate instanceof X509Certificate)
{ {
X509CertificateElement elem = new X509CertificateElement(_certForm.getAliasName(), UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_TRUSTED_CERTIFICATE), (X509Certificate)_certificate); X509CertificateElement elem = new X509CertificateElement(_certForm.getAliasName(), UniversalSecurityProperties.RESID_SECURITY_TRUSTED_CERTIFICATE,
(X509Certificate) _certificate);
this.page._tableItems.add(elem); this.page._tableItems.add(elem);
} }
return true; return true;
} }
public void handleEvent(Event e){ public void handleEvent(Event e){
getButton(IDialogConstants.OK_ID).setEnabled(_certForm.validateDialog()); getButton(IDialogConstants.OK_ID).setEnabled(_certForm.validateDialog());
} }
public Certificate getCertificate(){ public Certificate getCertificate(){
return _certificate; return _certificate;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2007 IBM Corporation and others. * Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,19 +7,18 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.dstore.security.preference; package org.eclipse.rse.internal.dstore.security.preference;
import org.eclipse.jface.dialogs.IDialogConstants; 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.UniversalSecurityProperties;
import org.eclipse.rse.internal.dstore.security.util.GridUtil; import org.eclipse.rse.internal.dstore.security.util.GridUtil;
import org.eclipse.rse.ui.dialogs.SystemPromptDialog; import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
@ -35,23 +34,23 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
public class RenameCertDialog extends SystemPromptDialog implements Listener{ public class RenameCertDialog extends SystemPromptDialog implements Listener{
private Text txtName; private Text txtName;
String newAlias; String newAlias;
private String oldAlias; private String oldAlias;
public RenameCertDialog(UniversalSecurityPreferencePage page, Shell shell, String oldValue) public RenameCertDialog(UniversalSecurityPreferencePage page, Shell shell, String oldValue)
{ {
super(shell, UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_RENAME_CERT_DLG_TITLE)); super(shell, UniversalSecurityProperties.RESID_SECURITY_RENAME_CERT_DLG_TITLE);
oldAlias = oldValue; oldAlias = oldValue;
} }
public Control getInitialFocusControl() public Control getInitialFocusControl()
{ {
return txtName; return txtName;
} }
protected Control createInner(Composite parent) protected Control createInner(Composite parent)
{ {
@ -64,44 +63,44 @@ public class RenameCertDialog extends SystemPromptDialog implements Listener{
content.setLayoutData(data); content.setLayoutData(data);
Label lblName = new Label(content, SWT.NONE); Label lblName = new Label(content, SWT.NONE);
lblName.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_ALIAS)); lblName.setText(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_ALIAS);
txtName = new Text(content, SWT.BORDER); txtName = new Text(content, SWT.BORDER);
txtName.setText(oldAlias); txtName.setText(oldAlias);
txtName.selectAll(); txtName.selectAll();
txtName.addListener(SWT.Modify, this); txtName.addListener(SWT.Modify, this);
data = GridUtil.createHorizontalFill(); data = GridUtil.createHorizontalFill();
data.widthHint = 200; data.widthHint = 200;
txtName.setLayoutData(data); txtName.setLayoutData(data);
return content; return content;
} }
private void validateDialog(){ private void validateDialog(){
if(txtName.getText().trim().length()==0) if(txtName.getText().trim().length()==0)
getButton(IDialogConstants.OK_ID).setEnabled(false); getButton(IDialogConstants.OK_ID).setEnabled(false);
else else
getButton(IDialogConstants.OK_ID).setEnabled(true); getButton(IDialogConstants.OK_ID).setEnabled(true);
} }
public void handleEvent(Event e){ public void handleEvent(Event e){
if(e.widget.equals(txtName)) if(e.widget.equals(txtName))
validateDialog(); validateDialog();
} }
protected Control createButtonBar(Composite parent) { protected Control createButtonBar(Composite parent) {
Control control = super.createButtonBar(parent); Control control = super.createButtonBar(parent);
validateDialog(); validateDialog();
return control; return control;
} }
public String getNewAlias() public String getNewAlias()
{ {
return newAlias; return newAlias;
} }
protected boolean processOK() protected boolean processOK()
{ {
newAlias = txtName.getText(); newAlias = txtName.getText();

View file

@ -7,12 +7,13 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* David Dykstal (IBM) - [232131] fix minor layout problems along with date formats * 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; package org.eclipse.rse.internal.dstore.security.preference;
@ -103,7 +104,7 @@ public class UniversalSecurityPreferencePage extends PreferencePage implements
Text label = new Text(composite, SWT.READ_ONLY); Text label = new Text(composite, SWT.READ_ONLY);
label.setBackground(composite.getBackground()); label.setBackground(composite.getBackground());
label.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_PREF_SEC_DESCRIPTION)); label.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_SEC_DESCRIPTION);
GridData data = new GridData(); GridData data = new GridData();
data.horizontalSpan = 2; data.horizontalSpan = 2;
label.setLayoutData(data); label.setLayoutData(data);
@ -142,19 +143,19 @@ public class UniversalSecurityPreferencePage extends PreferencePage implements
TableColumn aliasColumn = new TableColumn(table, SWT.LEFT); TableColumn aliasColumn = new TableColumn(table, SWT.LEFT);
aliasColumn.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_PREF_ALIAS_NAME)); aliasColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_ALIAS_NAME);
tableLayout.addColumnData(new ColumnPixelData(100)); tableLayout.addColumnData(new ColumnPixelData(100));
TableColumn toColumn = new TableColumn(table, SWT.LEFT); TableColumn toColumn = new TableColumn(table, SWT.LEFT);
toColumn.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_TO)); toColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_TO);
tableLayout.addColumnData(new ColumnPixelData(150)); tableLayout.addColumnData(new ColumnPixelData(150));
TableColumn frmColumn = new TableColumn(table, SWT.LEFT); TableColumn frmColumn = new TableColumn(table, SWT.LEFT);
frmColumn.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_FROM)); frmColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_FROM);
tableLayout.addColumnData(new ColumnPixelData(150)); tableLayout.addColumnData(new ColumnPixelData(150));
TableColumn expColumn = new TableColumn(table, SWT.LEFT); TableColumn expColumn = new TableColumn(table, SWT.LEFT);
expColumn.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_PREF_EXPIRES)); expColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_EXPIRES);
tableLayout.addColumnData(new ColumnPixelData(150)); tableLayout.addColumnData(new ColumnPixelData(150));
table.setLayout(tableLayout); table.setLayout(tableLayout);
@ -171,17 +172,17 @@ public class UniversalSecurityPreferencePage extends PreferencePage implements
private void createButtons(Composite parent) private void createButtons(Composite parent)
{ {
Composite buttonComposite = SystemWidgetHelpers.createComposite(parent, 4); Composite buttonComposite = SystemWidgetHelpers.createComposite(parent, 4);
_addButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_ADD_LBL),this); _addButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityProperties.RESID_SECURITY_ADD_LBL, this);
_removeButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_REMOVE_LBL), this); _removeButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityProperties.RESID_SECURITY_REMOVE_LBL, this);
_removeButton.setEnabled(false); _removeButton.setEnabled(false);
_renameButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_RENAME_LBL), this); _renameButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityProperties.RESID_SECURITY_RENAME_LBL, this);
_renameButton.setEnabled(false); _renameButton.setEnabled(false);
_propertiesButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_PROPERTIES_LBL), this); _propertiesButton = SystemWidgetHelpers.createPushButton(buttonComposite, UniversalSecurityProperties.RESID_SECURITY_PROPERTIES_LBL, this);
_propertiesButton.setEnabled(false); _propertiesButton.setEnabled(false);
} }
@ -219,64 +220,55 @@ public class UniversalSecurityPreferencePage extends PreferencePage implements
catch (IOException e) catch (IOException e)
{ {
String text = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_IO_SAVE_ERROR_); 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$
text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$ text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$
String msg = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_KEYSTORE_SAVE_ERROR_); String msg = UniversalSecurityProperties.RESID_SECURITY_KEYSTORE_SAVE_ERROR_;
Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES,
IStatus.ERROR, text, e); IStatus.ERROR, text, e);
ErrorDialog.openError(UniversalSecurityPlugin ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
.getActiveWorkbenchShell(), UniversalSecurityPlugin
.getString("SEC_MSG"), msg, err); //$NON-NLS-1$
return false; return false;
} }
catch (CertificateException exc) catch (CertificateException exc)
{ {
String text = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_STORE_ERROR_); String text = UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_STORE_ERROR_;
text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$ text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$
String msg = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_KEYSTORE_SAVE_ERROR_); String msg = UniversalSecurityProperties.RESID_SECURITY_KEYSTORE_SAVE_ERROR_;
Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES,
IStatus.ERROR, text, exc); IStatus.ERROR, text, exc);
ErrorDialog.openError(UniversalSecurityPlugin ErrorDialog.openError(UniversalSecurityPlugin
.getActiveWorkbenchShell(), UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_SEC_MSG), msg, err); .getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
return false; return false;
} }
catch (KeyStoreException exc) catch (KeyStoreException exc)
{ {
String text = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_UNINIT_KEYSTORE_ERROR_); String text = UniversalSecurityProperties.RESID_SECURITY_UNINIT_KEYSTORE_ERROR_;
text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$ text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$
.getKeyStoreLocation()); .getKeyStoreLocation());
String msg = UniversalSecurityPlugin String msg = UniversalSecurityProperties.RESID_SECURITY_KEYSTORE_SAVE_ERROR_;
.getString("RESID_SECURITY_KEYSTORE_SAVE_ERROR_"); //$NON-NLS-1$
Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES,
IStatus.ERROR, text, exc); IStatus.ERROR, text, exc);
ErrorDialog.openError(UniversalSecurityPlugin ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
.getActiveWorkbenchShell(), UniversalSecurityPlugin
.getString("SEC_MSG"), msg, err); //$NON-NLS-1$
return false; return false;
} }
catch (NoSuchAlgorithmException exc2) catch (NoSuchAlgorithmException exc2)
{ {
String text = UniversalSecurityPlugin String text = UniversalSecurityProperties.RESID_SECURITY_ALGORITHM_ERROR_;
.getString("RESID_SECURITY_ALGORITHM_ERROR_"); //$NON-NLS-1$
text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$ text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$
.getKeyStoreLocation()); .getKeyStoreLocation());
String msg = UniversalSecurityPlugin String msg = UniversalSecurityProperties.RESID_SECURITY_KEYSTORE_SAVE_ERROR_;
.getString("RESID_SECURITY_KEYSTORE_SAVE_ERROR_"); //$NON-NLS-1$
Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES,
IStatus.ERROR, text, exc2); IStatus.ERROR, text, exc2);
ErrorDialog.openError(UniversalSecurityPlugin ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
.getActiveWorkbenchShell(), UniversalSecurityPlugin
.getString("SEC_MSG"), msg, err); //$NON-NLS-1$
return false; return false;
} }
@ -323,8 +315,7 @@ public class UniversalSecurityPreferencePage extends PreferencePage implements
{ {
Key key = _keyStore.getKey(alias, passw.toCharArray()); Key key = _keyStore.getKey(alias, passw.toCharArray());
KeyElement elem = new KeyElement(alias, KeyElement elem = new KeyElement(alias,
UniversalSecurityPlugin UniversalSecurityProperties.RESID_SECURITY_KEY_ENTRY,
.getString("RESID_SECURITY_KEY_ENTRY"), //$NON-NLS-1$
key); key);
_tableItems.add(elem); _tableItems.add(elem);
} }
@ -339,82 +330,62 @@ public class UniversalSecurityPreferencePage extends PreferencePage implements
catch (IOException e) catch (IOException e)
{ {
String text = UniversalSecurityPlugin String text = UniversalSecurityProperties.RESID_SECURITY_LOAD_IO_EXC_;
.getString("RESID_SECURITY_LOAD_IO_EXC_"); //$NON-NLS-1$
text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$ text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$
String msg = UniversalSecurityPlugin String msg = UniversalSecurityProperties.RESID_SECURITY_LOAD_KEYSTORE_ERROR_;
.getString("RESID_SECURITY_LOAD_KEYSTORE_ERROR_"); //$NON-NLS-1$
Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES,
IStatus.ERROR, text, e); IStatus.ERROR, text, e);
ErrorDialog.openError(UniversalSecurityPlugin ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
.getActiveWorkbenchShell(), UniversalSecurityPlugin
.getString("SEC_MSG"), msg, err); //$NON-NLS-1$
} }
catch (CertificateException exc) catch (CertificateException exc)
{ {
String text = UniversalSecurityPlugin String text = UniversalSecurityProperties.RESID_SECURITY_KEY_LOAD_ERROR_;
.getString("RESID_SECURITY_KEY_LOAD_ERROR_"); //$NON-NLS-1$
text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$ text = StringModifier.change(text, "%1", storePath); //$NON-NLS-1$
String msg = UniversalSecurityPlugin String msg = UniversalSecurityProperties.RESID_SECURITY_LOAD_KEYSTORE_ERROR_;
.getString("RESID_SECURITY_LOAD_KEYSTORE_ERROR_"); //$NON-NLS-1$
Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES,
IStatus.ERROR, text, exc); IStatus.ERROR, text, exc);
ErrorDialog.openError(UniversalSecurityPlugin ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
.getActiveWorkbenchShell(), UniversalSecurityPlugin
.getString("SEC_MSG"), msg, err); //$NON-NLS-1$
} }
catch (KeyStoreException exc) catch (KeyStoreException exc)
{ {
String text = UniversalSecurityPlugin String text = UniversalSecurityProperties.RESID_SECURITY_INITIALIZE_ERROR_;
.getString("RESID_SECURITY_INITIALIZE_ERROR_"); //$NON-NLS-1$
text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$ text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$
.getKeyStoreLocation()); .getKeyStoreLocation());
String msg = UniversalSecurityPlugin String msg = UniversalSecurityProperties.RESID_SECURITY_LOAD_KEYSTORE_ERROR_;
.getString("RESID_SECURITY_LOAD_KEYSTORE_ERROR_"); //$NON-NLS-1$
Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES,
IStatus.ERROR, text, exc); IStatus.ERROR, text, exc);
ErrorDialog.openError(UniversalSecurityPlugin ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
.getActiveWorkbenchShell(), UniversalSecurityPlugin
.getString("SEC_MSG"), msg, err); //$NON-NLS-1$
} }
catch (NoSuchProviderException exc2) catch (NoSuchProviderException exc2)
{ {
String text = UniversalSecurityPlugin String text = UniversalSecurityProperties.RESID_SECURITY_SECURITY_PROVIDER_ERROR_;
.getString("RESID_SECURITY_SECURITY_PROVIDER_ERROR_"); //$NON-NLS-1$ String msg = UniversalSecurityProperties.RESID_SECURITY_INITIALIZE_ERROR_;
String msg = UniversalSecurityPlugin
.getString("RESID_SECURITY_INITIALIZE_ERROR_"); //$NON-NLS-1$
msg = StringModifier.change(msg, "%1", UniversalSecurityPlugin //$NON-NLS-1$ msg = StringModifier.change(msg, "%1", UniversalSecurityPlugin //$NON-NLS-1$
.getKeyStoreLocation()); .getKeyStoreLocation());
Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES,
IStatus.ERROR, text, exc2); IStatus.ERROR, text, exc2);
ErrorDialog.openError(UniversalSecurityPlugin ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
.getActiveWorkbenchShell(), UniversalSecurityPlugin
.getString("SEC_MSG"), msg, err); //$NON-NLS-1$
} }
catch (NoSuchAlgorithmException exc2) catch (NoSuchAlgorithmException exc2)
{ {
String text = UniversalSecurityPlugin String text = UniversalSecurityProperties.RESID_SECURITY_ALGORITHM_ERROR_;
.getString("RESID_SECURITY_ALGORITHM_ERROR_"); //$NON-NLS-1$
text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$ text = StringModifier.change(text, "%1", UniversalSecurityPlugin //$NON-NLS-1$
.getKeyStoreLocation()); .getKeyStoreLocation());
String msg = UniversalSecurityPlugin String msg = UniversalSecurityProperties.RESID_SECURITY_LOAD_KEYSTORE_ERROR_;
.getString("RESID_SECURITY_LOAD_KEYSTORE_ERROR_"); //$NON-NLS-1$
Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, Status err = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES,
IStatus.ERROR, text, exc2); IStatus.ERROR, text, exc2);
ErrorDialog.openError(UniversalSecurityPlugin ErrorDialog.openError(UniversalSecurityPlugin.getActiveWorkbenchShell(), UniversalSecurityProperties.RESID_SECURITY_SEC_MSG, msg, err);
.getActiveWorkbenchShell(), UniversalSecurityPlugin
.getString("SEC_MSG"), msg, err); //$NON-NLS-1$
} }
@ -513,7 +484,7 @@ public class UniversalSecurityPreferencePage extends PreferencePage implements
boolean sel = _viewer.getSelection().isEmpty(); boolean sel = _viewer.getSelection().isEmpty();
_renameButton.setEnabled(!sel); _renameButton.setEnabled(!sel);
_removeButton.setEnabled(!sel); _removeButton.setEnabled(!sel);
_propertiesButton.setEnabled(!sel); _propertiesButton.setEnabled(!sel);
} }
public void widgetSelected(SelectionEvent e) public void widgetSelected(SelectionEvent e)
@ -522,12 +493,12 @@ public class UniversalSecurityPreferencePage extends PreferencePage implements
boolean sel = _viewer.getSelection().isEmpty(); boolean sel = _viewer.getSelection().isEmpty();
_renameButton.setEnabled(!sel); _renameButton.setEnabled(!sel);
_removeButton.setEnabled(!sel); _removeButton.setEnabled(!sel);
_propertiesButton.setEnabled(!sel); _propertiesButton.setEnabled(!sel);
} }
public void widgetDefaultSelected(SelectionEvent e) public void widgetDefaultSelected(SelectionEvent e)
{ {
widgetSelected(e); widgetSelected(e);
} }
} }

View file

@ -7,12 +7,13 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* David Dykstal (IBM) - [230815] fix layout problems with long labels * David Dykstal (IBM) - [230815] fix layout problems with long labels
* Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format
*******************************************************************************/ *******************************************************************************/
@ -27,7 +28,6 @@ import java.security.cert.CertificateException;
import java.util.ArrayList; import java.util.ArrayList;
import org.eclipse.dstore.core.util.ssl.DStoreKeyStore; import org.eclipse.dstore.core.util.ssl.DStoreKeyStore;
import org.eclipse.rse.internal.dstore.security.UniversalSecurityPlugin;
import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; 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.GridUtil;
import org.eclipse.rse.ui.SystemBaseForm; import org.eclipse.rse.ui.SystemBaseForm;
@ -53,23 +53,23 @@ public class CertificateForm extends SystemBaseForm
private String _aliasStr; private String _aliasStr;
private String _pathStr; private String _pathStr;
private ArrayList listenerList; private ArrayList listenerList;
private Button _browseButton; private Button _browseButton;
public Shell _shell; public Shell _shell;
public CertificateForm(Shell shell, ISystemMessageLine msgLine) public CertificateForm(Shell shell, ISystemMessageLine msgLine)
{ {
super(shell, msgLine); super(shell, msgLine);
listenerList = new ArrayList(); listenerList = new ArrayList();
_shell = shell; _shell = shell;
} }
public Control getInitialFocusControl() public Control getInitialFocusControl()
{ {
return _pathField; return _pathField;
} }
public Control createContents(Composite c){ public Control createContents(Composite c){
GridData data; GridData data;
Composite nameGroup = new Composite(c, SWT.NONE); Composite nameGroup = new Composite(c, SWT.NONE);
@ -78,29 +78,29 @@ public class CertificateForm extends SystemBaseForm
data = GridUtil.createFill(); data = GridUtil.createFill();
nameGroup.setLayoutData(data); nameGroup.setLayoutData(data);
nameGroup.setLayout(layout); nameGroup.setLayout(layout);
Label lblPath = new Label(nameGroup, SWT.NONE); Label lblPath = new Label(nameGroup, SWT.NONE);
lblPath.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_FILE)); lblPath.setText(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_FILE);
_pathField = new Text(nameGroup, SWT.BORDER); _pathField = new Text(nameGroup, SWT.BORDER);
_pathField.setLayoutData(GridUtil.createHorizontalFill()); _pathField.setLayoutData(GridUtil.createHorizontalFill());
((GridData)_pathField.getLayoutData()).widthHint = 150; ((GridData)_pathField.getLayoutData()).widthHint = 150;
_pathField.setText(""); //$NON-NLS-1$ _pathField.setText(""); //$NON-NLS-1$
_browseButton = new Button(nameGroup, SWT.PUSH); _browseButton = new Button(nameGroup, SWT.PUSH);
_browseButton.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_BROWSE)); _browseButton.setText(UniversalSecurityProperties.RESID_SECURITY_BROWSE);
_browseButton.addListener(SWT.Selection, this); _browseButton.addListener(SWT.Selection, this);
Label lblName = new Label(nameGroup, SWT.NONE); Label lblName = new Label(nameGroup, SWT.NONE);
lblName.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_ALIAS)); lblName.setText(UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_ALIAS);
_aliasField = new Text(nameGroup, SWT.BORDER); _aliasField = new Text(nameGroup, SWT.BORDER);
_aliasField.setText(""); //$NON-NLS-1$ _aliasField.setText(""); //$NON-NLS-1$
_aliasField.setLayoutData(GridUtil.createHorizontalFill()); _aliasField.setLayoutData(GridUtil.createHorizontalFill());
_aliasField.addListener(SWT.Modify, this); _aliasField.addListener(SWT.Modify, this);
_pathField.addListener(SWT.Modify, this); _pathField.addListener(SWT.Modify, this);
return _pathField; return _pathField;
} }
@ -120,29 +120,29 @@ public class CertificateForm extends SystemBaseForm
//setButtonState(); //setButtonState();
_pathStr = _pathField.getText(); _pathStr = _pathField.getText();
_aliasStr = _aliasField.getText(); _aliasStr = _aliasField.getText();
NotifyListeners(event); NotifyListeners(event);
} }
} }
public void NotifyListeners(Event event){ public void NotifyListeners(Event event){
for(int i=0;i<listenerList.size();i++){ for(int i=0;i<listenerList.size();i++){
((Listener)listenerList.get(i)).handleEvent(event); ((Listener)listenerList.get(i)).handleEvent(event);
} }
} }
public boolean validateDialog(){ public boolean validateDialog(){
return (_aliasField.getText().trim().length()>0 && _pathField.getText().trim().length()>0); return (_aliasField.getText().trim().length()>0 && _pathField.getText().trim().length()>0);
} }
private void showFileDialog(){ private void showFileDialog(){
String currentSource = _pathField.getText(); String currentSource = _pathField.getText();
FileDialog dlg = new FileDialog(_shell, SWT.OPEN); FileDialog dlg = new FileDialog(_shell, SWT.OPEN);
dlg.setFileName(currentSource); dlg.setFileName(currentSource);
dlg.setFilterExtensions(new String[]{"*.cer", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ dlg.setFilterExtensions(new String[]{"*.cer", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$
String source = dlg.open(); String source = dlg.open();
if(source!=null) if(source!=null)
@ -157,30 +157,30 @@ public class CertificateForm extends SystemBaseForm
} }
_aliasField.setText(alias); _aliasField.setText(alias);
} }
} }
public Certificate loadCertificate(KeyStore ks) throws IOException, CertificateException, KeyStoreException { public Certificate loadCertificate(KeyStore ks) throws IOException, CertificateException, KeyStoreException {
Certificate fCertificate = DStoreKeyStore.loadCertificate(getPath()); Certificate fCertificate = DStoreKeyStore.loadCertificate(getPath());
DStoreKeyStore.addCertificateToKeyStore(ks, fCertificate, getAliasName()); DStoreKeyStore.addCertificateToKeyStore(ks, fCertificate, getAliasName());
return fCertificate; return fCertificate;
} }
public void registerListener(Listener listener){ public void registerListener(Listener listener){
listenerList.add(listener); listenerList.add(listener);
} }
public String getAliasName() public String getAliasName()
{ {
return _aliasStr; return _aliasStr;
} }
public String getPath() public String getPath()
{ {
return _pathStr; return _pathStr;
} }
} }

View file

@ -7,13 +7,14 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* David Dykstal (IBM) - [231913] increasing width of form to accomodate translation * David Dykstal (IBM) - [231913] increasing width of form to accommodate translation
* David Dykstal (IBM) - [232131] using ICU for DateFormat * 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; package org.eclipse.rse.internal.dstore.security.widgets;
@ -21,7 +22,6 @@ package org.eclipse.rse.internal.dstore.security.widgets;
import java.security.Key; import java.security.Key;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import org.eclipse.rse.internal.dstore.security.UniversalSecurityPlugin;
import org.eclipse.rse.internal.dstore.security.UniversalSecurityProperties; 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.GridUtil;
import org.eclipse.rse.internal.dstore.security.util.StringModifier; import org.eclipse.rse.internal.dstore.security.util.StringModifier;
@ -47,12 +47,12 @@ public class CertificatePropertiesForm extends SystemBaseForm
{ {
this(shell, certificate, alias, false); this(shell, certificate, alias, false);
} }
public CertificatePropertiesForm(Shell shell, Object certificate) public CertificatePropertiesForm(Shell shell, Object certificate)
{ {
this(shell, certificate, false); this(shell, certificate, false);
} }
public CertificatePropertiesForm(Shell shell, Object certificate, String alias, boolean advanced) public CertificatePropertiesForm(Shell shell, Object certificate, String alias, boolean advanced)
{ {
super(shell, null); super(shell, null);
@ -60,12 +60,12 @@ public class CertificatePropertiesForm extends SystemBaseForm
_alias = alias; _alias = alias;
_advanced = advanced; _advanced = advanced;
} }
public CertificatePropertiesForm(Shell shell, Object certificate, boolean advanced) public CertificatePropertiesForm(Shell shell, Object certificate, boolean advanced)
{ {
this(shell, certificate, null, advanced); this(shell, certificate, null, advanced);
} }
public Control createContents(Composite parent) public Control createContents(Composite parent)
{ {
@ -78,7 +78,7 @@ public class CertificatePropertiesForm extends SystemBaseForm
return createSimpleContents(parent); return createSimpleContents(parent);
} }
} }
public Control createSimpleContents(Composite parent) public Control createSimpleContents(Composite parent)
{ {
Composite content = new Composite(parent, SWT.NONE); Composite content = new Composite(parent, SWT.NONE);
@ -89,89 +89,89 @@ public class CertificatePropertiesForm extends SystemBaseForm
layout.numColumns = 2; layout.numColumns = 2;
content.setLayout(layout); content.setLayout(layout);
content.setLayoutData(data); content.setLayoutData(data);
if (_alias != null) if (_alias != null)
{ {
Label lblAlias = new Label(content, SWT.NONE); Label lblAlias = new Label(content, SWT.NONE);
lblAlias.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_PROP_ALIAS_LBL)); lblAlias.setText(UniversalSecurityProperties.RESID_SECURITY_PROP_ALIAS_LBL);
data = new GridData(); data = new GridData();
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblAlias.setLayoutData(data); lblAlias.setLayoutData(data);
Label lblAliasValue = new Label(content, SWT.NONE); Label lblAliasValue = new Label(content, SWT.NONE);
lblAliasValue.setText(_alias); lblAliasValue.setText(_alias);
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblAliasValue.setLayoutData(data); lblAliasValue.setLayoutData(data);
} }
Label lblVersion = new Label(content, SWT.NONE); Label lblVersion = new Label(content, SWT.NONE);
lblVersion.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIF_VERSION_LBL)); lblVersion.setText(UniversalSecurityProperties.RESID_SECURITY_CERTIF_VERSION_LBL);
data = new GridData(); data = new GridData();
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblVersion.setLayoutData(data); lblVersion.setLayoutData(data);
Label lblVersionValue = new Label(content, SWT.NONE); Label lblVersionValue = new Label(content, SWT.NONE);
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblVersionValue.setLayoutData(data); lblVersionValue.setLayoutData(data);
Label lblIssuedTo = new Label(content, SWT.NONE); Label lblIssuedTo = new Label(content, SWT.NONE);
lblIssuedTo.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_ISSUED_TO_LBL)); lblIssuedTo.setText(UniversalSecurityProperties.RESID_SECURITY_ISSUED_TO_LBL);
data = new GridData(); data = new GridData();
data.verticalAlignment = GridData.BEGINNING; data.verticalAlignment = GridData.BEGINNING;
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblIssuedTo.setLayoutData(data); lblIssuedTo.setLayoutData(data);
Text lblIssuedToValue = new Text(content, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP) ; Text lblIssuedToValue = new Text(content, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP) ;
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.heightHint = 60; data.heightHint = 60;
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblIssuedToValue.setLayoutData(data); lblIssuedToValue.setLayoutData(data);
Label lblIssuedBy = new Label(content, SWT.NONE); Label lblIssuedBy = new Label(content, SWT.NONE);
lblIssuedBy.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_ISSUED_BY_LBL)); lblIssuedBy.setText(UniversalSecurityProperties.RESID_SECURITY_ISSUED_BY_LBL);
data = new GridData(); data = new GridData();
data.horizontalIndent = 5; data.horizontalIndent = 5;
data.verticalAlignment = GridData.BEGINNING; data.verticalAlignment = GridData.BEGINNING;
lblIssuedBy.setLayoutData(data); lblIssuedBy.setLayoutData(data);
Text lblIssuedByValue = new Text(content, SWT.BORDER |SWT.READ_ONLY | SWT.WRAP); Text lblIssuedByValue = new Text(content, SWT.BORDER |SWT.READ_ONLY | SWT.WRAP);
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = 5; data.horizontalIndent = 5;
data.heightHint = 60; data.heightHint = 60;
lblIssuedByValue.setLayoutData(data); lblIssuedByValue.setLayoutData(data);
Label lblValidity = new Label(content, SWT.NONE); Label lblValidity = new Label(content, SWT.NONE);
lblValidity.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_VALIDITY_LBL)); lblValidity.setText(UniversalSecurityProperties.RESID_SECURITY_VALIDITY_LBL);
data = new GridData(); data = new GridData();
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblValidity.setLayoutData(data); lblValidity.setLayoutData(data);
Label lblValidityValue = new Label(content, SWT.NONE); Label lblValidityValue = new Label(content, SWT.NONE);
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblValidityValue.setLayoutData(data); lblValidityValue.setLayoutData(data);
Label lblAlgorithm = new Label(content, SWT.NONE); Label lblAlgorithm = new Label(content, SWT.NONE);
lblAlgorithm.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_ALGORITHM_LBL)); lblAlgorithm.setText(UniversalSecurityProperties.RESID_SECURITY_ALGORITHM_LBL);
data = new GridData(); data = new GridData();
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblAlgorithm.setLayoutData(data); lblAlgorithm.setLayoutData(data);
Label lblAlgorithmValue = new Label(content, SWT.NONE); Label lblAlgorithmValue = new Label(content, SWT.NONE);
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblAlgorithmValue.setLayoutData(data); lblAlgorithmValue.setLayoutData(data);
if(_certificate instanceof X509Certificate){ if(_certificate instanceof X509Certificate){
lblVersionValue.setText(((X509Certificate)_certificate).getType() + " V."+((X509Certificate)_certificate).getVersion()); //$NON-NLS-1$ lblVersionValue.setText(((X509Certificate)_certificate).getType() + " V."+((X509Certificate)_certificate).getVersion()); //$NON-NLS-1$
lblIssuedToValue.setText(((X509Certificate)_certificate).getSubjectDN().getName()); lblIssuedToValue.setText(((X509Certificate)_certificate).getSubjectDN().getName());
lblIssuedByValue.setText(((X509Certificate)_certificate).getIssuerDN().getName()); lblIssuedByValue.setText(((X509Certificate)_certificate).getIssuerDN().getName());
DateFormat df = DateFormat.getDateInstance(DateFormat.LONG); DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
String validity = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_VALIDITY_PERIOD); String validity = UniversalSecurityProperties.RESID_SECURITY_VALIDITY_PERIOD;
validity = StringModifier.change(validity,"%1", df.format(((X509Certificate)_certificate).getNotBefore())); //$NON-NLS-1$ 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$ validity = StringModifier.change(validity,"%2", df.format(((X509Certificate)_certificate).getNotAfter())); //$NON-NLS-1$
@ -181,11 +181,11 @@ public class CertificatePropertiesForm extends SystemBaseForm
lblVersionValue.setText(((Key)_certificate).getFormat()); lblVersionValue.setText(((Key)_certificate).getFormat());
lblAlgorithmValue.setText(((Key)_certificate).getAlgorithm()); lblAlgorithmValue.setText(((Key)_certificate).getAlgorithm());
} }
return content; return content;
} }
public Control createAdvancedContents(Composite parent) public Control createAdvancedContents(Composite parent)
{ {
Composite content = new Composite(parent, SWT.NONE); Composite content = new Composite(parent, SWT.NONE);
@ -196,89 +196,89 @@ public class CertificatePropertiesForm extends SystemBaseForm
layout.numColumns = 2; layout.numColumns = 2;
content.setLayout(layout); content.setLayout(layout);
content.setLayoutData(data); content.setLayoutData(data);
if (_alias != null) if (_alias != null)
{ {
Label lblAlias = new Label(content, SWT.NONE); Label lblAlias = new Label(content, SWT.NONE);
lblAlias.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_PROP_ALIAS_LBL)); lblAlias.setText(UniversalSecurityProperties.RESID_SECURITY_PROP_ALIAS_LBL);
data = new GridData(); data = new GridData();
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblAlias.setLayoutData(data); lblAlias.setLayoutData(data);
Label lblAliasValue = new Label(content, SWT.NONE); Label lblAliasValue = new Label(content, SWT.NONE);
lblAliasValue.setText(_alias); lblAliasValue.setText(_alias);
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblAliasValue.setLayoutData(data); lblAliasValue.setLayoutData(data);
} }
Label lblVersion = new Label(content, SWT.NONE); Label lblVersion = new Label(content, SWT.NONE);
lblVersion.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_CERTIF_VERSION_LBL)); lblVersion.setText(UniversalSecurityProperties.RESID_SECURITY_CERTIF_VERSION_LBL);
data = new GridData(); data = new GridData();
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblVersion.setLayoutData(data); lblVersion.setLayoutData(data);
Label lblVersionValue = new Label(content, SWT.NONE); Label lblVersionValue = new Label(content, SWT.NONE);
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblVersionValue.setLayoutData(data); lblVersionValue.setLayoutData(data);
Label lblIssuedTo = new Label(content, SWT.NONE); Label lblIssuedTo = new Label(content, SWT.NONE);
lblIssuedTo.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_ISSUED_TO_LBL)); lblIssuedTo.setText(UniversalSecurityProperties.RESID_SECURITY_ISSUED_TO_LBL);
data = new GridData(); data = new GridData();
data.verticalAlignment = GridData.BEGINNING; data.verticalAlignment = GridData.BEGINNING;
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblIssuedTo.setLayoutData(data); lblIssuedTo.setLayoutData(data);
Text lblIssuedToValue = new Text(content, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP) ; Text lblIssuedToValue = new Text(content, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP) ;
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.heightHint = 60; data.heightHint = 60;
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblIssuedToValue.setLayoutData(data); lblIssuedToValue.setLayoutData(data);
Label lblIssuedBy = new Label(content, SWT.NONE); Label lblIssuedBy = new Label(content, SWT.NONE);
lblIssuedBy.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_ISSUED_BY_LBL)); lblIssuedBy.setText(UniversalSecurityProperties.RESID_SECURITY_ISSUED_BY_LBL);
data = new GridData(); data = new GridData();
data.horizontalIndent = 5; data.horizontalIndent = 5;
data.verticalAlignment = GridData.BEGINNING; data.verticalAlignment = GridData.BEGINNING;
lblIssuedBy.setLayoutData(data); lblIssuedBy.setLayoutData(data);
Text lblIssuedByValue = new Text(content, SWT.BORDER |SWT.READ_ONLY | SWT.WRAP); Text lblIssuedByValue = new Text(content, SWT.BORDER |SWT.READ_ONLY | SWT.WRAP);
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = 5; data.horizontalIndent = 5;
data.heightHint = 60; data.heightHint = 60;
lblIssuedByValue.setLayoutData(data); lblIssuedByValue.setLayoutData(data);
Label lblValidity = new Label(content, SWT.NONE); Label lblValidity = new Label(content, SWT.NONE);
lblValidity.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_VALIDITY_LBL)); lblValidity.setText(UniversalSecurityProperties.RESID_SECURITY_VALIDITY_LBL);
data = new GridData(); data = new GridData();
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblValidity.setLayoutData(data); lblValidity.setLayoutData(data);
Label lblValidityValue = new Label(content, SWT.NONE); Label lblValidityValue = new Label(content, SWT.NONE);
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblValidityValue.setLayoutData(data); lblValidityValue.setLayoutData(data);
Label lblAlgorithm = new Label(content, SWT.NONE); Label lblAlgorithm = new Label(content, SWT.NONE);
lblAlgorithm.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_ALGORITHM_LBL)); lblAlgorithm.setText(UniversalSecurityProperties.RESID_SECURITY_ALGORITHM_LBL);
data = new GridData(); data = new GridData();
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblAlgorithm.setLayoutData(data); lblAlgorithm.setLayoutData(data);
Label lblAlgorithmValue = new Label(content, SWT.NONE); Label lblAlgorithmValue = new Label(content, SWT.NONE);
data = new GridData(GridData.FILL_HORIZONTAL); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = 5; data.horizontalIndent = 5;
lblAlgorithmValue.setLayoutData(data); lblAlgorithmValue.setLayoutData(data);
if(_certificate instanceof X509Certificate){ if(_certificate instanceof X509Certificate){
lblVersionValue.setText(((X509Certificate)_certificate).getType() + " V."+((X509Certificate)_certificate).getVersion()); //$NON-NLS-1$ lblVersionValue.setText(((X509Certificate)_certificate).getType() + " V."+((X509Certificate)_certificate).getVersion()); //$NON-NLS-1$
lblIssuedToValue.setText(((X509Certificate)_certificate).getSubjectDN().getName()); lblIssuedToValue.setText(((X509Certificate)_certificate).getSubjectDN().getName());
lblIssuedByValue.setText(((X509Certificate)_certificate).getIssuerDN().getName()); lblIssuedByValue.setText(((X509Certificate)_certificate).getIssuerDN().getName());
DateFormat df = DateFormat.getDateInstance(DateFormat.LONG); DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
String validity = UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_VALIDITY_PERIOD); String validity = UniversalSecurityProperties.RESID_SECURITY_VALIDITY_PERIOD;
validity = StringModifier.change(validity,"%1", df.format(((X509Certificate)_certificate).getNotBefore())); //$NON-NLS-1$ 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$ validity = StringModifier.change(validity,"%2", df.format(((X509Certificate)_certificate).getNotAfter())); //$NON-NLS-1$
@ -288,7 +288,7 @@ public class CertificatePropertiesForm extends SystemBaseForm
lblVersionValue.setText(((Key)_certificate).getFormat()); lblVersionValue.setText(((Key)_certificate).getFormat());
lblAlgorithmValue.setText(((Key)_certificate).getAlgorithm()); lblAlgorithmValue.setText(((Key)_certificate).getAlgorithm());
} }
return content; return content;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2007 IBM Corporation and others. * Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,12 +7,12 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * Martin Oberhuber (Wind River) - [235626] Convert dstore.security to MessageBundle format
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.dstore.security.wizards; package org.eclipse.rse.internal.dstore.security.wizards;
@ -25,7 +25,6 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.wizard.Wizard; 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.UniversalSecurityProperties;
import org.eclipse.rse.internal.dstore.security.preference.CertTableContentProvider; 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.X509CertificateElement;
@ -48,26 +47,26 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableColumn;
public class SystemImportCertWizardMainPage public class SystemImportCertWizardMainPage
extends AbstractSystemWizardPage extends AbstractSystemWizardPage
implements Listener implements Listener
{ {
protected SystemMessage errorMessage; protected SystemMessage errorMessage;
protected ISystemValidator nameValidator; protected ISystemValidator nameValidator;
protected ISystemMessageLine msgLine; protected ISystemMessageLine msgLine;
private List _certificates; private List _certificates;
private Button _propertiesButton; private Button _propertiesButton;
private TableViewer _viewer; private TableViewer _viewer;
/** /**
* Constructor. * Constructor.
*/ */
public SystemImportCertWizardMainPage(Wizard wizard, List certs) public SystemImportCertWizardMainPage(Wizard wizard, List certs)
{ {
super(wizard, "NewCertificate", //$NON-NLS-1$ super(wizard, "NewCertificate", //$NON-NLS-1$
UniversalSecurityProperties.RESID_SECURITY_TRUST_WIZ_CERTIFICATE_TITLE, UniversalSecurityProperties.RESID_SECURITY_TRUST_WIZ_CERTIFICATE_TITLE,
UniversalSecurityProperties.RESID_SECURITY_TRUST_WIZ_CERTIFICATE_DESC); UniversalSecurityProperties.RESID_SECURITY_TRUST_WIZ_CERTIFICATE_DESC);
_certificates = certs; _certificates = certs;
} }
@ -89,18 +88,18 @@ public class SystemImportCertWizardMainPage
SystemWidgetHelpers.createLabel(verbiage, UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_INFORMATION); SystemWidgetHelpers.createLabel(verbiage, UniversalSecurityProperties.RESID_SECURITY_CERTIFICATE_INFORMATION);
createTableViewer(verbiage); createTableViewer(verbiage);
Composite b = new Composite(parent, SWT.NULL); Composite b = new Composite(parent, SWT.NULL);
GridLayout blayout = new GridLayout(); GridLayout blayout = new GridLayout();
GridData bdata = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.END); GridData bdata = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.END);
blayout.numColumns = 3; blayout.numColumns = 3;
b.setLayout(blayout); b.setLayout(blayout);
b.setLayoutData(bdata); b.setLayoutData(bdata);
_propertiesButton = SystemWidgetHelpers.createPushButton(b, UniversalSecurityProperties.RESID_SECURITY_PROPERTIES_LBL, this); _propertiesButton = SystemWidgetHelpers.createPushButton(b, UniversalSecurityProperties.RESID_SECURITY_PROPERTIES_LBL, this);
return _propertiesButton; return _propertiesButton;
} }
private void createTableViewer(Composite parent) private void createTableViewer(Composite parent)
{ {
@ -119,15 +118,15 @@ public class SystemImportCertWizardMainPage
TableLayout tableLayout = new TableLayout(); TableLayout tableLayout = new TableLayout();
TableColumn toColumn = new TableColumn(table, SWT.LEFT); TableColumn toColumn = new TableColumn(table, SWT.LEFT);
toColumn.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_TO)); toColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_TO);
tableLayout.addColumnData(new ColumnPixelData(90)); tableLayout.addColumnData(new ColumnPixelData(90));
TableColumn frmColumn = new TableColumn(table, SWT.LEFT); TableColumn frmColumn = new TableColumn(table, SWT.LEFT);
frmColumn.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_FROM)); frmColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_ISSUED_FROM);
tableLayout.addColumnData(new ColumnPixelData(90)); tableLayout.addColumnData(new ColumnPixelData(90));
TableColumn expColumn = new TableColumn(table, SWT.RIGHT); TableColumn expColumn = new TableColumn(table, SWT.RIGHT);
expColumn.setText(UniversalSecurityPlugin.getString(UniversalSecurityProperties.RESID_SECURITY_PREF_EXPIRES)); expColumn.setText(UniversalSecurityProperties.RESID_SECURITY_PREF_EXPIRES);
tableLayout.addColumnData(new ColumnPixelData(180)); tableLayout.addColumnData(new ColumnPixelData(180));
table.setLayout(tableLayout); table.setLayout(tableLayout);
@ -136,9 +135,9 @@ public class SystemImportCertWizardMainPage
_viewer.setColumnProperties(properties); _viewer.setColumnProperties(properties);
_viewer.setContentProvider(new CertTableContentProvider()); _viewer.setContentProvider(new CertTableContentProvider());
_viewer.setLabelProvider(new NewCertTableLabelProvider()); _viewer.setLabelProvider(new NewCertTableLabelProvider());
if (_certificates != null) if (_certificates != null)
{ {
for (int i = 0; i < _certificates.size(); i++) for (int i = 0; i < _certificates.size(); i++)
{ {
_viewer.add(getElement(_certificates.get(i))); _viewer.add(getElement(_certificates.get(i)));
@ -146,31 +145,31 @@ public class SystemImportCertWizardMainPage
} }
} }
public void handleEvent(Event e) public void handleEvent(Event e)
{ {
if (e.widget == _propertiesButton) if (e.widget == _propertiesButton)
{ {
IStructuredSelection sel = (IStructuredSelection)_viewer.getSelection(); IStructuredSelection sel = (IStructuredSelection)_viewer.getSelection();
sel.getFirstElement(); sel.getFirstElement();
X509CertificatePropertiesDialog dlg = new X509CertificatePropertiesDialog(getShell(), (X509CertificateElement)sel.getFirstElement()); X509CertificatePropertiesDialog dlg = new X509CertificatePropertiesDialog(getShell(), (X509CertificateElement)sel.getFirstElement());
dlg.open(); dlg.open();
} }
} }
public X509CertificateElement getElement(Object cert) public X509CertificateElement getElement(Object cert)
{ {
if (cert instanceof X509Certificate) if (cert instanceof X509Certificate)
{ {
return new X509CertificateElement(null, return new X509CertificateElement(null,
UniversalSecurityProperties.RESID_SECURITY_TRUSTED_CERTIFICATE, UniversalSecurityProperties.RESID_SECURITY_TRUSTED_CERTIFICATE,
(X509Certificate)cert); (X509Certificate)cert);
} }
return null; return null;
} }
/** /**
* Return the Control to be given initial focus. * Return the Control to be given initial focus.
* Override from parent. Return control to be given initial focus. * Override from parent. Return control to be given initial focus.
@ -179,31 +178,31 @@ public class SystemImportCertWizardMainPage
{ {
return _propertiesButton; return _propertiesButton;
} }
/** /**
* Init values using input data * Init values using input data
*/ */
protected void initializeInput() protected void initializeInput()
{ {
} }
/** /**
* Completes processing of the wizard. If this * Completes processing of the wizard. If this
* method returns true, the wizard will close; * method returns true, the wizard will close;
* otherwise, it will stay active. * otherwise, it will stay active.
* This method is an override from the parent Wizard class. * This method is an override from the parent Wizard class.
* *
* @return whether the wizard finished successfully * @return whether the wizard finished successfully
*/ */
public boolean performFinish() public boolean performFinish()
{ {
return true; return true;
} }
/** /**
* Return true if the page is complete, so to enable Finish. * Return true if the page is complete, so to enable Finish.
@ -213,6 +212,6 @@ public class SystemImportCertWizardMainPage
{ {
return true; return true;
} }
} }