Package org.rssowl.core.connection

Examples of org.rssowl.core.connection.ICredentialsProvider


      }
    }

    /* Write all Credentials into credential provider again */
    for (CredentialsModelData credential : credentials) {
      ICredentialsProvider credentialsProvider = Owl.getConnectionService().getCredentialsProvider(credential.fNormalizedLink);
      if (credentialsProvider != null) {

        /* Implementation Detail: Need to clear PlatformCredentialsProvider once if provided */
        if (!clearedOnce && credentialsProvider instanceof PlatformCredentialsProvider) {
          ((PlatformCredentialsProvider) credentialsProvider).clear();
          clearedOnce = true;
        }

        try {
          credentialsProvider.setAuthCredentials(credential.toCredentials(), credential.fNormalizedLink, credential.fRealm);
        } catch (CredentialsException e) {
          Activator.getDefault().logError(e.getMessage(), e);
        }
      }
    }

    /* Delete Dummy Credentials Again */
    if (dummyCredentials != null) {
      ICredentialsProvider credentialsProvider = Owl.getConnectionService().getCredentialsProvider(dummyCredentials.fNormalizedLink);
      if (credentialsProvider != null) {
        try {
          credentialsProvider.deleteAuthCredentials(dummyCredentials.fNormalizedLink, dummyCredentials.fRealm);
        } catch (CredentialsException e) {
          Activator.getDefault().logError(e.getMessage(), e);
        }
      }
    }
View Full Code Here


      final String username = dialog.getUsername();
      final String password = dialog.getPassword();

      try {
        URI siteUri = new URI(site);
        ICredentialsProvider credentialsProvider = Owl.getConnectionService().getCredentialsProvider(siteUri);
        if (credentialsProvider != null) {
          credentialsProvider.setAuthCredentials(new ICredentials() {
            public String getUsername() {
              return username;
            }

            public String getPassword() {
View Full Code Here

      }
    };

    /* Bring Back Security to Default State resetting everything */
    if (dialog.open() == IDialogConstants.OK_ID) {
      ICredentialsProvider provider = Owl.getConnectionService().getCredentialsProvider(URI.create(DUMMY_LINK));
      ((PlatformCredentialsProvider) provider).clear();
      reSetAllCredentials();
      setShowError(false);

      if (!Application.IS_ECLIPSE)
View Full Code Here

  }

  private void remove(CredentialsModelData data, boolean all) {

    /* Remove normalized link and realm */
    ICredentialsProvider provider = fConService.getCredentialsProvider(data.getNormalizedLink());
    if (provider != null) {
      try {
        provider.deleteAuthCredentials(data.getNormalizedLink(), data.getRealm());
      } catch (CredentialsException e) {
        Activator.getDefault().logError(e.getMessage(), e);
      }
    }

    /* Remove all other stored Credentials matching normalized link and realm if set */
    if (all) {
      Collection<IBookMark> bookmarks = DynamicDAO.loadAll(IBookMark.class);
      for (IBookMark bookmark : bookmarks) {
        String realm = (String) bookmark.getProperty(Controller.BM_REALM_PROPERTY);

        URI feedLink = bookmark.getFeedLinkReference().getLink();
        URI normalizedLink = URIUtils.normalizeUri(feedLink, true);

        /*
         * If realm is null, then this bookmark successfully loaded due to another bookmark
         * that the user successfully authenticated to. If the realm is not null, then we
         * have to compare the realm to ensure that no credentials from the same host but
         * a different realm gets removed.
         */
        if ((realm == null || realm.equals(data.getRealm())) && normalizedLink.equals(data.getNormalizedLink())) {
          provider = fConService.getCredentialsProvider(feedLink);
          if (provider != null) {
            try {
              provider.deleteAuthCredentials(feedLink, null); //Null as per contract in DefaultProtocolHandler
              bookmark.removeProperty(Controller.BM_REALM_PROPERTY);
            } catch (CredentialsException e) {
              Activator.getDefault().logError(e.getMessage(), e);
            }
          }
View Full Code Here

    return credentials;
  }

  private CredentialsModelData loadCredentials(URI link, String realm) throws CredentialsException {
    if (StringUtils.isSet(link.getScheme())) {
      ICredentialsProvider credentialsProvider = fConService.getCredentialsProvider(link);
      if (credentialsProvider != null) {
        ICredentials authCredentials = credentialsProvider.getPersistedAuthCredentials(link, realm);
        if (authCredentials != null)
          return new CredentialsModelData(authCredentials.getUsername(), authCredentials.getPassword(), link, realm);
      }
    }
View Full Code Here

      }
    }

    /* Write all Credentials into credential provider again */
    for (CredentialsModelData credential : credentials) {
      ICredentialsProvider credentialsProvider = Owl.getConnectionService().getCredentialsProvider(credential.fNormalizedLink);
      if (credentialsProvider != null) {

        /* Implementation Detail: Need to clear PlatformCredentialsProvider once if provided */
        if (!clearedOnce && credentialsProvider instanceof PlatformCredentialsProvider) {
          ((PlatformCredentialsProvider) credentialsProvider).clear();
          clearedOnce = true;
        }

        try {
          credentialsProvider.setAuthCredentials(credential.toCredentials(), credential.fNormalizedLink, credential.fRealm);
        } catch (CredentialsException e) {
          Activator.getDefault().logError(e.getMessage(), e);
        }
      }
    }

    /* Delete Dummy Credentials Again */
    if (dummyCredentials != null) {
      ICredentialsProvider credentialsProvider = Owl.getConnectionService().getCredentialsProvider(dummyCredentials.fNormalizedLink);
      if (credentialsProvider != null) {
        try {
          credentialsProvider.deleteAuthCredentials(dummyCredentials.fNormalizedLink, dummyCredentials.fRealm);
        } catch (CredentialsException e) {
          Activator.getDefault().logError(e.getMessage(), e);
        }
      }
    }
View Full Code Here

    return equivalentItemLists;
  }

  private String getGoogleApiToken(IProgressMonitor monitor) throws ConnectionException {
    ICredentialsProvider provider = Owl.getConnectionService().getCredentialsProvider(URI.create(SyncUtils.GOOGLE_LOGIN_URL));
    ICredentials creds = provider.getAuthCredentials(URI.create(SyncUtils.GOOGLE_LOGIN_URL), null);
    if (creds == null)
      throw new AuthenticationRequiredException(null, Status.CANCEL_STATUS);

    return SyncUtils.getGoogleApiToken(creds.getUsername(), creds.getPassword(), monitor);
  }
View Full Code Here

      /* Credentials based on Host / Port / Realm provided */
      if (authCredentials != null) {

        /* Store for plain URI too */
        ICredentialsProvider credProvider = Owl.getConnectionService().getCredentialsProvider(link);
        if (credProvider.getPersistedAuthCredentials(normalizedUri, e.getRealm()) != null)
          credProvider.setAuthCredentials(authCredentials, link, null);
        else
          credProvider.setInMemoryAuthCredentials(authCredentials, link, null);

        /* Reopen Stream */
        try {
          return internalOpenStream(link, normalizedUri, e.getRealm(), properties);
        } catch (AuthenticationRequiredException ex) {
View Full Code Here

        for (FeedEvent feedEvent : events) {
          URI feedLink = feedEvent.getEntity().getLink();
          try {
            String protocol = feedLink.getScheme();
            if (protocol != null) {
              ICredentialsProvider credentialsProvider = fCredentialsProvider.get(protocol);

              /* Delete Auth Credentials if provided */
              if (credentialsProvider != null && credentialsProvider.getAuthCredentials(feedLink, null) != null)
                credentialsProvider.deleteAuthCredentials(feedLink, null);
            }
          } catch (CredentialsException e) {
            Activator.getDefault().getLog().log(e.getStatus());
          }
        }
View Full Code Here

   * .URI, java.lang.String)
   */
  public ICredentials getAuthCredentials(URI link, String realm) throws CredentialsException {

    /* Require credentials provider */
    ICredentialsProvider credentialsProvider = internalGetCredentialsProvider(link);

    /* Retrieve Credentials */
    ICredentials credentials = credentialsProvider.getAuthCredentials(link, realm);
    return credentials;
  }
View Full Code Here

TOP

Related Classes of org.rssowl.core.connection.ICredentialsProvider

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.