public void widgetSelected(SelectionEvent e) { ISecurePreferences root = SecurePreferencesFactory.getDefault(); if (root == null) return; try { root.flush(); } catch (IOException exception) { Activator.log(IStatus.ERROR, exception.getMessage(), null, exception); } validateSave(); // save could fail so re-check } });
static public void clearDefault() { if (defaultPreferences == null) return; try { defaultPreferences.flush(); } catch (IOException e) { // ignore in this context } close((((SecurePreferencesWrapper) defaultPreferences).getContainer().getRootData())); defaultPreferences = null; }
private static void storeCredentials(IServer server, String username, String password) { try { ISecurePreferences secureServersNode = getSecureServersNode(); ISecurePreferences secureServerNode = secureServersNode.node(getServerNodeName(server)); secureServerNode.put(USERNAME_ATTRIBUTE, username, true); secureServerNode.put(PASSWORD_ATTRIBUTE, password, true); secureServersNode.flush(); } catch (StorageException | IOException e) { throw new IllegalStateException("Unable to store server credentials in secure storage: " + e.getMessage(), e); } }
static public void clearDefault() { if (defaultPreferences == null) return; try { defaultPreferences.flush(); } catch (IOException e) { // ignore in this context } close((((SecurePreferencesWrapper) defaultPreferences).getContainer().getRootData())); defaultPreferences = null; }
ISecurePreferences root = org.eclipse.equinox.security.storage.SecurePreferencesFactory.getDefault(); if (root == null) return null; ISecurePreferences node = root.node("/your.class.path.or.something.else"); // get the node for your application e.g. this.getClass().getCanonicalName() node = node.node( "some name"); // get custom node from the tree node.get( "key" ); // load node.put("key","value", true / false (encrypt) ); // store (no save operation) node.remove("key"); // remove node.flush(); // save
return; try { root.flush(); } catch (IOException exception) { Activator.log(IStatus.ERROR, exception.getMessage(), null, exception);
private void saveProxyAuth(IProxyData data) { ISecurePreferences node= getNode(); if (node == null) return; try { if (data.getUserId() != null) node.put(INFO_PROXY_USER, data.getUserId(), true /* store encrypted */); else node.remove(INFO_PROXY_USER); if (data.getPassword() != null) node.put(INFO_PROXY_PASS, data.getPassword(), true /* store encrypted */); else node.remove(INFO_PROXY_PASS); } catch (StorageException e) { Activator.logError(e.getMessage(), e); return; } // optional: save it right away in case something crashes later try { node.flush(); } catch (IOException e) { Activator.logError(e.getMessage(), e); return; } }
prefNode.put(IRepository.PROP_USERNAME, loginDetails.getUserName(), true); prefNode.put(IRepository.PROP_PASSWORD, loginDetails.getPassword(), true); prefNode.flush(); } catch (StorageException e1) { throw internalError(e1); prefNode.removeNode(); try { prefNode.flush(); } catch (IOException e) { throw internalError(e);
prefNode.put(IRepository.PROP_USERNAME, loginDetails.getUserName(), true); prefNode.put(IRepository.PROP_PASSWORD, loginDetails.getPassword(), true); prefNode.flush(); } catch (StorageException e1) { throw internalError(e1); prefNode.removeNode(); try { prefNode.flush(); } catch (IOException e) { throw internalError(e);