View | Details | Raw Unified | Return to bug 220805 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/provisional/security/ui/services/package.html (-14 lines)
Removed Link Here
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<html>
3
<head>
4
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
   <title>Package-level Javadoc</title>
6
</head>
7
<body>
8
Equinox security UI-related services  
9
<h2>
10
Package Specification</h2>
11
<p>This package provides an infrastructure and helper utilities for the Equinox security UI services.
12
</p>
13
</body>
14
</html>
(-)src/org/eclipse/equinox/internal/provisional/security/ui/services/AuthorizationManager.java (-59 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.internal.provisional.security.ui.services;
12
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.ui.IWorkbenchWindow;
15
16
/**
17
 * The AuthorizationManager is the facility by which the end user
18
 * is informed of the current state of the system with respect to 
19
 * bundle authorization based security. 
20
 */
21
public abstract class AuthorizationManager {
22
23
	public AuthorizationManager() {
24
		//no content
25
	}
26
27
	/**
28
	 * Query whether the authorization system is enabled for the system.
29
	 * 
30
	 * @return <code>true</code> if and only if authorization is enabled 
31
	 */
32
	abstract public boolean isEnabled();
33
34
	/**
35
	 * Returns true when the system is in need of attention from the end
36
	 * user. This means that some unauthorized content has been encountered, and the 
37
	 * user has not yet inspected the situation.
38
	 * 
39
	 * @return <code>true</code> if user attention is required
40
	 */
41
	abstract public boolean needsAttention();
42
43
	/**
44
	 * Return an Eclipse IStatus object representing the current state of the 
45
	 * authorization system.
46
	 *
47
	 * @return IStatus code representing the system status
48
	 */
49
	abstract public IStatus getStatus();
50
51
	/**
52
	 * Open the authorization manager user interface so that the end
53
	 * user can view and edit the system's authorization state.
54
	 * 
55
	 * @param workbenchWindow the workbench window
56
	 */
57
	abstract public void displayManager(IWorkbenchWindow workbenchWindow);
58
59
}
(-)src/org/eclipse/equinox/internal/security/ui/preferences/CertificatesPage.java (+2 lines)
Lines 13-18 Link Here
13
import java.security.cert.Certificate;
13
import java.security.cert.Certificate;
14
import java.security.cert.X509Certificate;
14
import java.security.cert.X509Certificate;
15
import java.util.*;
15
import java.util.*;
16
import org.eclipse.equinox.internal.provisional.security.ui.X500PrincipalHelper;
17
import org.eclipse.equinox.internal.provisional.security.ui.X509CertificateViewDialog;
16
import org.eclipse.equinox.internal.security.ui.*;
18
import org.eclipse.equinox.internal.security.ui.*;
17
import org.eclipse.equinox.internal.security.ui.wizard.CertificateImportWizard;
19
import org.eclipse.equinox.internal.security.ui.wizard.CertificateImportWizard;
18
import org.eclipse.jface.preference.PreferencePage;
20
import org.eclipse.jface.preference.PreferencePage;
(-)src/org/eclipse/equinox/internal/security/ui/DefaultAuthorizationManager.java (-1 / +1 lines)
Lines 12-18 Link Here
12
12
13
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.core.runtime.Status;
14
import org.eclipse.core.runtime.Status;
15
import org.eclipse.equinox.internal.provisional.security.ui.services.AuthorizationManager;
15
import org.eclipse.equinox.internal.provisional.security.ui.AuthorizationManager;
16
import org.eclipse.osgi.internal.provisional.service.security.AuthorizationStatus;
16
import org.eclipse.osgi.internal.provisional.service.security.AuthorizationStatus;
17
import org.eclipse.ui.IWorkbenchWindow;
17
import org.eclipse.ui.IWorkbenchWindow;
18
18
(-)src/org/eclipse/equinox/internal/security/ui/Activator.java (-1 / +1 lines)
Lines 15-21 Link Here
15
import java.util.Hashtable;
15
import java.util.Hashtable;
16
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Status;
17
import org.eclipse.core.runtime.Status;
18
import org.eclipse.equinox.internal.provisional.security.ui.services.AuthorizationManager;
18
import org.eclipse.equinox.internal.provisional.security.ui.AuthorizationManager;
19
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.jface.resource.ImageDescriptor;
20
import org.eclipse.osgi.internal.provisional.service.security.AuthorizationEngine;
20
import org.eclipse.osgi.internal.provisional.service.security.AuthorizationEngine;
21
import org.eclipse.osgi.service.resolver.PlatformAdmin;
21
import org.eclipse.osgi.service.resolver.PlatformAdmin;
(-)src/org/eclipse/equinox/internal/security/ui/X509CertificateViewDialog.java (-217 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008,  Jay Rosenthal
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors:
10
 *     Jay Rosenthal - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.equinox.internal.security.ui;
14
15
import java.security.cert.X509Certificate;
16
import java.text.DateFormat;
17
import org.eclipse.equinox.internal.security.ui.wizard.CertificateViewer;
18
import org.eclipse.jface.dialogs.IDialogConstants;
19
import org.eclipse.jface.dialogs.TitleAreaDialog;
20
import org.eclipse.jface.resource.JFaceResources;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.graphics.Font;
23
import org.eclipse.swt.graphics.Image;
24
import org.eclipse.swt.layout.*;
25
import org.eclipse.swt.widgets.*;
26
27
public class X509CertificateViewDialog extends TitleAreaDialog {
28
	private final static String titleImageName = "/titleAreaCert.gif"; //$NON-NLS-1$
29
	private X509Certificate theCert;
30
	private static final DateFormat _df = DateFormat.getDateInstance(DateFormat.LONG);
31
	private X500PrincipalHelper nameHelper = new X500PrincipalHelper();
32
33
	// We use the "bannerFont" for our bold font
34
	private static Font boldFont = JFaceResources.getBannerFont();
35
	private Image titleImage;
36
37
	public X509CertificateViewDialog(Shell parentShell, X509Certificate cert) {
38
		super(parentShell);
39
		this.theCert = cert;
40
	}
41
42
	protected Control createContents(Composite parent) {
43
		return super.createContents(parent);
44
	}
45
46
	protected Control createDialogArea(Composite parent) {
47
		nameHelper.setPrincipal(theCert.getSubjectX500Principal());
48
49
		setTitle((nameHelper.getCN() != null ? nameHelper.getCN() : nameHelper.getOU()));
50
51
		titleImage = Activator.getImageDescriptor(titleImageName).createImage();
52
53
		if (titleImage != null)
54
			setTitleImage(titleImage);
55
56
		Composite composite = (Composite) super.createDialogArea(parent);
57
58
		TabFolder tabFolder = new TabFolder(composite, SWT.BORDER);
59
		GridData bdata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL);
60
		tabFolder.setLayoutData(bdata);
61
62
		createBasicTab(tabFolder);
63
64
		createAdvancedTab(tabFolder);
65
66
		return composite;
67
	}
68
69
	private void createBasicTab(TabFolder tabFolder) {
70
		String displayName = null;
71
		int labelIndent = 10;
72
		int dataIdent = 10;
73
74
		TabItem basicTab = new TabItem(tabFolder, SWT.NULL);
75
		basicTab.setText(SecurityUIMsg.CERTVIEW_LABEL_BASIC);
76
		Composite basicTabComposite = new Composite(tabFolder, SWT.NONE);
77
78
		GridLayout tabLayout = new GridLayout();
79
		tabLayout.numColumns = 2;
80
		basicTabComposite.setLayout(tabLayout);
81
82
		Label issueToLabel = new Label(basicTabComposite, SWT.NONE);
83
		issueToLabel.setText(SecurityUIMsg.CERTPROP_X509_ISSUED_TO);
84
		issueToLabel.setFont(boldFont);
85
		configureLayout(issueToLabel, 2, 0, 0, 0);
86
87
		// Display the RDNs of the Subject
88
		nameHelper.setPrincipal(theCert.getSubjectX500Principal());
89
90
		Label CNLabel = new Label(basicTabComposite, SWT.NONE);
91
		CNLabel.setText(SecurityUIMsg.X500_LABEL_CN);
92
		configureLayout(CNLabel, 0, 0, labelIndent, 0);
93
94
		Label subjectCN = new Label(basicTabComposite, SWT.NONE);
95
		displayName = nameHelper.getCN();
96
		subjectCN.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
97
		configureLayout(subjectCN, 0, 0, dataIdent, 0);
98
99
		Label OLabel = new Label(basicTabComposite, SWT.NONE);
100
		OLabel.setText(SecurityUIMsg.X500_LABEL_O);
101
		configureLayout(OLabel, 0, 0, labelIndent, 0);
102
103
		Label subjectO = new Label(basicTabComposite, SWT.NONE);
104
		displayName = nameHelper.getO();
105
		subjectO.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
106
		configureLayout(subjectO, 0, 0, dataIdent, 0);
107
108
		Label OULabel = new Label(basicTabComposite, SWT.NONE);
109
		OULabel.setText(SecurityUIMsg.X500_LABEL_OU);
110
		configureLayout(OULabel, 0, 0, labelIndent, 0);
111
112
		Label subjectOU = new Label(basicTabComposite, SWT.NONE);
113
		displayName = nameHelper.getOU();
114
		subjectOU.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
115
		configureLayout(subjectOU, 0, 0, dataIdent, 0);
116
117
		Label issueByLabel = new Label(basicTabComposite, SWT.NONE);
118
		issueByLabel.setText(SecurityUIMsg.CERTPROP_X509_ISSUED_BY);
119
		configureLayout(issueByLabel, 2, 0, 0, 0);
120
		issueByLabel.setFont(boldFont);
121
122
		// Display the RDNs of the Issuer
123
		nameHelper.setPrincipal(theCert.getIssuerX500Principal());
124
125
		Label CNLabel2 = new Label(basicTabComposite, SWT.NONE);
126
		CNLabel2.setText(SecurityUIMsg.X500_LABEL_CN);
127
		configureLayout(CNLabel2, 0, 0, labelIndent, 0);
128
129
		Label issuerCN = new Label(basicTabComposite, SWT.NONE);
130
		displayName = nameHelper.getCN();
131
		issuerCN.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
132
		configureLayout(issuerCN, 0, 0, dataIdent, 0);
133
134
		Label OLabel2 = new Label(basicTabComposite, SWT.NONE);
135
		OLabel2.setText(SecurityUIMsg.X500_LABEL_O);
136
		configureLayout(OLabel2, 0, 0, labelIndent, 0);
137
138
		Label issuerO = new Label(basicTabComposite, SWT.NONE);
139
		displayName = nameHelper.getO();
140
		issuerO.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
141
		configureLayout(issuerO, 0, 0, dataIdent, 0);
142
143
		Label OULabel2 = new Label(basicTabComposite, SWT.NONE);
144
		OULabel2.setText(SecurityUIMsg.X500_LABEL_OU);
145
		configureLayout(OULabel2, 0, 0, labelIndent, 0);
146
147
		Label issuerOU = new Label(basicTabComposite, SWT.NONE);
148
		displayName = nameHelper.getOU();
149
		issuerOU.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
150
		configureLayout(issuerOU, 0, 0, dataIdent, 0);
151
152
		Label datesLabel = new Label(basicTabComposite, SWT.NONE);
153
		datesLabel.setText(SecurityUIMsg.CERTVIEW_LABEL_VALIDITY_DATES);
154
		configureLayout(datesLabel, 2, 0, 0, 0);
155
		datesLabel.setFont(boldFont);
156
157
		Label validFrom = new Label(basicTabComposite, SWT.NONE);
158
		validFrom.setText(SecurityUIMsg.CERTPROP_X509_VALID_FROM);
159
		configureLayout(validFrom, 0, 0, labelIndent, 0);
160
161
		Label fromDate = new Label(basicTabComposite, SWT.NONE);
162
		fromDate.setText(_df.format(theCert.getNotBefore()));
163
		configureLayout(fromDate, 0, 0, dataIdent, 0);
164
165
		Label validTo = new Label(basicTabComposite, SWT.NONE);
166
		validTo.setText(SecurityUIMsg.CERTPROP_X509_VALID_TO);
167
		configureLayout(validTo, 0, 0, labelIndent, 0);
168
169
		Label toDate = new Label(basicTabComposite, SWT.NONE);
170
		toDate.setText(_df.format(theCert.getNotAfter()));
171
		configureLayout(toDate, 0, 0, dataIdent, 0);
172
173
		basicTab.setControl(basicTabComposite);
174
	}
175
176
	protected static void configureLayout(Control c, int horizontalSpan, int verticalSpan, int horizontalIndent, int vertIndent) {
177
		GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER);
178
179
		gd.horizontalSpan = horizontalSpan;
180
		gd.verticalSpan = verticalSpan;
181
		gd.horizontalIndent = horizontalIndent;
182
		gd.verticalIndent = vertIndent;
183
184
		c.setLayoutData(gd);
185
186
	}
187
188
	private void createAdvancedTab(final TabFolder tabFolder) {
189
		TabItem advancedTab = new TabItem(tabFolder, SWT.NULL);
190
		advancedTab.setText(SecurityUIMsg.CERTVIEW_LABEL_DETAILS);
191
		Composite advTabComposite = new Composite(tabFolder, SWT.NONE);
192
		advTabComposite.setLayout(new FillLayout(SWT.VERTICAL));
193
194
		CertificateViewer certViewer = new CertificateViewer(advTabComposite);
195
		certViewer.setCertificate(theCert);
196
		advancedTab.setControl(advTabComposite);
197
	}
198
199
	protected void setShellStyle(int newShellStyle) {
200
201
		super.setShellStyle(newShellStyle | SWT.RESIZE | SWT.DIALOG_TRIM);
202
	}
203
204
	protected void createButtonsForButtonBar(Composite parent) {
205
		// The default has only a "Close" button, but it returns the CANCEL Id
206
		createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, true);
207
208
	}
209
210
	public boolean close() {
211
		if (titleImage != null) {
212
			titleImage.dispose();
213
		}
214
		return super.close();
215
	}
216
217
}
(-)src/org/eclipse/equinox/internal/security/ui/X500PrincipalHelper.java (-276 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008,  Jay Rosenthal
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors:
10
 *     Jay Rosenthal - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.equinox.internal.security.ui;
14
15
import java.util.ArrayList;
16
import java.util.Iterator;
17
import javax.security.auth.x500.X500Principal;
18
19
/**
20
 * X500PrincipalHelper
21
 * <p>
22
 * Helper class to extract pieces (attributes) of an X500Principal object for display
23
 * in the UI.
24
 * <p>
25
 * This helper uses the X500Principal.RFC2253 format of X500Principal.getname() to parse an X500Principal name 
26
 *   into it's component parts. 
27
 *  <p> 
28
 * In principals which contain multiple occurrences of the same attribute,the default for all the methods 
29
 *  is to return the most significant (first) attribute found. 
30
 *    
31
 */
32
33
public class X500PrincipalHelper {
34
	public static int LEASTSIGNIFICANT = 0;
35
	public static int MOSTSIGNIFICANT = 1;
36
37
	public final static String attrCN = "CN"; //$NON-NLS-1$
38
	public final static String attrOU = "OU"; //$NON-NLS-1$
39
	public final static String attrO = "O"; //$NON-NLS-1$
40
	public final static String attrC = "C"; //$NON-NLS-1$
41
	public final static String attrL = "L"; //$NON-NLS-1$
42
	public final static String attrST = "ST"; //$NON-NLS-1$
43
	public final static String attrSTREET = "STREET";//$NON-NLS-1$
44
	public final static String attrEMAIL = "EMAILADDRESS"; //$NON-NLS-1$
45
	public final static String attrUID = "UID"; //$NON-NLS-1$
46
47
	ArrayList rdnNameArray = new ArrayList();
48
49
	private final static String attrTerminator = "="; //$NON-NLS-1$
50
51
	public X500PrincipalHelper() {
52
		// Do nothing constructor..
53
		// Wont be useful unless setPrincipal is called...
54
	}
55
56
	public X500PrincipalHelper(X500Principal principal) {
57
		parseDN(principal.getName(X500Principal.RFC2253));
58
	}
59
60
	/**
61
	 *  Set the X500Principal name object to be parsed.
62
	 *  <p>
63
	 * @param principal - X500Principal
64
	 */
65
	public void setPrincipal(X500Principal principal) {
66
		parseDN(principal.getName(X500Principal.RFC2253));
67
	}
68
69
	/**
70
	 *   Gets the most significant common name (CN) attribute from the given
71
	 *      X500Principal object.
72
	 *   For names that contains multiple attributes of this type.  The first
73
	 *      (most significant) one will be returned   
74
	 * <p> 
75
	 * @return the Most significant common name attribute.
76
	 * 
77
	 */
78
	public String getCN() {
79
		return findPart(attrCN);
80
	}
81
82
	/**
83
	 *   Gets the most significant Organizational Unit (OU) attribute from the given
84
	 *      X500Principal object.
85
	 *   For names that contains multiple attributes of this type.  The first
86
	 *      (most significant) one will be returned       
87
	 * <p> 
88
	 * 
89
	 * @return the Most significant OU attribute.
90
	 * 
91
	 */
92
93
	public String getOU() {
94
		return findPart(attrOU);
95
96
	}
97
98
	/**
99
	 *   Gets the most significant Organization (O) attribute from the given
100
	 *      X500Principal object.
101
	 *   For names that contains multiple attributes of this type.  The first
102
	 *      (most significant) one will be returned       
103
	 * <p> 
104
	 * 
105
	 * @return the Most significant O attribute.
106
	 * 
107
	 */
108
109
	public String getO() {
110
		return findPart(attrO);
111
112
	}
113
114
	/**
115
	 *   Gets the Country (C) attribute from the given
116
	 *      X500Principal object.      
117
	 * <p> 
118
	 * 
119
	 * @return the C attribute.
120
	 * 
121
	 */
122
	public String getC() {
123
		return findPart(attrC);
124
	}
125
126
	/**
127
	 *   Gets the Locale (L) attribute from the given
128
	 *      X500Principal object.      
129
	 * <p> 
130
	 * 
131
	 * @return the L attribute.
132
	 * 
133
	 */
134
	public String getL() {
135
		return findPart(attrL);
136
	}
137
138
	/**
139
	 *   Gets the State (ST) attribute from the given
140
	 *      X500Principal object.      
141
	 * <p> 
142
	 * 
143
	 * @return the ST attribute.
144
	 * 
145
	 */
146
	public String getST() {
147
		return findPart(attrST);
148
	}
149
150
	/**
151
	 *   Gets the Street (STREET) attribute from the given
152
	 *      X500Principal object.      
153
	 * <p> 
154
	 * 
155
	 * @return the STREET attribute.
156
	 * 
157
	 */
158
	public String getSTREET() {
159
		return findPart(attrSTREET);
160
	}
161
162
	/**
163
	 *   Gets the Email Address (EMAILADDRESS) attribute from the given
164
	 *      X500Principal object.      
165
	 * <p> 
166
	 * 
167
	 * @return the EMAILADDRESS attribute.
168
	 * 
169
	 */
170
	public String getEMAILDDRESS() {
171
		return findPart(attrEMAIL);
172
	}
173
174
	public String getUID() {
175
		return findPart(attrUID);
176
	}
177
178
	/**
179
	 * Derived From: org.eclipse.osgi.internal.verifier - DNChainMatching.java
180
	 * 
181
	 * Takes a distinguished name in canonical form and fills in the rdnArray
182
	 * with the extracted RDNs.
183
	 * 
184
	 * @param dn the distinguished name in canonical form.
185
	 * @throws IllegalArgumentException if a formatting error is found.
186
	 */
187
	private void parseDN(String dn) throws IllegalArgumentException {
188
		int startIndex = 0;
189
		char c = '\0';
190
		ArrayList nameValues = new ArrayList();
191
192
		// Clear the existing array, in case this instance is being re-used
193
		rdnNameArray.clear();
194
195
		while (startIndex < dn.length()) {
196
			int endIndex;
197
			for (endIndex = startIndex; endIndex < dn.length(); endIndex++) {
198
				c = dn.charAt(endIndex);
199
				if (c == ',' || c == '+')
200
					break;
201
				if (c == '\\') {
202
					endIndex++; // skip the escaped char
203
				}
204
			}
205
206
			if (endIndex > dn.length())
207
				throw new IllegalArgumentException("unterminated escape " + dn); //$NON-NLS-1$
208
209
			nameValues.add(dn.substring(startIndex, endIndex));
210
211
			if (c != '+') {
212
				rdnNameArray.add(nameValues);
213
				if (endIndex != dn.length())
214
					nameValues = new ArrayList();
215
				else
216
					nameValues = null;
217
			}
218
			startIndex = endIndex + 1;
219
		}
220
		if (nameValues != null) {
221
			throw new IllegalArgumentException("improperly terminated DN " + dn); //$NON-NLS-1$
222
		}
223
	}
224
225
	/**
226
	 * Returns an ArrayList containing all the values for the given attribute identifier.
227
	 * <p>
228
	 * @param  attributeID  String containing the X500 name attribute whose values are to be 
229
	 *      returned
230
	 * @return ArrayList containing the string values of the requested attribute. Values are in   
231
	 *      the order they occur.  May be empty.
232
	 * 
233
	 */
234
	public ArrayList getAllValues(String attributeID) {
235
		ArrayList retList = new ArrayList();
236
		String searchPart = attributeID + attrTerminator;
237
238
		for (Iterator iter = rdnNameArray.iterator(); iter.hasNext();) {
239
			ArrayList nameList = (ArrayList) iter.next();
240
			String namePart = (String) nameList.get(0);
241
242
			if (namePart.startsWith(searchPart)) {
243
				// Return the string starting after the ID string and the = sign that follows it.
244
				retList.add(namePart.toString().substring(searchPart.length()));
245
			}
246
		}
247
248
		return retList;
249
250
	}
251
252
	private String findPart(String attributeID) {
253
		return findSignificantPart(attributeID, MOSTSIGNIFICANT);
254
	}
255
256
	private String findSignificantPart(String attributeID, int significance) {
257
		String retNamePart = null;
258
		String searchPart = attributeID + attrTerminator;
259
260
		for (Iterator iter = rdnNameArray.iterator(); iter.hasNext();) {
261
			ArrayList nameList = (ArrayList) iter.next();
262
			String namePart = (String) nameList.get(0);
263
264
			if (namePart.startsWith(searchPart)) {
265
				// Return the string starting after the ID string and the = sign that follows it.
266
				retNamePart = namePart.toString().substring(searchPart.length());
267
				//  By definition the first one is most significant
268
				if (significance == MOSTSIGNIFICANT)
269
					break;
270
			}
271
		}
272
273
		return retNamePart;
274
	}
275
276
}
(-)src/org/eclipse/equinox/internal/security/ui/SecurityStatusControl.java (-1 / +1 lines)
Lines 12-18 Link Here
12
12
13
import org.eclipse.core.runtime.*;
13
import org.eclipse.core.runtime.*;
14
import org.eclipse.core.runtime.jobs.Job;
14
import org.eclipse.core.runtime.jobs.Job;
15
import org.eclipse.equinox.internal.provisional.security.ui.services.AuthorizationManager;
15
import org.eclipse.equinox.internal.provisional.security.ui.AuthorizationManager;
16
import org.eclipse.jface.action.ControlContribution;
16
import org.eclipse.jface.action.ControlContribution;
17
import org.eclipse.jface.resource.ImageDescriptor;
17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.SWT;
(-)src/org/eclipse/equinox/internal/provisional/security/ui/actions/package.html (-14 lines)
Removed Link Here
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<html>
3
<head>
4
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
   <title>Package-level Javadoc</title>
6
</head>
7
<body>
8
Equinox security UI contributions  
9
<h2>
10
Package Specification</h2>
11
<p>This package provides access to the Equinox security UI contributions.
12
</p>
13
</body>
14
</html>
(-)src/org/eclipse/equinox/internal/provisional/security/ui/actions/SecurityContributionItemFactory.java (-59 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.internal.provisional.security.ui.actions;
12
13
import org.eclipse.equinox.internal.security.ui.SecurityStatusControl;
14
import org.eclipse.jface.action.IContributionItem;
15
import org.eclipse.ui.IWorkbenchWindow;
16
import org.eclipse.ui.actions.ContributionItemFactory;
17
18
/**
19
 * Access to security related contribution items for the workbench.
20
 * <p>
21
 * Clients may declare subclasses that provide additional application-specific
22
 * contribution item factories.
23
 * </p>
24
 */
25
public abstract class SecurityContributionItemFactory {
26
27
	/**
28
	 * Id of contribution items created by this factory.
29
	 */
30
	private final String contributionItemId;
31
32
	/**
33
	* Creates a new contribution item factory with the given id.
34
	* @param contributionItemId the id of contribution items created by this factory
35
	*/
36
	protected SecurityContributionItemFactory(String contributionItemId) {
37
		this.contributionItemId = contributionItemId;
38
	}
39
40
	/**
41
	 * Returns the id of this contribution item factory.
42
	 * @return the id of contribution items created by this factory
43
	 */
44
	public String getId() {
45
		return contributionItemId;
46
	}
47
48
	/**
49
	 * Workbench contribution item (id &quot;securityStatus&quot;): An icon for 
50
	 * evaluating and inspecting the security status of the system.
51
	 */
52
	public static final ContributionItemFactory SECURITY_STATUS = new ContributionItemFactory("securityStatus") {//$NON-NLS-1$
53
		public IContributionItem create(IWorkbenchWindow window) {
54
			if (window == null)
55
				throw new IllegalArgumentException();
56
			return new SecurityStatusControl(window, getId());
57
		}
58
	};
59
}
(-)META-INF/MANIFEST.MF (-2 / +1 lines)
Lines 22-29 Link Here
22
 org.eclipse.equinox.preferences;bundle-version="[3.2.200,4.0.0)",
22
 org.eclipse.equinox.preferences;bundle-version="[3.2.200,4.0.0)",
23
 org.eclipse.ui;bundle-version="[3.4.0,4.0.0)"
23
 org.eclipse.ui;bundle-version="[3.4.0,4.0.0)"
24
Bundle-Activator: org.eclipse.equinox.internal.security.ui.Activator
24
Bundle-Activator: org.eclipse.equinox.internal.security.ui.Activator
25
Export-Package: org.eclipse.equinox.internal.provisional.security.ui.actions;version="1.0.0";x-internal:=true,
25
Export-Package: org.eclipse.equinox.internal.provisional.security.ui;version="1.0.0";x-internal:=true, 
26
 org.eclipse.equinox.internal.provisional.security.ui.services;version="1.0.0";x-internal:=true,
27
 org.eclipse.equinox.internal.security.ui;x-internal:=true,
26
 org.eclipse.equinox.internal.security.ui;x-internal:=true,
28
 org.eclipse.equinox.internal.security.ui.nls;x-internal:=true,
27
 org.eclipse.equinox.internal.security.ui.nls;x-internal:=true,
29
 org.eclipse.equinox.internal.security.ui.preferences;x-internal:=true,
28
 org.eclipse.equinox.internal.security.ui.preferences;x-internal:=true,
(-)src/org/eclipse/equinox/internal/provisional/security/ui/SecurityContributionItemFactory.java (+59 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.internal.provisional.security.ui;
12
13
import org.eclipse.equinox.internal.security.ui.SecurityStatusControl;
14
import org.eclipse.jface.action.IContributionItem;
15
import org.eclipse.ui.IWorkbenchWindow;
16
import org.eclipse.ui.actions.ContributionItemFactory;
17
18
/**
19
 * Access to security related contribution items for the workbench.
20
 * <p>
21
 * Clients may declare subclasses that provide additional application-specific
22
 * contribution item factories.
23
 * </p>
24
 */
25
public abstract class SecurityContributionItemFactory {
26
27
	/**
28
	 * Id of contribution items created by this factory.
29
	 */
30
	private final String contributionItemId;
31
32
	/**
33
	* Creates a new contribution item factory with the given id.
34
	* @param contributionItemId the id of contribution items created by this factory
35
	*/
36
	protected SecurityContributionItemFactory(String contributionItemId) {
37
		this.contributionItemId = contributionItemId;
38
	}
39
40
	/**
41
	 * Returns the id of this contribution item factory.
42
	 * @return the id of contribution items created by this factory
43
	 */
44
	public String getId() {
45
		return contributionItemId;
46
	}
47
48
	/**
49
	 * Workbench contribution item (id &quot;securityStatus&quot;): An icon for 
50
	 * evaluating and inspecting the security status of the system.
51
	 */
52
	public static final ContributionItemFactory SECURITY_STATUS = new ContributionItemFactory("securityStatus") {//$NON-NLS-1$
53
		public IContributionItem create(IWorkbenchWindow window) {
54
			if (window == null)
55
				throw new IllegalArgumentException();
56
			return new SecurityStatusControl(window, getId());
57
		}
58
	};
59
}
(-)src/org/eclipse/equinox/internal/provisional/security/ui/X500PrincipalHelper.java (+276 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008,  Jay Rosenthal
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors:
10
 *     Jay Rosenthal - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.equinox.internal.provisional.security.ui;
14
15
import java.util.ArrayList;
16
import java.util.Iterator;
17
import javax.security.auth.x500.X500Principal;
18
19
/**
20
 * X500PrincipalHelper
21
 * <p>
22
 * Helper class to extract pieces (attributes) of an X500Principal object for display
23
 * in the UI.
24
 * <p>
25
 * This helper uses the X500Principal.RFC2253 format of X500Principal.getname() to parse an X500Principal name 
26
 *   into it's component parts. 
27
 *  <p> 
28
 * In principals which contain multiple occurrences of the same attribute,the default for all the methods 
29
 *  is to return the most significant (first) attribute found. 
30
 *    
31
 */
32
33
public class X500PrincipalHelper {
34
	public static int LEASTSIGNIFICANT = 0;
35
	public static int MOSTSIGNIFICANT = 1;
36
37
	public final static String attrCN = "CN"; //$NON-NLS-1$
38
	public final static String attrOU = "OU"; //$NON-NLS-1$
39
	public final static String attrO = "O"; //$NON-NLS-1$
40
	public final static String attrC = "C"; //$NON-NLS-1$
41
	public final static String attrL = "L"; //$NON-NLS-1$
42
	public final static String attrST = "ST"; //$NON-NLS-1$
43
	public final static String attrSTREET = "STREET";//$NON-NLS-1$
44
	public final static String attrEMAIL = "EMAILADDRESS"; //$NON-NLS-1$
45
	public final static String attrUID = "UID"; //$NON-NLS-1$
46
47
	ArrayList rdnNameArray = new ArrayList();
48
49
	private final static String attrTerminator = "="; //$NON-NLS-1$
50
51
	public X500PrincipalHelper() {
52
		// Do nothing constructor..
53
		// Wont be useful unless setPrincipal is called...
54
	}
55
56
	public X500PrincipalHelper(X500Principal principal) {
57
		parseDN(principal.getName(X500Principal.RFC2253));
58
	}
59
60
	/**
61
	 *  Set the X500Principal name object to be parsed.
62
	 *  <p>
63
	 * @param principal - X500Principal
64
	 */
65
	public void setPrincipal(X500Principal principal) {
66
		parseDN(principal.getName(X500Principal.RFC2253));
67
	}
68
69
	/**
70
	 *   Gets the most significant common name (CN) attribute from the given
71
	 *      X500Principal object.
72
	 *   For names that contains multiple attributes of this type.  The first
73
	 *      (most significant) one will be returned   
74
	 * <p> 
75
	 * @return the Most significant common name attribute.
76
	 * 
77
	 */
78
	public String getCN() {
79
		return findPart(attrCN);
80
	}
81
82
	/**
83
	 *   Gets the most significant Organizational Unit (OU) attribute from the given
84
	 *      X500Principal object.
85
	 *   For names that contains multiple attributes of this type.  The first
86
	 *      (most significant) one will be returned       
87
	 * <p> 
88
	 * 
89
	 * @return the Most significant OU attribute.
90
	 * 
91
	 */
92
93
	public String getOU() {
94
		return findPart(attrOU);
95
96
	}
97
98
	/**
99
	 *   Gets the most significant Organization (O) attribute from the given
100
	 *      X500Principal object.
101
	 *   For names that contains multiple attributes of this type.  The first
102
	 *      (most significant) one will be returned       
103
	 * <p> 
104
	 * 
105
	 * @return the Most significant O attribute.
106
	 * 
107
	 */
108
109
	public String getO() {
110
		return findPart(attrO);
111
112
	}
113
114
	/**
115
	 *   Gets the Country (C) attribute from the given
116
	 *      X500Principal object.      
117
	 * <p> 
118
	 * 
119
	 * @return the C attribute.
120
	 * 
121
	 */
122
	public String getC() {
123
		return findPart(attrC);
124
	}
125
126
	/**
127
	 *   Gets the Locale (L) attribute from the given
128
	 *      X500Principal object.      
129
	 * <p> 
130
	 * 
131
	 * @return the L attribute.
132
	 * 
133
	 */
134
	public String getL() {
135
		return findPart(attrL);
136
	}
137
138
	/**
139
	 *   Gets the State (ST) attribute from the given
140
	 *      X500Principal object.      
141
	 * <p> 
142
	 * 
143
	 * @return the ST attribute.
144
	 * 
145
	 */
146
	public String getST() {
147
		return findPart(attrST);
148
	}
149
150
	/**
151
	 *   Gets the Street (STREET) attribute from the given
152
	 *      X500Principal object.      
153
	 * <p> 
154
	 * 
155
	 * @return the STREET attribute.
156
	 * 
157
	 */
158
	public String getSTREET() {
159
		return findPart(attrSTREET);
160
	}
161
162
	/**
163
	 *   Gets the Email Address (EMAILADDRESS) attribute from the given
164
	 *      X500Principal object.      
165
	 * <p> 
166
	 * 
167
	 * @return the EMAILADDRESS attribute.
168
	 * 
169
	 */
170
	public String getEMAILDDRESS() {
171
		return findPart(attrEMAIL);
172
	}
173
174
	public String getUID() {
175
		return findPart(attrUID);
176
	}
177
178
	/**
179
	 * Derived From: org.eclipse.osgi.internal.verifier - DNChainMatching.java
180
	 * 
181
	 * Takes a distinguished name in canonical form and fills in the rdnArray
182
	 * with the extracted RDNs.
183
	 * 
184
	 * @param dn the distinguished name in canonical form.
185
	 * @throws IllegalArgumentException if a formatting error is found.
186
	 */
187
	private void parseDN(String dn) throws IllegalArgumentException {
188
		int startIndex = 0;
189
		char c = '\0';
190
		ArrayList nameValues = new ArrayList();
191
192
		// Clear the existing array, in case this instance is being re-used
193
		rdnNameArray.clear();
194
195
		while (startIndex < dn.length()) {
196
			int endIndex;
197
			for (endIndex = startIndex; endIndex < dn.length(); endIndex++) {
198
				c = dn.charAt(endIndex);
199
				if (c == ',' || c == '+')
200
					break;
201
				if (c == '\\') {
202
					endIndex++; // skip the escaped char
203
				}
204
			}
205
206
			if (endIndex > dn.length())
207
				throw new IllegalArgumentException("unterminated escape " + dn); //$NON-NLS-1$
208
209
			nameValues.add(dn.substring(startIndex, endIndex));
210
211
			if (c != '+') {
212
				rdnNameArray.add(nameValues);
213
				if (endIndex != dn.length())
214
					nameValues = new ArrayList();
215
				else
216
					nameValues = null;
217
			}
218
			startIndex = endIndex + 1;
219
		}
220
		if (nameValues != null) {
221
			throw new IllegalArgumentException("improperly terminated DN " + dn); //$NON-NLS-1$
222
		}
223
	}
224
225
	/**
226
	 * Returns an ArrayList containing all the values for the given attribute identifier.
227
	 * <p>
228
	 * @param  attributeID  String containing the X500 name attribute whose values are to be 
229
	 *      returned
230
	 * @return ArrayList containing the string values of the requested attribute. Values are in   
231
	 *      the order they occur.  May be empty.
232
	 * 
233
	 */
234
	public ArrayList getAllValues(String attributeID) {
235
		ArrayList retList = new ArrayList();
236
		String searchPart = attributeID + attrTerminator;
237
238
		for (Iterator iter = rdnNameArray.iterator(); iter.hasNext();) {
239
			ArrayList nameList = (ArrayList) iter.next();
240
			String namePart = (String) nameList.get(0);
241
242
			if (namePart.startsWith(searchPart)) {
243
				// Return the string starting after the ID string and the = sign that follows it.
244
				retList.add(namePart.toString().substring(searchPart.length()));
245
			}
246
		}
247
248
		return retList;
249
250
	}
251
252
	private String findPart(String attributeID) {
253
		return findSignificantPart(attributeID, MOSTSIGNIFICANT);
254
	}
255
256
	private String findSignificantPart(String attributeID, int significance) {
257
		String retNamePart = null;
258
		String searchPart = attributeID + attrTerminator;
259
260
		for (Iterator iter = rdnNameArray.iterator(); iter.hasNext();) {
261
			ArrayList nameList = (ArrayList) iter.next();
262
			String namePart = (String) nameList.get(0);
263
264
			if (namePart.startsWith(searchPart)) {
265
				// Return the string starting after the ID string and the = sign that follows it.
266
				retNamePart = namePart.toString().substring(searchPart.length());
267
				//  By definition the first one is most significant
268
				if (significance == MOSTSIGNIFICANT)
269
					break;
270
			}
271
		}
272
273
		return retNamePart;
274
	}
275
276
}
(-)src/org/eclipse/equinox/internal/provisional/security/ui/package.html (+14 lines)
Added Link Here
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<html>
3
<head>
4
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
   <title>Package-level Javadoc</title>
6
</head>
7
<body>
8
Equinox security UI contributions  
9
<h2>
10
Package Specification</h2>
11
<p>This package provides access to the Equinox security UI contributions.
12
</p>
13
</body>
14
</html>
(-)src/org/eclipse/equinox/internal/provisional/security/ui/AuthorizationManager.java (+59 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.equinox.internal.provisional.security.ui;
12
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.ui.IWorkbenchWindow;
15
16
/**
17
 * The AuthorizationManager is the facility by which the end user
18
 * is informed of the current state of the system with respect to 
19
 * bundle authorization based security. 
20
 */
21
public abstract class AuthorizationManager {
22
23
	public AuthorizationManager() {
24
		//no content
25
	}
26
27
	/**
28
	 * Query whether the authorization system is enabled for the system.
29
	 * 
30
	 * @return <code>true</code> if and only if authorization is enabled 
31
	 */
32
	abstract public boolean isEnabled();
33
34
	/**
35
	 * Returns true when the system is in need of attention from the end
36
	 * user. This means that some unauthorized content has been encountered, and the 
37
	 * user has not yet inspected the situation.
38
	 * 
39
	 * @return <code>true</code> if user attention is required
40
	 */
41
	abstract public boolean needsAttention();
42
43
	/**
44
	 * Return an Eclipse IStatus object representing the current state of the 
45
	 * authorization system.
46
	 *
47
	 * @return IStatus code representing the system status
48
	 */
49
	abstract public IStatus getStatus();
50
51
	/**
52
	 * Open the authorization manager user interface so that the end
53
	 * user can view and edit the system's authorization state.
54
	 * 
55
	 * @param workbenchWindow the workbench window
56
	 */
57
	abstract public void displayManager(IWorkbenchWindow workbenchWindow);
58
59
}
(-)src/org/eclipse/equinox/internal/provisional/security/ui/X509CertificateViewDialog.java (+219 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008,  Jay Rosenthal
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 * 
9
 * Contributors:
10
 *     Jay Rosenthal - initial API and implementation
11
 *******************************************************************************/
12
13
package org.eclipse.equinox.internal.provisional.security.ui;
14
15
import java.security.cert.X509Certificate;
16
import java.text.DateFormat;
17
import org.eclipse.equinox.internal.security.ui.Activator;
18
import org.eclipse.equinox.internal.security.ui.SecurityUIMsg;
19
import org.eclipse.equinox.internal.security.ui.wizard.CertificateViewer;
20
import org.eclipse.jface.dialogs.IDialogConstants;
21
import org.eclipse.jface.dialogs.TitleAreaDialog;
22
import org.eclipse.jface.resource.JFaceResources;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.graphics.Font;
25
import org.eclipse.swt.graphics.Image;
26
import org.eclipse.swt.layout.*;
27
import org.eclipse.swt.widgets.*;
28
29
public class X509CertificateViewDialog extends TitleAreaDialog {
30
	private final static String titleImageName = "/titleAreaCert.gif"; //$NON-NLS-1$
31
	private X509Certificate theCert;
32
	private static final DateFormat _df = DateFormat.getDateInstance(DateFormat.LONG);
33
	private X500PrincipalHelper nameHelper = new X500PrincipalHelper();
34
35
	// We use the "bannerFont" for our bold font
36
	private static Font boldFont = JFaceResources.getBannerFont();
37
	private Image titleImage;
38
39
	public X509CertificateViewDialog(Shell parentShell, X509Certificate cert) {
40
		super(parentShell);
41
		this.theCert = cert;
42
	}
43
44
	protected Control createContents(Composite parent) {
45
		return super.createContents(parent);
46
	}
47
48
	protected Control createDialogArea(Composite parent) {
49
		nameHelper.setPrincipal(theCert.getSubjectX500Principal());
50
51
		setTitle((nameHelper.getCN() != null ? nameHelper.getCN() : nameHelper.getOU()));
52
53
		titleImage = Activator.getImageDescriptor(titleImageName).createImage();
54
55
		if (titleImage != null)
56
			setTitleImage(titleImage);
57
58
		Composite composite = (Composite) super.createDialogArea(parent);
59
60
		TabFolder tabFolder = new TabFolder(composite, SWT.BORDER);
61
		GridData bdata = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL);
62
		tabFolder.setLayoutData(bdata);
63
64
		createBasicTab(tabFolder);
65
66
		createAdvancedTab(tabFolder);
67
68
		return composite;
69
	}
70
71
	private void createBasicTab(TabFolder tabFolder) {
72
		String displayName = null;
73
		int labelIndent = 10;
74
		int dataIdent = 10;
75
76
		TabItem basicTab = new TabItem(tabFolder, SWT.NULL);
77
		basicTab.setText(SecurityUIMsg.CERTVIEW_LABEL_BASIC);
78
		Composite basicTabComposite = new Composite(tabFolder, SWT.NONE);
79
80
		GridLayout tabLayout = new GridLayout();
81
		tabLayout.numColumns = 2;
82
		basicTabComposite.setLayout(tabLayout);
83
84
		Label issueToLabel = new Label(basicTabComposite, SWT.NONE);
85
		issueToLabel.setText(SecurityUIMsg.CERTPROP_X509_ISSUED_TO);
86
		issueToLabel.setFont(boldFont);
87
		configureLayout(issueToLabel, 2, 0, 0, 0);
88
89
		// Display the RDNs of the Subject
90
		nameHelper.setPrincipal(theCert.getSubjectX500Principal());
91
92
		Label CNLabel = new Label(basicTabComposite, SWT.NONE);
93
		CNLabel.setText(SecurityUIMsg.X500_LABEL_CN);
94
		configureLayout(CNLabel, 0, 0, labelIndent, 0);
95
96
		Label subjectCN = new Label(basicTabComposite, SWT.NONE);
97
		displayName = nameHelper.getCN();
98
		subjectCN.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
99
		configureLayout(subjectCN, 0, 0, dataIdent, 0);
100
101
		Label OLabel = new Label(basicTabComposite, SWT.NONE);
102
		OLabel.setText(SecurityUIMsg.X500_LABEL_O);
103
		configureLayout(OLabel, 0, 0, labelIndent, 0);
104
105
		Label subjectO = new Label(basicTabComposite, SWT.NONE);
106
		displayName = nameHelper.getO();
107
		subjectO.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
108
		configureLayout(subjectO, 0, 0, dataIdent, 0);
109
110
		Label OULabel = new Label(basicTabComposite, SWT.NONE);
111
		OULabel.setText(SecurityUIMsg.X500_LABEL_OU);
112
		configureLayout(OULabel, 0, 0, labelIndent, 0);
113
114
		Label subjectOU = new Label(basicTabComposite, SWT.NONE);
115
		displayName = nameHelper.getOU();
116
		subjectOU.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
117
		configureLayout(subjectOU, 0, 0, dataIdent, 0);
118
119
		Label issueByLabel = new Label(basicTabComposite, SWT.NONE);
120
		issueByLabel.setText(SecurityUIMsg.CERTPROP_X509_ISSUED_BY);
121
		configureLayout(issueByLabel, 2, 0, 0, 0);
122
		issueByLabel.setFont(boldFont);
123
124
		// Display the RDNs of the Issuer
125
		nameHelper.setPrincipal(theCert.getIssuerX500Principal());
126
127
		Label CNLabel2 = new Label(basicTabComposite, SWT.NONE);
128
		CNLabel2.setText(SecurityUIMsg.X500_LABEL_CN);
129
		configureLayout(CNLabel2, 0, 0, labelIndent, 0);
130
131
		Label issuerCN = new Label(basicTabComposite, SWT.NONE);
132
		displayName = nameHelper.getCN();
133
		issuerCN.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
134
		configureLayout(issuerCN, 0, 0, dataIdent, 0);
135
136
		Label OLabel2 = new Label(basicTabComposite, SWT.NONE);
137
		OLabel2.setText(SecurityUIMsg.X500_LABEL_O);
138
		configureLayout(OLabel2, 0, 0, labelIndent, 0);
139
140
		Label issuerO = new Label(basicTabComposite, SWT.NONE);
141
		displayName = nameHelper.getO();
142
		issuerO.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
143
		configureLayout(issuerO, 0, 0, dataIdent, 0);
144
145
		Label OULabel2 = new Label(basicTabComposite, SWT.NONE);
146
		OULabel2.setText(SecurityUIMsg.X500_LABEL_OU);
147
		configureLayout(OULabel2, 0, 0, labelIndent, 0);
148
149
		Label issuerOU = new Label(basicTabComposite, SWT.NONE);
150
		displayName = nameHelper.getOU();
151
		issuerOU.setText((displayName != null ? displayName : SecurityUIMsg.CERTVAL_UNDEFINED));
152
		configureLayout(issuerOU, 0, 0, dataIdent, 0);
153
154
		Label datesLabel = new Label(basicTabComposite, SWT.NONE);
155
		datesLabel.setText(SecurityUIMsg.CERTVIEW_LABEL_VALIDITY_DATES);
156
		configureLayout(datesLabel, 2, 0, 0, 0);
157
		datesLabel.setFont(boldFont);
158
159
		Label validFrom = new Label(basicTabComposite, SWT.NONE);
160
		validFrom.setText(SecurityUIMsg.CERTPROP_X509_VALID_FROM);
161
		configureLayout(validFrom, 0, 0, labelIndent, 0);
162
163
		Label fromDate = new Label(basicTabComposite, SWT.NONE);
164
		fromDate.setText(_df.format(theCert.getNotBefore()));
165
		configureLayout(fromDate, 0, 0, dataIdent, 0);
166
167
		Label validTo = new Label(basicTabComposite, SWT.NONE);
168
		validTo.setText(SecurityUIMsg.CERTPROP_X509_VALID_TO);
169
		configureLayout(validTo, 0, 0, labelIndent, 0);
170
171
		Label toDate = new Label(basicTabComposite, SWT.NONE);
172
		toDate.setText(_df.format(theCert.getNotAfter()));
173
		configureLayout(toDate, 0, 0, dataIdent, 0);
174
175
		basicTab.setControl(basicTabComposite);
176
	}
177
178
	protected static void configureLayout(Control c, int horizontalSpan, int verticalSpan, int horizontalIndent, int vertIndent) {
179
		GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER);
180
181
		gd.horizontalSpan = horizontalSpan;
182
		gd.verticalSpan = verticalSpan;
183
		gd.horizontalIndent = horizontalIndent;
184
		gd.verticalIndent = vertIndent;
185
186
		c.setLayoutData(gd);
187
188
	}
189
190
	private void createAdvancedTab(final TabFolder tabFolder) {
191
		TabItem advancedTab = new TabItem(tabFolder, SWT.NULL);
192
		advancedTab.setText(SecurityUIMsg.CERTVIEW_LABEL_DETAILS);
193
		Composite advTabComposite = new Composite(tabFolder, SWT.NONE);
194
		advTabComposite.setLayout(new FillLayout(SWT.VERTICAL));
195
196
		CertificateViewer certViewer = new CertificateViewer(advTabComposite);
197
		certViewer.setCertificate(theCert);
198
		advancedTab.setControl(advTabComposite);
199
	}
200
201
	protected void setShellStyle(int newShellStyle) {
202
203
		super.setShellStyle(newShellStyle | SWT.RESIZE | SWT.DIALOG_TRIM);
204
	}
205
206
	protected void createButtonsForButtonBar(Composite parent) {
207
		// The default has only a "Close" button, but it returns the CANCEL Id
208
		createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, true);
209
210
	}
211
212
	public boolean close() {
213
		if (titleImage != null) {
214
			titleImage.dispose();
215
		}
216
		return super.close();
217
	}
218
219
}

Return to bug 220805