Package org.apache.shindig.gadgets.oauth.OAuthStore

Examples of org.apache.shindig.gadgets.oauth.OAuthStore.ConsumerInfo


    BasicOAuthStoreConsumerKeyAndSecret cks = new BasicOAuthStoreConsumerKeyAndSecret(
        "somekey", "default", KeyType.RSA_PRIVATE, "keyname", null);
    store.setDefaultKey(cks);

    ConsumerInfo consumer = store.getConsumerKeyAndSecret(t, "", provider);
    assertEquals("somekey", consumer.getConsumer().consumerKey);
    assertNull(consumer.getConsumer().consumerSecret);
    assertEquals("RSA-SHA1", consumer.getConsumer().getProperty("oauth_signature_method"));
    assertEquals("default", consumer.getConsumer().getProperty(RSA_SHA1.PRIVATE_KEY));
    assertEquals(provider, consumer.getConsumer().serviceProvider);
    assertEquals("keyname", consumer.getKeyName());
    assertEquals("default callback", consumer.getCallbackUrl());

    cks = new BasicOAuthStoreConsumerKeyAndSecret(
        "somekey", "default", KeyType.RSA_PRIVATE, "keyname", "callback");
    store.setDefaultKey(cks);
    consumer = store.getConsumerKeyAndSecret(t, "", provider);
    assertEquals("callback", consumer.getCallbackUrl());
  }
View Full Code Here


    store.initFromConfigString(SAMPLE_FILE);

    FakeGadgetToken t = new FakeGadgetToken();
    t.setAppUrl("http://localhost:8080/samplecontainer/examples/oauth.xml");
    OAuthServiceProvider provider = new OAuthServiceProvider("req", "authorize", "access");
    ConsumerInfo consumerInfo = store.getConsumerKeyAndSecret(t, "", provider);
    OAuthConsumer consumer = consumerInfo.getConsumer();
    assertEquals("gadgetConsumer", consumer.consumerKey);
    assertNull(consumerInfo.getKeyName());
    assertNull(consumerInfo.getCallbackUrl());
  }
View Full Code Here

      // This is plain old signed fetch.
      accessorBuilder.setParameterLocation(AccessorInfo.OAuthParamLocation.URI_QUERY);
    }

    // What consumer key/secret should we use?
    ConsumerInfo consumer;
    try {
      consumer = store.getConsumerKeyAndSecret(
          securityToken, arguments.getServiceName(), provider);
      accessorBuilder.setConsumer(consumer);
    } catch (GadgetException e) {
View Full Code Here

      // This is plain old signed fetch.
      accessorBuilder.setParameterLocation(AccessorInfo.OAuthParamLocation.URI_QUERY);
    }

    // What consumer key/secret should we use?
    ConsumerInfo consumer = store.getConsumerKeyAndSecret(
        securityToken, arguments.getServiceName(), provider);
    accessorBuilder.setConsumer(consumer);

    // Should we use the OAuth access token?  We never do this unless the client allows it, and
    // if owner == viewer.
View Full Code Here

      // This is plain old signed fetch.
      accessorBuilder.setParameterLocation(AccessorInfo.OAuthParamLocation.URI_QUERY);
    }

    // What consumer key/secret should we use?
    ConsumerInfo consumer;
    try {
      consumer = store.getConsumerKeyAndSecret(
          securityToken, arguments.getServiceName(), provider);
      accessorBuilder.setConsumer(consumer);
    } catch (GadgetException e) {
View Full Code Here

        context.checking(new Expectations()
        {
            {
                oneOf(serviceActionControllerMock).execute(with(any(ServiceActionContext.class)),
                        with(any(ServiceAction.class)));
                will(returnValue(new ConsumerInfoResponse(new ConsumerInfo(null, null, null))));
            }
        });

        sut.getConsumerKeyAndSecret(securityToken, "serviceName", provider);
        context.assertIsSatisfied();
View Full Code Here

            throw new ExecutionException("OAuth Consumer was not found");
        }
        net.oauth.OAuthConsumer consumer = new net.oauth.OAuthConsumer(oauthConsumer.getCallbackURL(), oauthConsumer
                .getConsumerKey(), oauthConsumer.getConsumerSecret(), request.getProvider());
        consumer.setProperty(OAuth.OAUTH_SIGNATURE_METHOD, oauthConsumer.getSignatureMethod());
        ConsumerInfo consumerInfo = new ConsumerInfo(consumer, null, oauthConsumer.getCallbackURL());
        return new ConsumerInfoResponse(consumerInfo);
    }
View Full Code Here

  }

  @Test
  public void testInit() throws Exception {
    store.init(createConfig().toString());
    ConsumerInfo info = store.getConsumerKeyAndSecret(createMock(SecurityToken.class), "service1", createMock(OAuthServiceProvider.class));
    assertEquals("http://example.com/callback1", info.getCallbackUrl());
    info = store.getConsumerKeyAndSecret(createMock(SecurityToken.class), "service2", createMock(OAuthServiceProvider.class));
    assertEquals("http://example.com/callback2", info.getCallbackUrl());
  }
View Full Code Here

  }

  @Test
  public void testGetConsumerKeyAndSecret() throws Exception {
    store.init(createConfig().toString());
    ConsumerInfo info = store.getConsumerKeyAndSecret(createMock(SecurityToken.class), "service1", createMock(OAuthServiceProvider.class));
    assertEquals("http://example.com/callback1", info.getCallbackUrl());
    assertEquals(OAuth.HMAC_SHA1, info.getConsumer().getProperty(OAuth.OAUTH_SIGNATURE_METHOD));
    info = store.getConsumerKeyAndSecret(createMock(SecurityToken.class), "service2", createMock(OAuthServiceProvider.class));
    assertEquals("http://example.com/callback2", info.getCallbackUrl());
    assertEquals(OAuth.RSA_SHA1, info.getConsumer().getProperty(OAuth.OAUTH_SIGNATURE_METHOD));
    assertEquals("secret2", info.getConsumer().getProperty(RSA_SHA1.PRIVATE_KEY));
    info = store.getConsumerKeyAndSecret(createMock(SecurityToken.class), "service3", createMock(OAuthServiceProvider.class));
    assertEquals("http://example.com/callback3", info.getCallbackUrl());
    assertEquals("PLAINTEXT", info.getConsumer().getProperty(OAuth.OAUTH_SIGNATURE_METHOD));
  }
View Full Code Here

  }

  @Test
  public void testSetDefaultCallbackUrl() throws Exception {
    store.init(createConfig().toString());
    ConsumerInfo info = store.getConsumerKeyAndSecret(createMock(SecurityToken.class), "servicedefault", createMock(OAuthServiceProvider.class));
    assertEquals("http://example.com/default", info.getCallbackUrl());
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.oauth.OAuthStore.ConsumerInfo

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.