Package org.apache.shindig.gadgets.oauth2

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


  @Before
  public void setUp() throws Exception {
    super.setUp();
    injector = Guice.createInjector(
        new PropertiesModule(), new GadgetAdminModule(), new DefaultGuiceModule(),
        new OAuthModule(), new OAuth2Module(), new OAuth2PersistenceModule(), new OAuth2MessageModule(), new OAuth2HandlerModule());
    ParseModule.DOMImplementationProvider domImpl =
        new ParseModule.DOMImplementationProvider();
    htmlParser = new CajaHtmlParser(domImpl.get());
    serializer = new CajaHtmlSerializer();
    ContainerConfig config = injector.getInstance(ContainerConfig.class);
View Full Code Here


  @Before
  public void setUp() {
    injector = Guice.createInjector(
        new PropertiesModule(),
        new GadgetAdminModule(),
        new DefaultGuiceModule(), new OAuthModule(), new OAuth2Module(), new OAuth2PersistenceModule(), new OAuth2MessageModule(), new OAuth2HandlerModule());
  }
View Full Code Here

  @Before
  public void setUp() throws Exception {
    super.setUp();
    injector = Guice.createInjector(
        new PropertiesModule(), new GadgetAdminModule(), new DefaultGuiceModule(),
        new OAuthModule(), new OAuth2Module(), new OAuth2PersistenceModule(), new OAuth2MessageModule(), new OAuth2HandlerModule());
    ParseModule.DOMImplementationProvider domImpl =
        new ParseModule.DOMImplementationProvider();
    htmlParser = new CajaHtmlParser(domImpl.get());
    serializer = new CajaHtmlSerializer();
    ContainerConfig config = injector.getInstance(ContainerConfig.class);
View Full Code Here

  private static final String TEST_NS = "http://example.com";

  @Before
  public void setUp() throws Exception {
    Injector injector = Guice.createInjector(new GadgetAdminModule(), new DefaultGuiceModule(), new OAuthModule(), new OAuth2Module(), new PropertiesModule(), new OAuth2PersistenceModule(), new OAuth2MessageModule(), new OAuth2HandlerModule());
    parser = injector.getInstance(GadgetHtmlParser.class);
    processor = injector.getInstance(TemplateProcessor.class);
    context = new TemplateContext(new Gadget(), null);
  }
View Full Code Here

  protected void configure() {
    // OAuth1.0a
    install(Modules.override(new OAuthModule()).with(new OAuthModuleOverride()));
   
    // OAuth2
    install(Modules.override(new OAuth2Module()).with(new OAuth2ModuleOverride()));
    install(Modules.override(new OAuth2PersistenceModule()).with(new OAuth2PersistenceModuleOverride()));
  }
View Full Code Here

  public void setMacSecret(byte[] secret) throws OAuth2RequestException {
    this.macSecret = secret;
    try {
      this.encryptedMacSecret = this.encrypter.encrypt(secret);
    } catch (final OAuth2EncryptionException e) {
      throw new OAuth2RequestException(OAuth2Error.SECRET_ENCRYPTION_PROBLEM,
          "OAuth2TokenPersistence could not encrypt the mac secret", e);
    }
  }
View Full Code Here

    Assert.assertNotNull(this.cache.getClient(MockUtils.CLIENT_INDEX2));
  }

  @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());
View Full Code Here

    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
        accessor, response);

    Assert.assertNull(result);

    final OAuth2Token accessToken = TokenAuthorizationResponseHandlerTest.store.getToken(
        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
        accessor.getScope(), OAuth2Token.Type.ACCESS);
    Assert.assertNotNull(accessToken);
    Assert.assertEquals("xxx", new String(accessToken.getSecret(), "UTF-8"));
    Assert.assertEquals(OAuth2Message.BEARER_TOKEN_TYPE, accessToken.getTokenType());
    Assert.assertTrue(accessToken.getExpiresAt() > 1000);

    final OAuth2Token refreshToken = TokenAuthorizationResponseHandlerTest.store.getToken(
        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
        accessor.getScope(), OAuth2Token.Type.REFRESH);
    Assert.assertNotNull(refreshToken);
    Assert.assertEquals("yyy", new String(refreshToken.getSecret(), "UTF-8"));
  }
View Full Code Here

    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
        accessor, response);

    Assert.assertNull(result);

    final OAuth2Token accessToken = TokenAuthorizationResponseHandlerTest.store.getToken(
        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
        accessor.getScope(), OAuth2Token.Type.ACCESS);
    Assert.assertNotNull(accessToken);
    Assert.assertEquals("xxx", new String(accessToken.getSecret(), "UTF-8"));
    Assert.assertEquals(OAuth2Message.BEARER_TOKEN_TYPE, accessToken.getTokenType());
    Assert.assertTrue(accessToken.getExpiresAt() > 1000);

    final OAuth2Token refreshToken = TokenAuthorizationResponseHandlerTest.store.getToken(
        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
        accessor.getScope(), OAuth2Token.Type.REFRESH);
    Assert.assertNotNull(refreshToken);
    Assert.assertEquals("yyy", new String(refreshToken.getSecret(), "UTF-8"));
  }
View Full Code Here

    final OAuth2HandlerError result = fixture.handleRequest(accessor, request);

    Assert.assertNull(result);

    final OAuth2Token accessToken = CodeAuthorizationResponseHandlerTest.store.getToken(
        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
        accessor.getScope(), OAuth2Token.Type.ACCESS);
    Assert.assertNotNull(accessToken);
    Assert.assertEquals("xxx", new String(accessToken.getSecret(), "UTF-8"));
    Assert.assertEquals(OAuth2Message.BEARER_TOKEN_TYPE, accessToken.getTokenType());
    Assert.assertTrue(accessToken.getExpiresAt() > 1000);

    final OAuth2Token refreshToken = CodeAuthorizationResponseHandlerTest.store.getToken(
        accessor.getGadgetUri(), accessor.getServiceName(), accessor.getUser(),
        accessor.getScope(), OAuth2Token.Type.REFRESH);
    Assert.assertNotNull(refreshToken);
    Assert.assertEquals("yyy", new String(refreshToken.getSecret(), "UTF-8"));
  }
View Full Code Here

TOP

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

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.