import org.eclipse.equinox.security.storage.SecurePreferencesFactory; import org.eclipse.equinox.security.storage.ISecurePreferences; ISecurePreferences root = SecurePreferencesFactory.getDefault(); ISecurePreferences coresec = root.node("org.eclipse.rse.core.security"); ISecurePreferences typeftp = coresec.node("org.eclipse.rse.systemtype.ftp"); pass = typeftp.get("HERE_FTP_HOST//HERE_MY_FTP_USER_NAME", "test");
private static void tryRemoveSecureProperties(String serverNodeName) { ISecurePreferences secureServersNode = getSecureServersNode(); if (secureServersNode.nodeExists(serverNodeName)) { secureServersNode.node(serverNodeName).removeNode(); } }
public ReEncrypter(ISecurePreferences prefs, String moduleID) { this.moduleID = moduleID; root = prefs.node("/"); //$NON-NLS-1$ }
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); }
public ReEncrypter(ISecurePreferences prefs, String moduleID) { this.moduleID = moduleID; root = prefs.node("/"); //$NON-NLS-1$ }
/** * Answer secured preferences which can be used for storing sensitive * information of this tab * * @return default instance of secure preferences for this tab, * <code>null</code> if application was unable to create secure * preferences using default location */ private ISecurePreferences getPreferences(String sectionName) { ISecurePreferences preferences = SecurePreferencesFactory.getDefault(); if (preferences == null) { return null; } return preferences.node(IPDEUIConstants.PLUGIN_ID).node(sectionName); } }
public Object[] getChildren(Object parent) { if (!(parent instanceof ISecurePreferences)) return new Object[0]; ISecurePreferences node = (ISecurePreferences) parent; String[] childrenNames = node.childrenNames(); ISecurePreferences[] result = new ISecurePreferences[childrenNames.length]; for (int i = 0; i < childrenNames.length; i++) result[i] = node.node(childrenNames[i]); return result; }
public Object[] getChildren(Object parent) { if (!(parent instanceof ISecurePreferences)) return new Object[0]; ISecurePreferences node = (ISecurePreferences) parent; String[] childrenNames = node.childrenNames(); ISecurePreferences[] result = new ISecurePreferences[childrenNames.length]; for (int i = 0; i < childrenNames.length; i++) result[i] = node.node(childrenNames[i]); return result; }
private ISecurePreferences getSecurePreferences() { if (!securePreferencesDisabled.get()) { String serverId = getServerId(); if (serverId != null) { ISecurePreferences securePreferences = SecurePreferencesFactory.getDefault().node( CloudFoundryPlugin.PLUGIN_ID); securePreferences = securePreferences.node(EncodingUtils.encodeSlashes(serverId)); return securePreferences; } } return 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
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); } }
for (Iterator i = elements.iterator(); i.hasNext();) { TmpElement element = (TmpElement) i.next(); ISecurePreferences node = root.node(element.getPath()); Map values = element.getValues(); for (Iterator j = values.keySet().iterator(); j.hasNext();) {
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); } }
decrypt(node.node(childrenNames[i]));
decrypt(node.node(childrenNames[i]));
public void run() { TreeSelection selection = (TreeSelection) nodeTreeViewer.getSelection(); Object selected = selection.getFirstElement(); if (selected instanceof ISecurePreferences) { ISecurePreferences node = (ISecurePreferences) selected; NewNodeDialog nodeDialog = new NewNodeDialog(nodeTreeViewer.getControl().getShell()); if (nodeDialog.open() != Window.OK) return; String name = nodeDialog.getNodeName(); ISecurePreferences child = node.node(name); parentView.modified(); // expand and select new node ISecurePreferences parentNode = child.parent(); if (parentNode != null) nodeTreeViewer.refresh(parentNode, false); else nodeTreeViewer.refresh(false); nodeTreeViewer.expandToLevel(child, 0); nodeTreeViewer.setSelection(new StructuredSelection(child), true); } } };
public void run() { TreeSelection selection = (TreeSelection) nodeTreeViewer.getSelection(); Object selected = selection.getFirstElement(); if (selected instanceof ISecurePreferences) { ISecurePreferences node = (ISecurePreferences) selected; NewNodeDialog nodeDialog = new NewNodeDialog(nodeTreeViewer.getControl().getShell()); if (nodeDialog.open() != Window.OK) return; String name = nodeDialog.getNodeName(); ISecurePreferences child = node.node(name); parentView.modified(); // expand and select new node ISecurePreferences parentNode = child.parent(); if (parentNode != null) nodeTreeViewer.refresh(parentNode, false); else nodeTreeViewer.refresh(false); nodeTreeViewer.expandToLevel(child, 0); nodeTreeViewer.setSelection(new StructuredSelection(child), true); } } };