Package org.eclipse.equinox.security.storage

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


    return null;
  }

  public Map getCredentialMap(URL url, String projectName, String authType) {
    try {
      ISecurePreferences root = SecurePreferencesFactory.getDefault();
      ISecurePreferences node = root.node(FORCE_PROJECT + "/" + projectName);
      Map credentialMap = new HashMap();
      credentialMap.put(PROP_PASSWORD, node.get(PROP_PASSWORD, ""));
      credentialMap.put(PROP_TOKEN, node.get(PROP_TOKEN, ""));
      return credentialMap;

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


          for (ILaunchConfiguration configuration : configs) {
            addTunnelConfiguration(configuration, hostToUsers);
          }
          // Then, check with the secure-storage node and remove
          // anything that should not be there.
          ISecurePreferences root = SecurePreferencesFactory
              .getDefault();
          ISecurePreferences node = root
              .node(IPHPDebugConstants.SSH_TUNNEL_SECURE_PREF_NODE);
          String[] listedHosts = node.childrenNames();
          // For each host that we have in the secured storage, check
          // that it's existing in the launch configurations and that
          // it contains
          // only the user names that are defined.
          // In any other case, remove the item from the storage (a
          // host node, or a user node).
          for (String host : listedHosts) {
            if (!hostToUsers.containsKey(host)) {
              ISecurePreferences hostNode = node.node(host);
              hostNode.removeNode();
            } else {
              if (node.nodeExists(host)) {
                ISecurePreferences hostNode = node.node(host);
                // holds the user names field in the secure
                // preference
                String[] usersKeys = hostNode.keys();
                List<String> usersList = hostToUsers.get(host);
                for (String userNode : usersKeys) {
                  if (!usersList.contains(userNode)) {
                    hostNode.remove(userNode);
                  }
                }
              }
            }
          }
View Full Code Here

  public static ISecurePreferences getSecurePreferences(String host) {
    String hostPath = "";//$NON-NLS-1$
    if (host != null) {
      hostPath = '/' + host;
    }
    ISecurePreferences root = SecurePreferencesFactory.getDefault();
    ISecurePreferences node = root
        .node(IPHPDebugConstants.SSH_TUNNEL_SECURE_PREF_NODE + hostPath);
    return node;
  }
View Full Code Here

  return true;
    }

    public static void ErasePassword(String host) {
  String nodename = ConvertHostToNodeName(host);
  ISecurePreferences root = SecurePreferencesFactory.getDefault();
  ISecurePreferences node = root.node(nodename);
  try {
      if (root.nodeExists(nodename)) {
    node.put("password", null, true);
      }

  } catch (StorageException e) {
      // ignore this error
      e.printStackTrace();
View Full Code Here

  myhost = host;
  myPassword = null;
  myLogin = null;

  String nodename = ConvertHostToNodeName(myhost);
  ISecurePreferences root = SecurePreferencesFactory.getDefault();
  ISecurePreferences node = root.node(nodename);

  try {
      if (root.nodeExists(nodename)) {
    myPassword = node.get("password", null);
    myLogin = node.get("login", null);
      }
      if (myPassword == null) {
    PasswordDialog dialog = new PasswordDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
    if (myLogin != null)
        dialog.setUser(myLogin);
    dialog.sethost(host);
    // get the new values from the dialog
    if (dialog.open() == Window.OK) {
        myLogin = dialog.getUser();
        myPassword = dialog.getPassword();
        node.put("login", myLogin, false);
        node.put("password", myPassword, true);
    } else {
        return false;
    }
      }
  } catch (StorageException e) {
View Full Code Here

    /* Fallback to default location */
    return SecurePreferencesFactory.getDefault();
  }

  private ICredentials getAuthorizationInfo(URI link, String realm) throws CredentialsException {
    ISecurePreferences securePreferences = getSecurePreferences();

    /* Check if Bundle is Stopped */
    if (securePreferences == null)
      return null;

    /* Return from Equinox Security Storage */
    if (securePreferences.nodeExists(SECURE_FEED_NODE)) { // Global Feed Node
      ISecurePreferences allFeedsPreferences = securePreferences.node(SECURE_FEED_NODE);
      if (allFeedsPreferences.nodeExists(EncodingUtils.encodeSlashes(link.toString()))) { // Feed Node
        ISecurePreferences feedPreferences = allFeedsPreferences.node(EncodingUtils.encodeSlashes(link.toString()));
        if (feedPreferences.nodeExists(EncodingUtils.encodeSlashes(realm != null ? realm : REALM))) { // Realm Node
          ISecurePreferences realmPreferences = feedPreferences.node(EncodingUtils.encodeSlashes(realm != null ? realm : REALM));

          try {
            String username = realmPreferences.get(USERNAME, null);
            String password = realmPreferences.get(PASSWORD, null);
            String domain = realmPreferences.get(DOMAIN, null);

            if (username != null && password != null)
              return new Credentials(username, password, domain);
          } catch (StorageException e) {
            throw new CredentialsException(Activator.getDefault().createErrorStatus(e.getMessage(), e));
View Full Code Here

      fInMemoryStore.put(toCacheKey(link, realm), credentials);
    }

    /* Store Credentials in secure Storage */
    else {
      ISecurePreferences securePreferences = getSecurePreferences();

      /* Check if Bundle is Stopped */
      if (securePreferences == null)
        return;

      /* Store in Equinox Security Storage */
      ISecurePreferences allFeedsPreferences = securePreferences.node(SECURE_FEED_NODE);
      ISecurePreferences feedPreferences = allFeedsPreferences.node(EncodingUtils.encodeSlashes(link.toString()));
      ISecurePreferences realmPreference = feedPreferences.node(EncodingUtils.encodeSlashes(realm != null ? realm : REALM));

      IPreferenceScope globalScope = Owl.getPreferenceService().getGlobalScope();

      /* OS Password is only supported on Windows and Mac */
      boolean useOSPassword = globalScope.getBoolean(DefaultPreferences.USE_OS_PASSWORD);
      if (!Platform.OS_WIN32.equals(Platform.getOS()) && !Platform.OS_MACOSX.equals(Platform.getOS()))
        useOSPassword = false;

      boolean encryptPW = useOSPassword || globalScope.getBoolean(DefaultPreferences.USE_MASTER_PASSWORD);
      try {
        if (credentials.getUsername() != null)
          realmPreference.put(USERNAME, credentials.getUsername(), encryptPW);

        if (credentials.getPassword() != null)
          realmPreference.put(PASSWORD, credentials.getPassword(), encryptPW);

        if (credentials.getDomain() != null)
          realmPreference.put(DOMAIN, credentials.getDomain(), encryptPW);

        realmPreference.flush(); // Flush to disk early
      } catch (StorageException e) {
        throw new CredentialsException(Activator.getDefault().createErrorStatus(e.getMessage(), e));
      } catch (IOException e) {
        throw new CredentialsException(Activator.getDefault().createErrorStatus(e.getMessage(), e));
      }
View Full Code Here

    /* Delete from Cache */
    removeUnprotected(link, realm);

    /* Check if Bundle is Stopped */
    ISecurePreferences securePreferences = getSecurePreferences();
    if (securePreferences == null)
      return;

    /* Remove from Equinox Security Storage */
    if (securePreferences.nodeExists(SECURE_FEED_NODE)) { // Global Feed Node
      ISecurePreferences allFeedsPreferences = securePreferences.node(SECURE_FEED_NODE);
      if (allFeedsPreferences.nodeExists(EncodingUtils.encodeSlashes(link.toString()))) { // Feed Node
        ISecurePreferences feedPreferences = allFeedsPreferences.node(EncodingUtils.encodeSlashes(link.toString()));
        if (feedPreferences.nodeExists(EncodingUtils.encodeSlashes(realm != null ? realm : REALM))) { // Realm Node
          ISecurePreferences realmPreferences = feedPreferences.node(EncodingUtils.encodeSlashes(realm != null ? realm : REALM));
          realmPreferences.clear();
          realmPreferences.removeNode();
          try {
            feedPreferences.flush();
          } catch (IOException e) {
            throw new CredentialsException(Activator.getDefault().createErrorStatus(e.getMessage(), e));
          }
View Full Code Here

    /* Clear cached info */
    InternalExchangeUtils.passwordProvidersReset();

    /* Remove all Nodes */
    ISecurePreferences secureRoot = getSecurePreferences();

    /* Check if Bundle is Stopped */
    if (secureRoot == null)
      return;

    String[] childrenNames = secureRoot.childrenNames();
    for (String child : childrenNames) {
      secureRoot.node(child).removeNode();
    }

    /* Flush to Disk */
    try {
      secureRoot.flush();
    } catch (IOException e) {
      Activator.getDefault().logError(e.getMessage(), e);
    }
  }
View Full Code Here

  private ISecurePreferences getPasswordNode(String login) {
    if(login == null)
      return null;

    ISecurePreferences preferences = SecurePreferencesFactory.getDefault();
    if(preferences == null)
      return null;

    String host = Strings.trimToNull(preferenceHelper.getForgeURI());
    if(host == null)
      return null;

    StringBuilder bld = new StringBuilder();
    bld.append("/Puppetforge Credentials/"); //$NON-NLS-1$
    bld.append(login);
    bld.append('/');
    Checksums.appendSHA1(bld, host);
    return preferences.node(bld.toString());
  }
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.