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); } }
public boolean flush(String newServerId) { String oldServerId = getServerId(); if (oldServerId != null && !oldServerId.equals(newServerId)) { initialize(); ISecurePreferences preferences = getSecurePreferences(); if (preferences != null) { preferences.removeNode(); } } this.serverId = newServerId; ISecurePreferences preferences = getSecurePreferences(); if (preferences != null) { try { preferences.put(KEY_USERNAME, username, true); preferences.put(KEY_PASSWORD, password, true); return true; } catch (StorageException e) { disableSecurePreferences(e); } } return false; }
String key = (String) j.next(); try { node.put(key, (String) values.get(key), true); } catch (StorageException e) {
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
String key = entry.getKey(); try { node.put(key, entry.getValue(), true); } catch (StorageException e) {
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; } }
public void run() { if (selectedNode == null) return; NewValueDialog newValueDialog = new NewValueDialog(selectedNode.keys(), tableViewer.getControl().getShell()); if (newValueDialog.open() != Window.OK) return; String key = newValueDialog.getKey(); String value = newValueDialog.getValue(); boolean encrypt = newValueDialog.encrypt(); try { selectedNode.put(key, value, encrypt); parentView.modified(); } catch (StorageException e) { Activator.log(IStatus.ERROR, SecUIMessages.failedEncrypt, null, e); } tableViewer.refresh(); } };
public void run() { if (selectedNode == null) return; NewValueDialog newValueDialog = new NewValueDialog(selectedNode.keys(), tableViewer.getControl().getShell()); if (newValueDialog.open() != Window.OK) return; String key = newValueDialog.getKey(); String value = newValueDialog.getValue(); boolean encrypt = newValueDialog.encrypt(); try { selectedNode.put(key, value, encrypt); parentView.modified(); } catch (StorageException e) { Activator.log(IStatus.ERROR, SecUIMessages.failedEncrypt, null, e); } tableViewer.refresh(); } };
selectedNode.put(key, value, encrypted); parentView.modified(); } catch (StorageException e) {
selectedNode.put(key, value, encrypted); parentView.modified(); } catch (StorageException e) {