Package org.apache.shindig.gadgets.oauth2

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


  }

  @Test
  public void testStoreOAuth2Accessor_1() throws Exception {
    final OAuth2Store store = MockUtils.getDummyStore(this.cache, null, null);
    OAuth2Accessor accessor = new BasicOAuth2Accessor("XXX", "YYY", "ZZZ", "", false, store, "AAA");

    final Integer result = this.cache.storeOAuth2Accessor(accessor);

    Assert.assertEquals(-1664180105, result.intValue());

    accessor = this.cache.getOAuth2Accessor(result);

    Assert.assertNotNull(accessor);
    Assert.assertEquals("XXX", accessor.getGadgetUri());
    Assert.assertEquals("YYY", accessor.getServiceName());
    Assert.assertEquals("ZZZ", accessor.getUser());
    Assert.assertEquals("", accessor.getScope());
    Assert.assertEquals(false, accessor.isAllowModuleOverrides());
    Assert.assertEquals("AAA", accessor.getRedirectUri());
    Assert.assertEquals("-1664180105", accessor.getState());
  }
View Full Code Here


  @Test
  public void testStoreOAuth2Accessor_1() throws Exception {
    final OAuth2Store store = MockUtils.getDummyStore(this.cache, null, null, null, null, null,
            null);
    OAuth2Accessor accessor = new BasicOAuth2Accessor("XXX", "YYY", "ZZZ", "", false, store, "AAA",
            null, null);

    this.cache.storeOAuth2Accessor(accessor);

    final OAuth2CallbackState state = new OAuth2CallbackState(MockUtils.getDummyStateCrypter());
    state.setGadgetUri(accessor.getGadgetUri());
    state.setServiceName(accessor.getServiceName());
    state.setUser(accessor.getUser());
    state.setScope(accessor.getScope());
    accessor = this.cache.getOAuth2Accessor(state);

    Assert.assertNotNull(accessor);
    Assert.assertEquals("XXX", accessor.getGadgetUri());
    Assert.assertEquals("YYY", accessor.getServiceName());
    Assert.assertEquals("ZZZ", accessor.getUser());
    Assert.assertEquals("", accessor.getScope());
    Assert.assertEquals(false, accessor.isAllowModuleOverrides());
    Assert.assertEquals("AAA", accessor.getRedirectUri());
  }
View Full Code Here

        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,
            this.authority, this.contextRoot);
        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());
        newAccessor.setAllowedDomains(client.getAllowedDomains());
        ret = newAccessor;

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

  }

  @Test(expected = OAuth2RequestException.class)
  public void testGetAuthorizationRequest_1() throws Exception {
    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
    final OAuth2Accessor accessor = null;

    final String completeAuthorizationUrl = "xxx";

    fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
  }
View Full Code Here

  }

  @Test(expected = OAuth2RequestException.class)
  public void testGetAuthorizationRequest_2() throws Exception {
    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();

    final String completeAuthorizationUrl = null;

    fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
  }
View Full Code Here

  }

  @Test(expected = OAuth2RequestException.class)
  public void testGetAuthorizationRequest_3() throws Exception {
    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();

    final String completeAuthorizationUrl = "xxx";

    fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
  }
View Full Code Here

  }

  @Test(expected = OAuth2RequestException.class)
  public void testGetAuthorizationRequest_4() throws Exception {
    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
    final String completeAuthorizationUrl = "xxx";

    fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);
  }
View Full Code Here

  }

  @Test
  public void testGetAuthorizationRequest_5() throws Exception {
    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_ClientCredentials();
    final String completeAuthorizationUrl = "xxx";

    final HttpRequest result = fixture.getAuthorizationRequest(accessor, completeAuthorizationUrl);

    Assert.assertNotNull(result);
View Full Code Here

  }

  @Test(expected = OAuth2RequestException.class)
  public void testGetCompleteUrl_1() throws Exception {
    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
    final OAuth2Accessor accessor = null;
    fixture.getCompleteUrl(accessor);
  }
View Full Code Here

  }

  @Test(expected = OAuth2RequestException.class)
  public void testGetCompleteUrl_2() throws Exception {
    final ClientCredentialsGrantTypeHandler fixture = ClientCredentialsGrantTypeHandlerTest.ccgth;
    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Error();
    fixture.getCompleteUrl(accessor);
  }
View Full Code Here

TOP

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

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.