Package org.apache.shindig.gadgets.oauth2

Examples of org.apache.shindig.gadgets.oauth2.OAuth2CallbackState


    Assert.assertNull(this.cache.getToken(MockUtils.ACCESS_TOKEN_INDEX));
  }

  @Test
  public void testGetClient_1() throws Exception {
    final OAuth2Client result = this.cache.getClient(MockUtils.CLIENT_INDEX1);

    Assert.assertNotNull(result);
    Assert.assertEquals(MockUtils.CLIENT_ID1, result.getClientId());
  }
View Full Code Here


  }

  @Test
  public void testRemoveClient_1() throws Exception {

    OAuth2Client result = this.cache.getClient(MockUtils.CLIENT_INDEX1);

    Assert.assertNotNull(result);

    result = this.cache.removeClient(MockUtils.CLIENT_INDEX1);
View Full Code Here

  }

  @Test
  public void testStoreClient_1() throws Exception {

    OAuth2Client client = new OAuth2Client(MockUtils.getDummyEncrypter());
    client.setGadgetUri("xxx");
    client.setServiceName("yyy");

    final Integer result = this.cache.storeClient(client);

    Assert.assertEquals(909248813, result.intValue());

    client = this.cache.getClient(result);

    Assert.assertNotNull(client);
    Assert.assertEquals("xxx", client.getGadgetUri());
    Assert.assertEquals("yyy", client.getServiceName());
  }
View Full Code Here

  }

  @Test
  public void testStoreClient_2() throws Exception {

    final OAuth2Client client = null;

    final Integer result = this.cache.storeClient(client);

    Assert.assertNull(result);
  }
View Full Code Here

    if (isLogging) {
      BasicOAuth2Store.LOG.log("index = {0}", index);
    }

    OAuth2Client client = this.cache.getClient(index);

    if (isLogging) {
      BasicOAuth2Store.LOG.log("client from cache = {0}", client);
    }
View Full Code Here

    final Integer index = this.cache.getOAuth2AccessorIndex(gadgetUri, serviceName, user, scope);

    OAuth2Accessor ret = this.cache.getOAuth2Accessor(index);

    if ((ret == null) || (!ret.isValid())) {
      final OAuth2Client client = this.getClient(gadgetUri, serviceName);

      if (client != null) {
        final OAuth2Token accessToken = this.getToken(gadgetUri, serviceName, user, scope,
            OAuth2Token.Type.ACCESS);
        final OAuth2Token refreshToken = this.getToken(gadgetUri, serviceName, user, scope,
            OAuth2Token.Type.REFRESH);

        final BasicOAuth2Accessor newAccessor = new BasicOAuth2Accessor(gadgetUri, serviceName,
            user, scope, client.isAllowModuleOverride(), this, this.globalRedirectUri);
        newAccessor.setAccessToken(accessToken);
        newAccessor.setAuthorizationUrl(client.getAuthorizationUrl());
        newAccessor.setClientAuthenticationType(client.getClientAuthenticationType());
        newAccessor.setAuthorizationHeader(client.isAuthorizationHeader());
        newAccessor.setUrlParameter(client.isUrlParameter());
        newAccessor.setClientId(client.getClientId());
        newAccessor.setClientSecret(client.getClientSecret());
        newAccessor.setGrantType(client.getGrantType());
        newAccessor.setRedirectUri(client.getRedirectUri());
        newAccessor.setRefreshToken(refreshToken);
        newAccessor.setTokenUrl(client.getTokenUrl());
        newAccessor.setType(client.getType());
        ret = newAccessor;

        this.storeOAuth2Accessor(ret);
      }
    }
View Full Code Here

  }

  protected static OAuth2Store getDummyStore() throws Exception {
    if (MockUtils.dummyStore == null) {
      final OAuth2Cache cache = new InMemoryCache();
      final OAuth2Persister persister = MockUtils.getDummyPersister();
      MockUtils.dummyStore = MockUtils.getDummyStore(cache, persister, MockUtils.REDIRECT_URI);
    }

    MockUtils.dummyStore.clearCache();
    MockUtils.dummyStore.init();
View Full Code Here

    return accessToken;
  }

  private static BasicOAuth2Accessor getOAuth2AccessorCommon() throws Exception {
    final OAuth2Cache cache = new InMemoryCache();
    final OAuth2Persister persister = MockUtils.getDummyPersister();
    final OAuth2Store store = MockUtils.getDummyStore(cache, persister, MockUtils.REDIRECT_URI);
    final BasicOAuth2Accessor accessor = new BasicOAuth2Accessor(MockUtils.GADGET_URI1,
        MockUtils.SERVICE_NAME, MockUtils.USER, MockUtils.SCOPE, true, store,
        MockUtils.REDIRECT_URI);
View Full Code Here

    return accessor;
  }

  protected static OAuth2Accessor getOAuth2Accessor_ClientCredentialsRedirecting() throws Exception {
    final OAuth2Cache cache = new InMemoryCache();
    final OAuth2Persister persister = MockUtils.getDummyPersister();
    final OAuth2Store store = MockUtils.getDummyStore(cache, persister, MockUtils.REDIRECT_URI);
    final BasicOAuth2Accessor accessor = new BasicOAuth2Accessor(MockUtils.GADGET_URI1,
        MockUtils.SERVICE_NAME, MockUtils.USER, MockUtils.SCOPE, true, store,
        MockUtils.REDIRECT_URI);
View Full Code Here

      this.store = new BasicOAuth2Store(cache, persister, redirectUri);

      if (importFromConfig) {
        try {
          final OAuth2Persister source = new JSONOAuth2Persister(encrypter, authority,
                  globalRedirectUri, contextRoot);
          BasicOAuth2Store.runImport(source, persister, importClean);
        } catch (final OAuth2PersistenceException e) {
          if (OAuth2Module.LOG.isLoggable()) {
            OAuth2Module.LOG.log("store init exception", e);
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.oauth2.OAuth2CallbackState

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.