Package org.eclipse.equinox.security.storage

Examples of org.eclipse.equinox.security.storage.ISecurePreferences


*/
public class SecureStorageUtil {
   
    public static String getFromSecureStorage(String baseKey, ILaunchConfiguration launch, String key) {
        try {
          ISecurePreferences node = getNode(baseKey, launch);
            String val = node.get(key, null);
            if (val == null) {
              return null;
            }
            return new String(EncodingUtils.decodeBase64(val));
        } catch(IOException e) {
View Full Code Here


          return null;
    }
    }

    public static void storeInSecureStorage(String baseKey, ILaunchConfiguration launch, String key, String val ) throws StorageException, UnsupportedEncodingException {
        ISecurePreferences node = getNode(baseKey, launch);
        if( val == null )
          node.put(key, val, true);
        else
          node.put(key, EncodingUtils.encodeBase64(val.getBytes()), true /* encrypt */);
    }
View Full Code Here

        throws UnsupportedEncodingException {
    String secureKey = new StringBuilder(baseKey)
      .append(launch.getName())
      .append(Path.SEPARATOR).toString();

    ISecurePreferences root = SecurePreferencesFactory.getDefault();
    String encoded = URLEncoder.encode(secureKey, "UTF-8"); //$NON-NLS-1$
    return root.node(encoded);
    }
View Full Code Here

   * @throws IOException
   */
  public void putCredentials(URIish uri, UserPasswordCredentials credentials)
      throws StorageException, IOException {
    String pathName = calcNodePath(uri);
    ISecurePreferences node = preferences.node(pathName);
    node.put(USER, credentials.getUser(), false);
    node.put(PASSWORD, credentials.getPassword(), true);
    node.flush();
  }
View Full Code Here

  public UserPasswordCredentials getCredentials(URIish uri)
      throws StorageException {
    String pathName = calcNodePath(uri);
    if (!preferences.nodeExists(pathName))
      return null;
    ISecurePreferences node = preferences.node(pathName);
    String user = node.get(USER, ""); //$NON-NLS-1$
    String password = node.get(PASSWORD, ""); //$NON-NLS-1$
    if (uri.getUser() != null && !user.equals(uri.getUser()))
      return null;
    return new UserPasswordCredentials(user, password);
  }
View Full Code Here

   */
  public void clearCredentials(URIish uri) throws IOException {
    String pathName = calcNodePath(uri);
    if (!preferences.nodeExists(pathName))
      return;
    ISecurePreferences node = preferences.node(pathName);
    node.removeNode();
    node.flush();
  }
View Full Code Here

    URIish uri = new URIish("http://testRepo.example.com/testrepo");
    UserPasswordCredentials credentials = new UserPasswordCredentials(
        "agitter", "letmein");
    store.putCredentials(uri, credentials);

    ISecurePreferences node = secureStoreForTest.node(EGitSecureStore
        .calcNodePath(uri).toString());
    assertEquals("agitter", node.get("user", null));
    assertTrue(node.isEncrypted("password"));
    assertEquals("letmein", node.get("password", null));
  }
View Full Code Here

        "http://user:pass@testRepo.example.com/testrepo");
    UserPasswordCredentials credentials = new UserPasswordCredentials(
        "agitter", "letmein");
    store.putCredentials(uri, credentials);

    ISecurePreferences node = secureStoreForTest.node(EGitSecureStore
        .calcNodePath(uri).toString());
    assertEquals("agitter", node.get("user", null));
    assertTrue(node.isEncrypted("password"));
    assertEquals("letmein", node.get("password", null));
  }
View Full Code Here

  private static final String FORCE_PROJECT = "Force Projects";
  private ISecurePreferences root;

  public void addAuthorizationInfo(String AUTH_URL, IProject project, String AUTH_TYPE, Map credentialMap) {
    root = SecurePreferencesFactory.getDefault();
    ISecurePreferences node = root.node(FORCE_PROJECT + "/" + project.getName());
    try {
      logger.info("Saving values in secure storage");
      node.put(PROP_PASSWORD, credentialMap.get(PROP_PASSWORD).toString(), true);
      node.put(PROP_TOKEN, credentialMap.get(PROP_TOKEN).toString(), true);

    } catch (StorageException e) {
      logger.error("Unable to store values in equinox secure storage", e);
    }
View Full Code Here

    }

  }

  public String getPassword(IProject project, String AUTH_URL, String AUTH_TYPE) {
    ISecurePreferences node = root.node(FORCE_PROJECT + "/" + project.getName());
    try {
      return node.get(PROP_PASSWORD, "");
    } catch (StorageException e) {
      logger.error("Unable to retrive values from equinox secure storage", e);
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.equinox.security.storage.ISecurePreferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.