Examples of ICredentialsProvider


Examples of org.rssowl.core.connection.ICredentialsProvider

  @Test
  @SuppressWarnings("nls")
  public void testProtectedFeed() throws Exception {
    IConnectionService conManager = Owl.getConnectionService();
    URI feedUrl = new URI("http://www.rssowl.org/rssowl2dg/tests/connection/authrequired/feed_rss.xml");
    ICredentialsProvider credProvider = conManager.getCredentialsProvider(feedUrl);

    IFeed feed = new Feed(feedUrl);
    AuthenticationRequiredException e = null;

    try {
      new DefaultProtocolHandler().openStream(feed.getLink(), null);
    } catch (AuthenticationRequiredException e1) {
      e = e1;
    }

    assertNotNull(e);

    ICredentials credentials = new ICredentials() {
      public String getDomain() {
        return null;
      }

      public String getPassword() {
        return "admin";
      }

      public String getUsername() {
        return "bpasero";
      }
    };

    credProvider.setAuthCredentials(credentials, feedUrl);

    InputStream inS = new DefaultProtocolHandler().openStream(feed.getLink(), null);
    assertNotNull(inS);

    Owl.getInterpreter().interpret(inS, feed);
View Full Code Here

Examples of org.rssowl.core.connection.ICredentialsProvider

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

        /* Store for plain URI too */
        ICredentialsProvider credProvider = Owl.getConnectionService().getCredentialsProvider(link);
        credProvider.setAuthCredentials(authCredentials, link, null);

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

Examples of org.rssowl.core.connection.ICredentialsProvider

  @SuppressWarnings("nls")
  public void testProtectedFeed() throws Exception {
    IConnectionService conManager = Owl.getConnectionService();
    URI feedUrl1 = new URI("http://www.rssowl.org/rssowl2dg/tests/connection/authrequired/feed_rss.xml");
    URI feedUrl2 = new URI("http://www.rssowl.org/rssowl2dg/tests/connection/authrequired/feed_rss_copy.xml");
    ICredentialsProvider credProvider = conManager.getCredentialsProvider(feedUrl1);

    IFeed feed1 = new Feed(feedUrl1);
    IFeed feed2 = new Feed(feedUrl2);
    AuthenticationRequiredException e = null;

    try {
      Owl.getConnectionService().getHandler(feed1.getLink()).openStream(feed1.getLink(), null, null);
    } catch (AuthenticationRequiredException e1) {
      e = e1;
    }

    assertNotNull(e);
    e = null;

    ICredentials credentials = new ICredentials() {
      public String getDomain() {
        return null;
      }

      public String getPassword() {
        return "admin";
      }

      public String getUsername() {
        return "bpasero";
      }
    };

    credProvider.setAuthCredentials(credentials, feedUrl1, null);

    InputStream inS = Owl.getConnectionService().getHandler(feed1.getLink()).openStream(feed1.getLink(), null, null);
    assertNotNull(inS);

    Owl.getInterpreter().interpret(inS, feed1, null);
    assertEquals("RSS 2.0", feed1.getFormat());

    /* Test authentication by other realm is not working */
    credProvider.setAuthCredentials(credentials, URIUtils.normalizeUri(feedUrl2, true), "Other Directory");

    try {
      Owl.getConnectionService().getHandler(feed2.getLink()).openStream(feed2.getLink(), null, null);
    } catch (AuthenticationRequiredException e1) {
      e = e1;
    }

    assertNotNull(e);

    /* Test authentication by realm is working */
    credProvider.setAuthCredentials(credentials, URIUtils.normalizeUri(feedUrl2, true), "Restricted Directory");

    inS = Owl.getConnectionService().getHandler(feed2.getLink()).openStream(feed2.getLink(), null, null);
    assertNotNull(inS);

    Owl.getInterpreter().interpret(inS, feed2, null);
View Full Code Here

Examples of org.rssowl.core.connection.ICredentialsProvider

        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)
                credentialsProvider.deleteAuthCredentials(feedLink);
            }
          } catch (CredentialsException e) {
            Activator.getDefault().getLog().log(e.getStatus());
          }
        }
View Full Code Here

Examples of org.rssowl.core.connection.ICredentialsProvider

    /* Require protocol */
    if (!StringUtils.isSet(protocol))
      throw new CredentialsException(Activator.getDefault().createErrorStatus("Unknown protocol", null));

    /* Require credentials provider */
    ICredentialsProvider credentialsProvider = fCredentialsProvider.get(protocol);
    if (credentialsProvider == null)
      throw new CredentialsException(Activator.getDefault().createErrorStatus("Could not find any credentials provider for protocol: " + protocol, null));

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

Examples of org.rssowl.core.connection.ICredentialsProvider

    /* Require protocol */
    if (!StringUtils.isSet(protocol))
      throw new CredentialsException(Activator.getDefault().createErrorStatus("Unknown protocol", null));

    /* Require credentials provider */
    ICredentialsProvider credentialsProvider = fCredentialsProvider.get(protocol);
    if (credentialsProvider == null)
      throw new CredentialsException(Activator.getDefault().createErrorStatus("Could not find any credentials provider for protocol: " + protocol, null));

    /* Retrieve Credentials */
    IProxyCredentials credentials = credentialsProvider.getProxyCredentials(link);
    return credentials;
  }
View Full Code Here

Examples of org.rssowl.core.connection.ICredentialsProvider

      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

Examples of org.rssowl.core.connection.ICredentialsProvider

      }
    };

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

Examples of org.rssowl.core.connection.ICredentialsProvider

  }

  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

Examples of org.rssowl.core.connection.ICredentialsProvider

    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.getAuthCredentials(link, realm);
        if (authCredentials != null)
          return new CredentialsModelData(authCredentials.getUsername(), authCredentials.getPassword(), link, realm);
      }
    }
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.