Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 214119 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/security/ui/preferences/SecurityCategoryPage.java (-3 lines)
Lines 40-48 Link Here
40
		PreferenceLinkArea policyLinkArea = new PreferenceLinkArea(pageArea, SWT.NONE, "org.eclipse.equinox.security.ui.policy", SecurityUIMsg.CATPAGE_LABEL_POLICY, (IWorkbenchPreferenceContainer) getContainer(), null); //$NON-NLS-1$
40
		PreferenceLinkArea policyLinkArea = new PreferenceLinkArea(pageArea, SWT.NONE, "org.eclipse.equinox.security.ui.policy", SecurityUIMsg.CATPAGE_LABEL_POLICY, (IWorkbenchPreferenceContainer) getContainer(), null); //$NON-NLS-1$
41
		policyLinkArea.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
41
		policyLinkArea.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
42
42
43
		PreferenceLinkArea advancedLinkArea = new PreferenceLinkArea(pageArea, SWT.NONE, "org.eclipse.equinox.security.ui.advanced", SecurityUIMsg.CATPAGE_LABEL_ADVANCED, (IWorkbenchPreferenceContainer) getContainer(), null); //$NON-NLS-1$
44
		advancedLinkArea.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
45
46
		PreferenceLinkArea storageLinkArea = new PreferenceLinkArea(pageArea, SWT.NONE, "org.eclipse.equinox.security.ui.storage", SecurityUIMsg.CATPAGE_LABEL_STORAGE, (IWorkbenchPreferenceContainer) getContainer(), null); //$NON-NLS-1$
43
		PreferenceLinkArea storageLinkArea = new PreferenceLinkArea(pageArea, SWT.NONE, "org.eclipse.equinox.security.ui.storage", SecurityUIMsg.CATPAGE_LABEL_STORAGE, (IWorkbenchPreferenceContainer) getContainer(), null); //$NON-NLS-1$
47
		storageLinkArea.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
44
		storageLinkArea.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
48
45
(-)plugin.xml (-8 / +10 lines)
Lines 39-52 Link Here
39
      </page>
39
      </page>
40
   </extension>
40
   </extension>
41
41
42
   <extension point="org.eclipse.ui.preferencePages">
43
      <page
44
         name="%advanced"
45
         class="org.eclipse.equinox.internal.security.ui.preferences.AdvancedPage"
46
         id="org.eclipse.equinox.security.ui.advanced"
47
         category="org.eclipse.equinox.security.ui.category">
48
      </page>
49
   </extension>
50
   
42
   
51
<!--   
43
<!--   
52
   <extension
44
   <extension
Lines 81-85 Link Here
81
            class="org.eclipse.equinox.internal.security.ui.storage.UICallbackProvider">
73
            class="org.eclipse.equinox.internal.security.ui.storage.UICallbackProvider">
82
      </provider>
74
      </provider>
83
   </extension>
75
   </extension>
76
   <extension
77
         id="security"
78
         name="Security"
79
         point="org.eclipse.ui.systemSummarySections">
80
      <section
81
            class="org.eclipse.equinox.internal.security.ui.SecuritySummary"
82
            id="securitySection"
83
            sectionTitle="Security">
84
      </section>
85
   </extension>
84
   
86
   
85
</plugin>
87
</plugin>
(-)src/org/eclipse/equinox/internal/security/ui/SecuritySummary.java (+176 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 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.security.ui;
12
13
import java.io.PrintWriter;
14
import java.security.Provider;
15
import java.security.Security;
16
import java.util.*;
17
import org.eclipse.ui.about.ISystemSummarySection;
18
19
public class SecuritySummary implements ISystemSummarySection {
20
21
	private static final String ALG_ALIAS = "Alg.Alias."; //$NON-NLS-1$
22
	private static final String PROVIDER = "Provider."; //$NON-NLS-1$
23
24
	public void write(PrintWriter writer) {
25
26
		Provider[] providers = Security.getProviders();
27
		writer.println("Installed providers (" + providers.length + "): ");
28
		writer.println();
29
30
		for (int i = 0; i < providers.length; i++) {
31
			appendProvider(writer, providers[i], i);
32
		}
33
	}
34
35
	private void appendProvider(PrintWriter writer, Provider provider, int index) {
36
		writer.println(" Provider: " + provider.getName() + ", Version: " + provider.getVersion() + ", Class: " + provider.getClass().getName());
37
		writer.println("  Description: " + provider.getInfo());
38
		ProviderService[] services = getServices(provider);
39
		writer.println("  Available services (" + services.length + "):");
40
		for (int i = 0; i < services.length; i++) {
41
			appendService(writer, services[i], i);
42
		}
43
		writer.println();
44
	}
45
46
	private void appendService(PrintWriter writer, ProviderService service, int index) {
47
		writer.println("   Service: " + service.getType() + ", Algorithm: " + service.getAlgorithm() + ", Class: " + service.getClassName());
48
		List aliases = service.getAliases();
49
		if (null != aliases && (0 < aliases.size())) {
50
			writer.print("    Aliases: ");
51
			for (Iterator it = aliases.iterator(); it.hasNext();) {
52
				writer.print((String) it.next());
53
				if (it.hasNext()) {
54
					writer.print(", ");
55
				}
56
			}
57
			writer.println();
58
		}
59
		Map attributes = service.getAttributes();
60
		if ((null != attributes) && (0 < attributes.size())) {
61
			writer.println("    Attributes:");
62
			Set keys = attributes.keySet();
63
			for (Iterator it = keys.iterator(); it.hasNext();) {
64
				String key = (String) it.next();
65
				writer.print("      " + key + ": ");
66
				writer.println((String) attributes.get(key));
67
			}
68
		}
69
	}
70
71
	private static ProviderService[] getServices(Provider provider) {
72
73
		Set providerKeys = provider.keySet();
74
		Hashtable serviceList = new Hashtable();
75
		Hashtable attributeMap = new Hashtable(); // "type" => "Hashtable of (attribute,value) pairs"
76
		Hashtable aliasMap = new Hashtable(); // "type" => "Arraylist of aliases"
77
		for (Iterator it = providerKeys.iterator(); it.hasNext();) {
78
			String key = (String) it.next();
79
80
			// this is provider info, available off the Provider API
81
			if (key.startsWith(PROVIDER)) {
82
				continue;
83
			}
84
85
			// this is an alias
86
			if (key.startsWith(ALG_ALIAS)) {
87
				String value = key.substring(key.indexOf(ALG_ALIAS) + ALG_ALIAS.length(), key.length());
88
				String type = (String) provider.get(key);
89
				String algo = value.substring(0, value.indexOf('.'));
90
				String alias = value.substring(value.indexOf('.') + 1, value.length());
91
				ArrayList aliasList = (ArrayList) aliasMap.get(type + '.' + algo);
92
				if (aliasList == null) {
93
					aliasList = new ArrayList();
94
					aliasList.add(alias);
95
					aliasMap.put(type, aliasList);
96
				} else {
97
					aliasList.add(alias);
98
				}
99
			}
100
101
			// this is an attribute
102
			else if (key.indexOf(' ') > -1) {
103
				String type = key.substring(0, key.indexOf('.'));
104
				String algorithm = key.substring(key.indexOf('.') + 1, key.indexOf(' '));
105
				String attribute = key.substring(key.indexOf(' ') + 1, key.length());
106
				String value = (String) provider.get(key);
107
				Hashtable attributeTable = (Hashtable) attributeMap.get(type + '.' + algorithm);
108
				if (attributeTable == null) {
109
					attributeTable = new Hashtable();
110
					attributeTable.put(attribute, value);
111
					attributeMap.put(type + '.' + algorithm, attributeTable);
112
				} else {
113
					attributeTable.put(attribute, value);
114
				}
115
			}
116
117
			// else this is a service
118
			else {
119
				serviceList.put(key, provider.get(key));
120
			}
121
		}
122
123
		ProviderService[] serviceArray = new ProviderService[serviceList.size()];
124
		Set serviceKeys = serviceList.keySet();
125
		int serviceCount = 0;
126
		for (Iterator it = serviceKeys.iterator(); it.hasNext();) {
127
			String key = (String) it.next();
128
			String type = key.substring(0, key.indexOf('.'));
129
			String algo = key.substring(key.indexOf('.') + 1, key.length());
130
			String className = (String) serviceList.get(key);
131
			List aliases = (List) aliasMap.get(algo);
132
			Map attributes = (Map) attributeMap.get(key);
133
134
			serviceArray[serviceCount] = new ProviderService(type, algo, className, aliases, attributes);
135
			serviceCount++;
136
		}
137
		return serviceArray;
138
	}
139
140
	private static class ProviderService {
141
142
		private final String type;
143
		private final String algorithm;
144
		private final String className;
145
		private final List aliases;
146
		private final Map attributes;
147
148
		public ProviderService(String type, String algorithm, String className, List aliases, Map attributes) {
149
			this.type = type;
150
			this.algorithm = algorithm;
151
			this.className = className;
152
			this.aliases = aliases;
153
			this.attributes = attributes;
154
		}
155
156
		public String getType() {
157
			return type;
158
		}
159
160
		public String getAlgorithm() {
161
			return algorithm;
162
		}
163
164
		public String getClassName() {
165
			return className;
166
		}
167
168
		public List getAliases() {
169
			return aliases;
170
		}
171
172
		public Map getAttributes() {
173
			return attributes;
174
		}
175
	}
176
}

Return to bug 214119