use of org.eclipse.equinox.security.storage.ISecurePreferences in project epp.mpc by eclipse.
the class MarketplaceStorageService method cleanupExtraStorageService.
private static IStorageService cleanupExtraStorageService(IStorageService service, IStorageService extraService) {
IStorageService.Dynamic removeDynamic;
IStorageService keepService;
if (extraService instanceof IStorageService.Dynamic) {
removeDynamic = (IStorageService.Dynamic) extraService;
keepService = service;
} else if (service instanceof IStorageService.Dynamic) {
removeDynamic = (IStorageService.Dynamic) service;
keepService = extraService;
} else {
return service;
}
if (removeDynamic instanceof StorageService && keepService instanceof StorageService) {
StorageService removeImpl = (StorageService) removeDynamic;
StorageService keepImpl = (StorageService) keepService;
ISecurePreferences removeSecurePreferences = removeImpl.getSecurePreferences();
ISecurePreferences keepSecurePreferences = keepImpl.getSecurePreferences();
try {
copySecurePreferences(removeSecurePreferences, keepSecurePreferences);
} catch (Exception e) {
MarketplaceClientCore.error(NLS.bind("Failed to migrate secure storage values from {0} to {1}", removeDynamic.getServiceURI(), keepService.getServiceURI()), e);
}
}
removeDynamic.remove();
return keepService;
}
use of org.eclipse.equinox.security.storage.ISecurePreferences in project jbosstools-openshift by jbosstools.
the class Cluster method load.
public void load(Preferences clusterNode, ISecurePreferences secureClusterNode) throws StorageException {
clusterNode.get(ENDPOINT_URL_KEY, OSIOCoreConstants.OSIO_ENDPOINT);
try {
String[] ids = clusterNode.childrenNames();
for (String id : ids) {
Account account = new Account(id, this);
Preferences accountNode = clusterNode.node(id);
ISecurePreferences secureAccountNode = secureClusterNode.node(id);
try {
account.load(accountNode, secureAccountNode);
identities.add(account);
} catch (StorageException e) {
OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e);
}
}
} catch (BackingStoreException e) {
OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e);
}
}
use of org.eclipse.equinox.security.storage.ISecurePreferences in project jbosstools-openshift by jbosstools.
the class Cluster method save.
@Override
public void save() {
try {
Preferences accountsNode = AccountModel.getAccountsPreferences();
Preferences clusterNode = accountsNode.node(getId());
ISecurePreferences clusterSecureNode = AccountModel.getSecureAccountsPreferences().node(getId());
clusterNode.put(ENDPOINT_URL_KEY, getEndpointURL());
removed.forEach(id -> {
try {
clusterNode.node(id).removeNode();
clusterSecureNode.node(id).removeNode();
} catch (BackingStoreException e) {
OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e);
}
});
removed.clear();
clusterNode.flush();
clusterSecureNode.flush();
} catch (BackingStoreException | IOException e) {
OpenShiftIOCoreActivator.logError("Error saving cluster in storage", e);
}
}
use of org.eclipse.equinox.security.storage.ISecurePreferences in project jbosstools-openshift by jbosstools.
the class Account method save.
@Override
public void save() {
try {
ISecurePreferences secureAccountsRoot = AccountModel.getSecureAccountsPreferences();
Preferences accountsRoot = AccountModel.getAccountsPreferences();
ISecurePreferences secureAccountNode = secureAccountsRoot.node(cluster.getId()).node(getId());
Preferences accountNode = accountsRoot.node(cluster.getId()).node(getId());
accountNode.putLong(ACCESS_TOKEN_EXPIRY_TIME_KEY, getAccessTokenExpiryTime());
accountNode.putLong(KEYREFRESH_TOKEN_EXPIRY_TIME, getRefreshTokenExpiryTime());
accountNode.putLong(LAST_REFRESHED_TIME_KEY, getLastRefreshedTime());
secureAccountNode.put(ACCESS_TOKEN_KEY, getAccessToken(), true);
secureAccountNode.put(REFRESH_TOKEN_KEY, getRefreshToken(), true);
accountNode.flush();
secureAccountNode.flush();
} catch (StorageException | BackingStoreException | IOException e) {
OpenShiftIOCoreActivator.logError("Error saving credentials ", e);
}
}
use of org.eclipse.equinox.security.storage.ISecurePreferences in project polymap4-core by Polymap4.
the class InternalExchangeUtils method defaultStorageDelete.
/**
* Closes open default storage, if any, and deletes the actual file.
*/
public static void defaultStorageDelete() {
ISecurePreferences defaultStorage = SecurePreferencesFactory.getDefault();
if (defaultStorage == null)
return;
URL location = defaultStorageLocation();
if (location == null)
return;
// clear the default preferences store from the mapper
SecurePreferencesMapper.clearDefault();
// delete the actual file
if (StorageUtils.exists(location))
StorageUtils.delete(location);
// FUTURE: this is a good place to notify delete listeners
}
Aggregations