fInMemoryStore.put(toCacheKey(link, realm), credentials);
}
/* Store Credentials in secure Storage */
else {
ISecurePreferences securePreferences = getSecurePreferences();
/* Check if Bundle is Stopped */
if (securePreferences == null)
return;
/* Store in Equinox Security Storage */
ISecurePreferences allFeedsPreferences = securePreferences.node(SECURE_FEED_NODE);
ISecurePreferences feedPreferences = allFeedsPreferences.node(EncodingUtils.encodeSlashes(link.toString()));
ISecurePreferences realmPreference = feedPreferences.node(EncodingUtils.encodeSlashes(realm != null ? realm : REALM));
IPreferenceScope globalScope = Owl.getPreferenceService().getGlobalScope();
/* OS Password is only supported on Windows and Mac */
boolean useOSPassword = globalScope.getBoolean(DefaultPreferences.USE_OS_PASSWORD);
if (!Platform.OS_WIN32.equals(Platform.getOS()) && !Platform.OS_MACOSX.equals(Platform.getOS()))
useOSPassword = false;
boolean encryptPW = useOSPassword || globalScope.getBoolean(DefaultPreferences.USE_MASTER_PASSWORD);
try {
if (credentials.getUsername() != null)
realmPreference.put(USERNAME, credentials.getUsername(), encryptPW);
if (credentials.getPassword() != null)
realmPreference.put(PASSWORD, credentials.getPassword(), encryptPW);
if (credentials.getDomain() != null)
realmPreference.put(DOMAIN, credentials.getDomain(), encryptPW);
realmPreference.flush(); // Flush to disk early
} catch (StorageException e) {
throw new CredentialsException(Activator.getDefault().createErrorStatus(e.getMessage(), e));
} catch (IOException e) {
throw new CredentialsException(Activator.getDefault().createErrorStatus(e.getMessage(), e));
}