Examples of BlobCrypter


Examples of org.apache.shindig.common.crypto.BlobCrypter

*/
public class OAuthFetcherConfigTest extends EasyMockTestCase {

  @Test
  public void testOAuthFetcherConfig() {
    BlobCrypter crypter = mock(BlobCrypter.class);
    mock(HttpCache.class);
    GadgetOAuthTokenStore tokenStore = mock(GadgetOAuthTokenStore.class);
    OAuthCallbackGenerator callbackGenerator = mock(OAuthCallbackGenerator.class);
    OAuthFetcherConfig config = new OAuthFetcherConfig(crypter, tokenStore, new TimeSource(),
        callbackGenerator);
View Full Code Here

Examples of org.apache.shindig.common.crypto.BlobCrypter

    Assert.assertNotSame("body is " + body, body.indexOf("window.close()"), -1);
  }
 
  @Test
  public void testServletWithCallback() throws Exception {
    BlobCrypter crypter = new BasicBlobCrypter("00000000000000000000".getBytes());
    OAuthCallbackState state = new OAuthCallbackState(crypter);
    OAuthCallbackServlet servlet = new OAuthCallbackServlet();
    servlet.setStateCrypter(crypter);   
    state.setRealCallbackUrl("http://www.example.com/callback");
    expect(request.getParameter("cs")).andReturn(state.getEncryptedState());
View Full Code Here

Examples of org.apache.shindig.common.crypto.BlobCrypter

    assertEquals("private,max-age=3600", cacheControl);
  }
 
  @Test
  public void testServletWithCallback_noQueryParams() throws Exception {
    BlobCrypter crypter = new BasicBlobCrypter("00000000000000000000".getBytes());
    OAuthCallbackState state = new OAuthCallbackState(crypter);
    OAuthCallbackServlet servlet = new OAuthCallbackServlet();
    servlet.setStateCrypter(crypter);   
    state.setRealCallbackUrl("http://www.example.com/callback");
    expect(request.getParameter("cs")).andReturn(state.getEncryptedState());
View Full Code Here

Examples of org.apache.shindig.common.crypto.BlobCrypter

  public BlobCrypterSecurityTokenDecoder(ContainerConfig config) {
    try {
      for (String container : config.getContainers()) {
        String keyFile = config.getString(container, SECURITY_TOKEN_KEY_FILE);
        if (keyFile != null) {
          BlobCrypter crypter = loadCrypterFromFile(new File(keyFile));
          crypters.put(container, crypter);
        }
        String domain = config.getString(container, SIGNED_FETCH_DOMAIN);
        domains.put(container, domain);
      }
View Full Code Here

Examples of org.apache.shindig.common.crypto.BlobCrypter

    String[] fields = StringUtils.split(token, ':');
    if (fields.length != 2) {
      throw new SecurityTokenException("Invalid security token " + token);
    }
    String container = fields[0];
    BlobCrypter crypter = crypters.get(container);
    if (crypter == null) {
      throw new SecurityTokenException("Unknown container " + token);
    }
    String domain = domains.get(container);
    String activeUrl = tokenParameters.get(SecurityTokenDecoder.ACTIVE_URL_NAME);
View Full Code Here

Examples of org.apache.shindig.common.crypto.BlobCrypter

        this.timeSource = new TimeSource();
    }

    protected String createToken(String gadgetURL, String owner, String viewer, Long moduleId, String container) {
        try {
            BlobCrypter blobCrypter = getBlobCrypter();
            BlobCrypterSecurityToken t = new BlobCrypterSecurityToken(blobCrypter, container, null);

            t.setAppUrl(gadgetURL);
            t.setModuleId(moduleId);
            t.setOwnerId(owner);
View Full Code Here

Examples of org.apache.shindig.common.crypto.BlobCrypter

  private void loadContainers(ContainerConfig config, Collection<String> containers,
      Map<String, BlobCrypter> crypters, Map<String, String> domains) throws IOException {
    for (String container : containers) {
      String key = config.getString(container, SECURITY_TOKEN_KEY);
      if (key != null) {
        BlobCrypter crypter = loadCrypter(key);
        crypters.put(container, crypter);
      }
      String domain = config.getString(container, SIGNED_FETCH_DOMAIN);
      domains.put(container, domain);
    }
View Full Code Here

Examples of org.apache.shindig.common.crypto.BlobCrypter

    String[] fields = StringUtils.split(token, ':');
    if (fields.length != 2) {
      throw new SecurityTokenException("Invalid security token " + token);
    }
    String container = fields[0];
    BlobCrypter crypter = crypters.get(container);
    if (crypter == null) {
      throw new SecurityTokenException("Unknown container " + token);
    }
    String domain = domains.get(container);
    String activeUrl = tokenParameters.get(SecurityTokenCodec.ACTIVE_URL_NAME);
    String crypted = fields[1];
    try {
      BlobCrypterSecurityToken st = new BlobCrypterSecurityToken(container, domain, activeUrl,
          crypter.unwrap(crypted));
      return st.enforceNotExpired();
    } catch (BlobCrypterException e) {
      throw new SecurityTokenException(e);
    }
  }
View Full Code Here

Examples of org.apache.shindig.common.crypto.BlobCrypter

    // Test code sends in real AbstractTokens, they have modified time sources in them so
    // that we can test token expiration, production tokens are proxied via the SecurityToken interface.
    AbstractSecurityToken aToken = token instanceof AbstractSecurityToken ?
        (AbstractSecurityToken)token : BlobCrypterSecurityToken.fromToken(token);

    BlobCrypter crypter = crypters.get(aToken.getContainer());
    if (crypter == null) {
      throw new SecurityTokenException("Unknown container " + aToken.getContainer());
    }

    try {
      aToken.setExpires();
      return aToken.getContainer() + ':' + crypter.wrap(aToken.toMap());
    } catch (BlobCrypterException e) {
      throw new SecurityTokenException(e);
    }
  }
View Full Code Here

Examples of org.apache.shindig.common.crypto.BlobCrypter

*/
public class OAuthFetcherConfigTest extends EasyMockTestCase {

  @Test
  public void testOAuthFetcherConfig() {
    BlobCrypter crypter = mock(BlobCrypter.class);
    mock(HttpCache.class);
    GadgetOAuthTokenStore tokenStore = mock(GadgetOAuthTokenStore.class);
    OAuthCallbackGenerator callbackGenerator = mock(OAuthCallbackGenerator.class);
    OAuthFetcherConfig config = new OAuthFetcherConfig(crypter, tokenStore, new TimeSource(),
        callbackGenerator, false);
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.