Package org.rssowl.core.connection

Examples of org.rssowl.core.connection.ICredentialsProvider


   * net.URI)
   */
  public IProxyCredentials getProxyCredentials(URI link) throws CredentialsException {

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

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


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

    /* Require credentials provider */
    ICredentialsProvider credentialsProvider = fCredentialsProvider.get(protocol);
    if (credentialsProvider == null)
      throw new CredentialsException(Activator.getDefault().createErrorStatus(NLS.bind(Messages.ConnectionServiceImpl_ERROR_NO_CREDENTIAL_PROVIDER, protocol), null));

    return credentialsProvider;
  }
View Full Code Here

  private String handleAuthentication(boolean refresh, IProgressMonitor monitor) throws ConnectionException {

    /* Obtain Google Credentials */
    URI googleLoginUri = URI.create(SyncUtils.GOOGLE_LOGIN_URL);
    ICredentialsProvider provider = Owl.getConnectionService().getCredentialsProvider(googleLoginUri);
    ICredentials credentials = provider.getAuthCredentials(googleLoginUri, null);
    if (credentials == null)
      throw new AuthenticationRequiredException(null, Status.CANCEL_STATUS);

    /* Obtain Google Authentication Token */
    String token = SyncUtils.getGoogleAuthToken(credentials.getUsername(), credentials.getPassword(), refresh, monitor);
View Full Code Here

  @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;

    DynamicDAO.save(feed1);
    DynamicDAO.save(feed2);

    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

  @SuppressWarnings("nls")
  public void testProtectedFeedInMemory() 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;

    DynamicDAO.save(feed1);
    DynamicDAO.save(feed2);

    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.setInMemoryAuthCredentials(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.setInMemoryAuthCredentials(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.setInMemoryAuthCredentials(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

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.