Examples of OAuth2TokenPersistence


Examples of org.apache.shindig.gadgets.oauth2.persistence.OAuth2TokenPersistence

    token.setTokenType(OAuth2Message.BEARER_TOKEN_TYPE);
    token.setUser(MockUtils.USER);
  }

  protected static OAuth2TokenPersistence getAccessToken() throws Exception {
    final OAuth2TokenPersistence accessToken = new OAuth2TokenPersistence(
        MockUtils.getDummyEncrypter());
    MockUtils.setTokenCommons(accessToken);
    accessToken.setType(OAuth2Token.Type.ACCESS);
    return accessToken;
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.persistence.OAuth2TokenPersistence

    accessToken.setType(OAuth2Token.Type.ACCESS);
    return accessToken;
  }

  protected static OAuth2TokenPersistence getBadMacToken() throws Exception {
    final OAuth2TokenPersistence accessToken = new OAuth2TokenPersistence(
        MockUtils.getDummyEncrypter());
    MockUtils.setTokenCommons(accessToken);
    accessToken.setMacAlgorithm(OAuth2Message.HMAC_SHA_256);
    accessToken.setMacExt("1 2 3");
    accessToken.setMacSecret(MockUtils.MAC_SECRET.getBytes("UTF-8"));
    accessToken.setTokenType(OAuth2Message.MAC_TOKEN_TYPE);
    accessToken.setType(OAuth2Token.Type.ACCESS);
    return accessToken;
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.persistence.OAuth2TokenPersistence

  protected static String getJSONString() throws IOException {
    return MockUtils.loadFile("org/apache/shindig/gadgets/oauth2/oauth2_test.json");
  }

  protected static OAuth2TokenPersistence getMacToken() throws Exception {
    final OAuth2TokenPersistence accessToken = new OAuth2TokenPersistence(
        MockUtils.getDummyEncrypter());

    MockUtils.setTokenCommons(accessToken);
    accessToken.setMacAlgorithm(OAuth2Message.HMAC_SHA_1);
    accessToken.setMacExt("1 2 3");
    accessToken.setMacSecret(MockUtils.MAC_SECRET.getBytes("UTF-8"));
    accessToken.setTokenType(OAuth2Message.MAC_TOKEN_TYPE);
    accessToken.setType(OAuth2Token.Type.ACCESS);

    return accessToken;
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.persistence.OAuth2TokenPersistence

    return accessor;
  }

  protected static OAuth2TokenPersistence getRefreshToken() throws Exception {
    final OAuth2TokenPersistence refreshToken = new OAuth2TokenPersistence(
        MockUtils.getDummyEncrypter());
    refreshToken.setExpiresAt(1L);
    refreshToken.setGadgetUri(MockUtils.GADGET_URI1);
    refreshToken.setIssuedAt(0L);
    refreshToken.setMacAlgorithm("");
    refreshToken.setMacExt("");
    refreshToken.setMacSecret(new byte[] {});
    refreshToken.setProperties(MockUtils.EMPTY_MAP);
    refreshToken.setScope(MockUtils.SCOPE);
    refreshToken.setSecret(MockUtils.ACCESS_SECRET.getBytes("UTF-8"));
    refreshToken.setServiceName(MockUtils.SERVICE_NAME);
    refreshToken.setTokenType(OAuth2Message.MAC_TOKEN_TYPE);
    refreshToken.setType(OAuth2Token.Type.REFRESH);
    refreshToken.setUser(MockUtils.USER);
    return refreshToken;
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.persistence.OAuth2TokenPersistence

    Assert.assertEquals(null, result);
  }

  @Test
  public void testStoreToken_1() throws Exception {
    OAuth2Token token = new OAuth2TokenPersistence(MockUtils.getDummyEncrypter());
    token.setGadgetUri("xxx");
    token.setServiceName("yyy");
    token.setExpiresAt(2);
    token.setIssuedAt(1);
    token.setMacAlgorithm(OAuth2Message.HMAC_SHA_1);
    token.setMacSecret("shh, it's a secret".getBytes("UTF-8"));
    token.setScope("mac_scope");
    token.setSecret("i'll never tell".getBytes("UTF-8"));
    token.setTokenType(OAuth2Message.MAC_TOKEN_TYPE);
    token.setType(OAuth2Token.Type.ACCESS);
    token.setUser("zzz");

    final Integer result = this.cache.storeToken(token);

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

    token = this.cache.getToken(result);

    Assert.assertNotNull(token);
    Assert.assertEquals("xxx", token.getGadgetUri());
    Assert.assertEquals("yyy", token.getServiceName());

    Assert.assertEquals(2, token.getExpiresAt());
    Assert.assertEquals(1, token.getIssuedAt());
    Assert.assertEquals(OAuth2Message.HMAC_SHA_1, token.getMacAlgorithm());
    Assert.assertEquals("shh, it's a secret", new String(token.getMacSecret(), "UTF-8"));
    Assert.assertEquals("mac_scope", token.getScope());
    Assert.assertEquals("i'll never tell", new String(token.getSecret(), "UTF-8"));
    Assert.assertEquals(OAuth2Message.MAC_TOKEN_TYPE, token.getTokenType());
    Assert.assertEquals(OAuth2Token.Type.ACCESS, token.getType());
    Assert.assertEquals("zzz", token.getUser());
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.persistence.OAuth2TokenPersistence

    this.contextRoot = contextRoot;
    this.configFile = configFile;
  }

  public OAuth2Token createToken() {
    return new OAuth2TokenPersistence(this.encrypter);
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.persistence.OAuth2TokenPersistence

  /**
   * Creates a new OAuth 2 token that can be used as a refresh or access token.
   * @return A new OAuth 2 token.
   */
  public OAuth2Token createToken() {
    return new OAuth2TokenPersistence(this.encrypter);
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.persistence.OAuth2TokenPersistence

    return ret;
  }

  protected OAuth2Token internalCreateToken() {
    return new OAuth2TokenPersistence(this.encrypter);
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.persistence.OAuth2TokenPersistence

    token.setTokenType(OAuth2Message.BEARER_TOKEN_TYPE);
    token.setUser(MockUtils.USER);
  }

  protected static OAuth2TokenPersistence getAccessToken() throws Exception {
    final OAuth2TokenPersistence accessToken = new OAuth2TokenPersistence(
            MockUtils.getDummyEncrypter());
    MockUtils.setTokenCommons(accessToken);
    accessToken.setType(OAuth2Token.Type.ACCESS);
    return accessToken;
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.persistence.OAuth2TokenPersistence

    accessToken.setType(OAuth2Token.Type.ACCESS);
    return accessToken;
  }

  protected static OAuth2TokenPersistence getBadMacToken() throws Exception {
    final OAuth2TokenPersistence accessToken = new OAuth2TokenPersistence(
            MockUtils.getDummyEncrypter());
    MockUtils.setTokenCommons(accessToken);
    accessToken.setMacAlgorithm(OAuth2Message.HMAC_SHA_256);
    accessToken.setMacExt("1 2 3");
    accessToken.setMacSecret(MockUtils.MAC_SECRET.getBytes("UTF-8"));
    accessToken.setTokenType(OAuth2Message.MAC_TOKEN_TYPE);
    accessToken.setType(OAuth2Token.Type.ACCESS);
    return accessToken;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.