Lines 18-26
Link Here
|
18 |
import org.eclipse.equinox.internal.security.ui.nls.SecUIMessages; |
18 |
import org.eclipse.equinox.internal.security.ui.nls.SecUIMessages; |
19 |
import org.eclipse.equinox.security.storage.ISecurePreferences; |
19 |
import org.eclipse.equinox.security.storage.ISecurePreferences; |
20 |
import org.eclipse.equinox.security.storage.SecurePreferencesFactory; |
20 |
import org.eclipse.equinox.security.storage.SecurePreferencesFactory; |
|
|
21 |
import org.eclipse.jface.dialogs.MessageDialog; |
21 |
import org.eclipse.jface.layout.*; |
22 |
import org.eclipse.jface.layout.*; |
22 |
import org.eclipse.jface.viewers.ColumnWeightData; |
23 |
import org.eclipse.jface.viewers.ColumnWeightData; |
23 |
import org.eclipse.jface.viewers.TableLayout; |
24 |
import org.eclipse.jface.viewers.TableLayout; |
|
|
25 |
import org.eclipse.osgi.util.NLS; |
24 |
import org.eclipse.swt.SWT; |
26 |
import org.eclipse.swt.SWT; |
25 |
import org.eclipse.swt.events.*; |
27 |
import org.eclipse.swt.events.*; |
26 |
import org.eclipse.swt.layout.GridData; |
28 |
import org.eclipse.swt.layout.GridData; |
Lines 40-45
Link Here
|
40 |
protected Button buttonChangePassword; |
42 |
protected Button buttonChangePassword; |
41 |
protected Button buttonRecoverPassword; |
43 |
protected Button buttonRecoverPassword; |
42 |
|
44 |
|
|
|
45 |
protected Text detailsText; |
46 |
|
43 |
protected boolean providerModified = false; |
47 |
protected boolean providerModified = false; |
44 |
|
48 |
|
45 |
public TabPassword(TabFolder folder, int index, final Shell shell) { |
49 |
public TabPassword(TabFolder folder, int index, final Shell shell) { |
Lines 107-112
Link Here
|
107 |
if ((e.detail & SWT.CHECK) != 0) |
111 |
if ((e.detail & SWT.CHECK) != 0) |
108 |
providerModified = true; |
112 |
providerModified = true; |
109 |
enableButtons(); |
113 |
enableButtons(); |
|
|
114 |
updateDescription(); |
110 |
} |
115 |
} |
111 |
}); |
116 |
}); |
112 |
GridDataFactory.defaultsFor(providerTable).span(1, 2).applyTo(providerTable); |
117 |
GridDataFactory.defaultsFor(providerTable).span(1, 2).applyTo(providerTable); |
Lines 121-130
Link Here
|
121 |
} |
126 |
} |
122 |
|
127 |
|
123 |
public void widgetSelected(SelectionEvent e) { |
128 |
public void widgetSelected(SelectionEvent e) { |
|
|
129 |
PasswordProviderDescription selectedModule = getSelectedModule(); |
130 |
if (selectedModule == null) |
131 |
return; |
124 |
String moduleID = getSelectedModuleID(); |
132 |
String moduleID = getSelectedModuleID(); |
125 |
ISecurePreferences rootNode = SecurePreferencesFactory.getDefault(); |
133 |
ISecurePreferences rootNode = SecurePreferencesFactory.getDefault(); |
126 |
ChangePasswordWizardDialog dialog = new ChangePasswordWizardDialog(shell, rootNode, moduleID); |
134 |
if (selectedModule.hasHint(InternalExchangeUtils.HINT_PASSWORD_AUTOGEN)) { |
127 |
dialog.open(); |
135 |
// do replacement behind the scene without showing the wizard |
|
|
136 |
changePassword(rootNode, moduleID, selectedModule.getName(), shell); |
137 |
} else { |
138 |
// show the wizard to provide separate "old" and "new" password entries |
139 |
ChangePasswordWizardDialog dialog = new ChangePasswordWizardDialog(shell, rootNode, moduleID); |
140 |
dialog.open(); |
141 |
} |
128 |
enableLogout(); |
142 |
enableLogout(); |
129 |
} |
143 |
} |
130 |
}); |
144 |
}); |
Lines 153-158
Link Here
|
153 |
setButtonSize(buttonRecoverPassword); |
167 |
setButtonSize(buttonRecoverPassword); |
154 |
|
168 |
|
155 |
enableButtons(); |
169 |
enableButtons(); |
|
|
170 |
|
171 |
Label descriptionLabel = new Label(providersComp, SWT.NONE); |
172 |
descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); |
173 |
descriptionLabel.setText(SecUIMessages.providerDetails); |
174 |
|
175 |
detailsText = new Text(providersComp, SWT.MULTI | SWT.LEAD | SWT.BORDER | SWT.READ_ONLY | SWT.WRAP); |
176 |
detailsText.setBackground(detailsText.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); |
177 |
gridData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1); |
178 |
gridData.widthHint = 300; |
179 |
gridData.heightHint = 65; |
180 |
detailsText.setLayoutData(gridData); |
181 |
updateDescription(); |
182 |
|
156 |
GridLayoutFactory.fillDefaults().margins(LayoutConstants.getSpacing()).generateLayout(page); |
183 |
GridLayoutFactory.fillDefaults().margins(LayoutConstants.getSpacing()).generateLayout(page); |
157 |
} |
184 |
} |
158 |
|
185 |
|
Lines 169-175
Link Here
|
169 |
PasswordProviderDescription module = (PasswordProviderDescription) i.next(); |
196 |
PasswordProviderDescription module = (PasswordProviderDescription) i.next(); |
170 |
TableItem item = new TableItem(providerTable, SWT.NONE); |
197 |
TableItem item = new TableItem(providerTable, SWT.NONE); |
171 |
item.setText(new String[] {module.getName(), Integer.toString(module.getPriority())}); |
198 |
item.setText(new String[] {module.getName(), Integer.toString(module.getPriority())}); |
172 |
item.setData(module.getId()); |
199 |
item.setData(module); |
173 |
if (disabledModules == null) |
200 |
if (disabledModules == null) |
174 |
item.setChecked(true); |
201 |
item.setChecked(true); |
175 |
else |
202 |
else |
Lines 180-194
Link Here
|
180 |
layout.addColumnData(new ColumnWeightData(5)); |
207 |
layout.addColumnData(new ColumnWeightData(5)); |
181 |
layout.addColumnData(new ColumnWeightData(1)); |
208 |
layout.addColumnData(new ColumnWeightData(1)); |
182 |
providerTable.setLayout(layout); |
209 |
providerTable.setLayout(layout); |
|
|
210 |
|
211 |
if (providerTable.getItemCount() > 0) |
212 |
providerTable.select(0); |
183 |
} |
213 |
} |
184 |
|
214 |
|
185 |
protected String getSelectedModuleID() { |
215 |
protected PasswordProviderDescription getSelectedModule() { |
186 |
if (providerTable == null) |
216 |
if (providerTable == null) |
187 |
return null; |
217 |
return null; |
188 |
TableItem[] items = providerTable.getSelection(); |
218 |
TableItem[] items = providerTable.getSelection(); |
189 |
if (items.length == 0) |
219 |
if (items.length == 0) |
190 |
return null; |
220 |
return null; |
191 |
return (String) items[0].getData(); |
221 |
return ((PasswordProviderDescription) items[0].getData()); |
|
|
222 |
} |
223 |
|
224 |
protected String getSelectedModuleID() { |
225 |
PasswordProviderDescription selectedModule = getSelectedModule(); |
226 |
if (selectedModule == null) |
227 |
return null; |
228 |
return selectedModule.getId(); |
192 |
} |
229 |
} |
193 |
|
230 |
|
194 |
protected void enableButtons() { |
231 |
protected void enableButtons() { |
Lines 246-252
Link Here
|
246 |
tmp.append(','); |
283 |
tmp.append(','); |
247 |
else |
284 |
else |
248 |
first = false; |
285 |
first = false; |
249 |
tmp.append((String) items[i].getData()); |
286 |
tmp.append(((PasswordProviderDescription) items[i].getData()).getId()); |
250 |
} |
287 |
} |
251 |
|
288 |
|
252 |
IEclipsePreferences node = new ConfigurationScope().getNode(PREFERENCES_PLUGIN); |
289 |
IEclipsePreferences node = new ConfigurationScope().getNode(PREFERENCES_PLUGIN); |
Lines 276-279
Link Here
|
276 |
GridDataFactory.defaultsFor(button).align(SWT.FILL, SWT.BEGINNING).grab(false, false).applyTo(button); |
313 |
GridDataFactory.defaultsFor(button).align(SWT.FILL, SWT.BEGINNING).grab(false, false).applyTo(button); |
277 |
} |
314 |
} |
278 |
|
315 |
|
|
|
316 |
protected boolean changePassword(ISecurePreferences node, String moduleID, String name, Shell shell) { |
317 |
ReEncrypter reEncrypter = new ReEncrypter(node, moduleID); |
318 |
if (!reEncrypter.decrypt()) { |
319 |
MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO | SWT.ICON_WARNING); |
320 |
messageBox.setText(SecUIMessages.changePasswordWizardTitle); |
321 |
messageBox.setMessage(SecUIMessages.wizardDecodeWarning); |
322 |
if (messageBox.open() == SWT.YES) |
323 |
return false; |
324 |
} |
325 |
|
326 |
if (!reEncrypter.switchToNewPassword()) { |
327 |
MessageBox messageBox = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); |
328 |
messageBox.setText(SecUIMessages.changePasswordWizardTitle); |
329 |
messageBox.setMessage(SecUIMessages.wizardSwitchError); |
330 |
messageBox.open(); |
331 |
return false; |
332 |
} |
333 |
reEncrypter.encrypt(); |
334 |
|
335 |
// all good |
336 |
String msg = NLS.bind(SecUIMessages.passwordChangeDone, name); |
337 |
MessageDialog.openInformation(StorageUtils.getShell(), SecUIMessages.generalDialogTitle, msg); |
338 |
return true; |
339 |
} |
340 |
|
341 |
protected void updateDescription() { |
342 |
PasswordProviderDescription selectedModule = getSelectedModule(); |
343 |
if (selectedModule != null && detailsText != null) |
344 |
detailsText.setText(selectedModule.getDescription()); |
345 |
} |
346 |
|
279 |
} |
347 |
} |