use of org.eclipse.equinox.internal.security.storage.SecurePreferencesContainer in project polymap4-core by Polymap4.
the class ReEncrypter method encrypt.
/**
* The method will encrypt all data from the memory structure created by decrypt using current
* passwords and providers. The original encrypted data will be overwritten.
*/
public boolean encrypt() {
boolean result = true;
// we'll directly inject here a requirement to use the specified module to encrypt data
SecurePreferencesContainer container = ((SecurePreferencesWrapper) root).getContainer();
Object originalProperty = container.getOption(IProviderHints.REQUIRED_MODULE_ID);
container.setOption(IProviderHints.REQUIRED_MODULE_ID, moduleID);
for (Iterator i = elements.iterator(); i.hasNext(); ) {
TmpElement element = (TmpElement) i.next();
ISecurePreferences node = root.node(element.getPath());
Map values = element.getValues();
for (Iterator j = values.keySet().iterator(); j.hasNext(); ) {
String key = (String) j.next();
try {
node.put(key, (String) values.get(key), true);
} catch (StorageException e) {
// this value will not be re-coded
String msg = NLS.bind(SecAuthMessages.encryptingError, key, node.absolutePath());
AuthPlugin.getDefault().logError(msg, e);
result = false;
}
}
}
if (originalProperty != null)
container.setOption(IProviderHints.REQUIRED_MODULE_ID, originalProperty);
else
container.removeOption(IProviderHints.REQUIRED_MODULE_ID);
return result;
}
Aggregations