Examples of ISecurePreferences


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

    /* 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

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

   * @see
   * org.rssowl.core.connection.ICredentialsProvider#setAuthCredentials(org.
   * rssowl.core.connection.ICredentials, java.net.URI, java.lang.String)
   */
  public void setAuthCredentials(ICredentials credentials, URI link, String realm) throws CredentialsException {
    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

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

   * @see
   * org.rssowl.core.connection.ICredentialsProvider#deleteAuthCredentials(java
   * .net.URI, java.lang.String)
   */
  public synchronized void deleteAuthCredentials(URI link, String realm) throws CredentialsException {
    ISecurePreferences securePreferences = getSecurePreferences();

    /* Check if Bundle is Stopped */
    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

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

    /* 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

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

  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);
      }
View Full Code Here

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

  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;
  }
View Full Code Here

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

    username = readProperty(KEY_USERNAME);
    password = readProperty(KEY_PASSWORD);
  }
 
  private String readProperty(String property) {
    ISecurePreferences preferences = getSecurePreferences();
    if (preferences != null) {
      try {
        return preferences.get(property, null);
      }
      catch (StorageException e) {
        disableSecurePreferences(e);
      }
    }
View Full Code Here

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

     * <li>Resets the existing details in the IPreferenceStore to empty string
     * </ul>
     */
    protected void updateAccounts() {
        IPreferenceStore prefStore = saros.getPreferenceStore();
        ISecurePreferences secureStore = saros.getSecurePrefs();

        // Get the active account
        String username = prefStore.getString(PreferenceConstants.USERNAME);
        String server = prefStore.getString(PreferenceConstants.SERVER);
        String password = prefStore.getString(PreferenceConstants.PASSWORD);

        try {
            // If there is an active account...
            if (!username.equals("")) {
                // ... put it into secure storage
                secureStore.put(PreferenceConstants.USERNAME, username, false);
                secureStore.put(PreferenceConstants.SERVER, server, false);
                secureStore.put(PreferenceConstants.PASSWORD, password, false);

                // ... and clear the old preferences
                prefStore.setValue(PreferenceConstants.USERNAME, "");
                prefStore.setValue(PreferenceConstants.SERVER, "");
                prefStore.setValue(PreferenceConstants.PASSWORD, "");
            }

            // Now do the same with any remaining accounts
            int i = 1;
            username = prefStore.getString(PreferenceConstants.USERNAME + i);
            server = prefStore.getString(PreferenceConstants.SERVER + i);
            password = prefStore.getString(PreferenceConstants.PASSWORD + i);

            while (!username.equals("")) {
                secureStore.put(PreferenceConstants.USERNAME + i, username,
                    false);
                secureStore.put(PreferenceConstants.SERVER + i, server, false);
                secureStore.put(PreferenceConstants.PASSWORD + i, password,
                    false);

                prefStore.setValue(PreferenceConstants.USERNAME + i, "");
                prefStore.setValue(PreferenceConstants.SERVER + i, "");
                prefStore.setValue(PreferenceConstants.PASSWORD + i, "");
View Full Code Here

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

     * Might be an empty string but never null.
     *
     * @return
     */
    public String getServer() {
        ISecurePreferences prefs = saros.getSecurePrefs();
        String server = "";

        try {
            server = prefs.get(PreferenceConstants.SERVER, "");
        } catch (StorageException e) {
            log.error("Exception while retrieving account: " + e.getMessage());
        }
        return server;
    }
View Full Code Here

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

     * Might be an empty string but never null.
     *
     * @return User name
     */
    public String getUserName() {
        ISecurePreferences prefs = saros.getSecurePrefs();
        String username = "";

        try {
            username = prefs.get(PreferenceConstants.USERNAME, "");
        } catch (StorageException e) {
            log.error("Exception while retrieving account: " + e.getMessage());
        }
        return username;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.