private String getString(ISecurePreferences settings, String key) { try { return settings.get(key, ""); //$NON-NLS-1$ } catch (StorageException e) { return ""; //$NON-NLS-1$ } }
private String readProperty(String property) { ISecurePreferences preferences = getSecurePreferences(); if (preferences != null) { try { return preferences.get(property, null); } catch (StorageException e) { disableSecurePreferences(e); } } return null; }
protected void export(ISecurePreferences node, PrintStream stream) { if (IStorageConst.PROVIDER_NODE.equals(node.absolutePath())) return; // skip internal node String[] keys = node.keys(); if (keys.length > 0) { String header = '[' + node.absolutePath() + ']'; stream.println(header); for (int i = 0; i < keys.length; i++) { try { String data = keys[i] + " := " + node.get(keys[i], ""); //$NON-NLS-1$ //$NON-NLS-2$ stream.println(data); } catch (StorageException e) { Activator.log(IStatus.ERROR, SecUIMessages.failedDecrypt, null, e); } } } String[] children = node.childrenNames(); for (int i = 0; i < children.length; i++) { export(node.node(children[i]), stream); } }
protected void export(ISecurePreferences node, PrintStream stream) { if (IStorageConst.PROVIDER_NODE.equals(node.absolutePath())) return; // skip internal node String[] keys = node.keys(); if (keys.length > 0) { String header = '[' + node.absolutePath() + ']'; stream.println(header); for (int i = 0; i < keys.length; i++) { try { String data = keys[i] + " := " + node.get(keys[i], ""); //$NON-NLS-1$ //$NON-NLS-2$ stream.println(data); } catch (StorageException e) { Activator.log(IStatus.ERROR, SecUIMessages.failedDecrypt, null, e); } } } String[] children = node.childrenNames(); for (int i = 0; i < children.length; i++) { export(node.node(children[i]), stream); } }
private static String getFromSecure(IServer server, String attribute) throws StorageException { ISecurePreferences secureServersNode = getSecureServersNode(); if (!secureServersNode.nodeExists(getServerNodeName(server))) { return null; } ISecurePreferences secureServerNode = secureServersNode.node(getServerNodeName(server)); return secureServerNode.get(attribute, 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
continue; map.put(keys[i], node.get(keys[i], null)); } catch (StorageException e) {
continue; map.put(keys[i], node.get(keys[i], null)); } catch (StorageException e) {
public Object[] getElements(Object parent) { if (selectedNode == null) return new Object[0]; String[] keys = selectedNode.keys(); TableValuesElement[] result = new TableValuesElement[keys.length]; for (int i = 0; i < keys.length; i++) { try { if (selectedNode.isEncrypted(keys[i])) result[i] = new TableValuesElement(keys[i]); else result[i] = new TableValuesElement(keys[i], selectedNode.get(keys[i], null)); } catch (StorageException e) { Activator.log(IStatus.ERROR, SecUIMessages.failedDecrypt, null, e); } } return result; } }
public Object[] getElements(Object parent) { if (selectedNode == null) return new Object[0]; String[] keys = selectedNode.keys(); TableValuesElement[] result = new TableValuesElement[keys.length]; for (int i = 0; i < keys.length; i++) { try { if (selectedNode.isEncrypted(keys[i])) result[i] = new TableValuesElement(keys[i]); else result[i] = new TableValuesElement(keys[i], selectedNode.get(keys[i], null)); } catch (StorageException e) { Activator.log(IStatus.ERROR, SecUIMessages.failedDecrypt, null, e); } } return result; } }
public void run() { if (selectedNode == null) return; StructuredSelection selection = (StructuredSelection) tableViewer.getSelection(); Object selected = selection.getFirstElement(); if (!(selected instanceof TableValuesElement)) return; TableValuesElement node = (TableValuesElement) selected; String key = node.getKey(); try { String value = selectedNode.get(key, null); MessageBox dialog = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK); dialog.setText(SecUIMessages.showValueTitle); String msg = NLS.bind(SecUIMessages.showValueMsg, key, value); dialog.setMessage(msg); dialog.open(); } catch (StorageException e) { Activator.log(IStatus.ERROR, SecUIMessages.failedDecrypt, null, e); MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK); dialog.setMessage(SecUIMessages.failedDecrypt); dialog.open(); return; } } };
public void run() { if (selectedNode == null) return; StructuredSelection selection = (StructuredSelection) tableViewer.getSelection(); Object selected = selection.getFirstElement(); if (!(selected instanceof TableValuesElement)) return; TableValuesElement node = (TableValuesElement) selected; String key = node.getKey(); try { String value = selectedNode.get(key, null); MessageBox dialog = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK); dialog.setText(SecUIMessages.showValueTitle); String msg = NLS.bind(SecUIMessages.showValueMsg, key, value); dialog.setMessage(msg); dialog.open(); } catch (StorageException e) { Activator.log(IStatus.ERROR, SecUIMessages.failedDecrypt, null, e); MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK); dialog.setMessage(SecUIMessages.failedDecrypt); dialog.open(); return; } } };
String value; try { value = selectedNode.get(key, null); } catch (StorageException e) { MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
String value; try { value = selectedNode.get(key, null); } catch (StorageException e) { MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);