當前位置: 首頁>>代碼示例>>Java>>正文


Java BlobCrypter類代碼示例

本文整理匯總了Java中org.apache.shindig.common.crypto.BlobCrypter的典型用法代碼示例。如果您正苦於以下問題:Java BlobCrypter類的具體用法?Java BlobCrypter怎麽用?Java BlobCrypter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BlobCrypter類屬於org.apache.shindig.common.crypto包,在下文中一共展示了BlobCrypter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testServletWithCallback

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
@Test
public void testServletWithCallback() throws Exception {
    ContextResource contextResource = resource.getContextResource();
    BlobCrypter crypter = new BasicBlobCrypter("00000000000000000000".getBytes());
    OAuthCallbackState state = new OAuthCallbackState(crypter);
    resource.setStateCrypter(crypter);
    state.setRealCallbackUrl("http://www.example.com/callback");
    contextResource.getParameters().set("cs", state.getEncryptedState());
    contextResource.getRequest().setResourceRef("http://foo.com?cs=foo&bar=baz");
    replay();
    resource.doGet();
    verify();

    assertEquals(Status.REDIRECTION_FOUND, contextResource.getStatus());
    assertEquals(new Reference("http://www.example.com/callback?bar=baz"), contextResource.getResponse().getLocationRef());

    List<CacheDirective> cacheDirectives = contextResource.getResponse().getCacheDirectives();
    assertEquals(2, cacheDirectives.size());
    assertEquals("private", cacheDirectives.get(0).getName());
    assertEquals("max-age", cacheDirectives.get(1).getName());
    assertEquals("3600", cacheDirectives.get(1).getValue());

}
 
開發者ID:devacfr,項目名稱:spring-restlet,代碼行數:24,代碼來源:OAuthCallbackResourceTest.java

示例2: testServletWithCallback_noQueryParams

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
@Test
public void testServletWithCallback_noQueryParams() throws Exception {
    ContextResource contextResource = resource.getContextResource();
    BlobCrypter crypter = new BasicBlobCrypter("00000000000000000000".getBytes());
    OAuthCallbackState state = new OAuthCallbackState(crypter);
    resource.setStateCrypter(crypter);
    state.setRealCallbackUrl("http://www.example.com/callback");
    contextResource.getParameters().set("cs", state.getEncryptedState());
    contextResource.getRequest().setResourceRef("http://foo.com?cs=foo");
    replay();
    resource.doGet();
    verify();

    assertEquals(Status.REDIRECTION_FOUND, contextResource.getStatus());
    assertEquals(new Reference("http://www.example.com/callback"), contextResource.getResponse().getLocationRef());

    List<CacheDirective> cacheDirectives = contextResource.getResponse().getCacheDirectives();
    assertEquals(2, cacheDirectives.size());
    assertEquals("private", cacheDirectives.get(0).getName());
    assertEquals("max-age", cacheDirectives.get(1).getName());
    assertEquals("3600", cacheDirectives.get(1).getValue());
}
 
開發者ID:devacfr,項目名稱:spring-restlet,代碼行數:23,代碼來源:OAuthCallbackResourceTest.java

示例3: OAuthClientState

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
/**
 * Initialize client state based on an encrypted blob passed by the
 * client.
 *
 * @param crypter
 * @param stateBlob
 */
public OAuthClientState(BlobCrypter crypter, String stateBlob) {
  this.crypter = crypter;
  Map<String, String> state = null;
  if (stateBlob != null) {
    try {
      state = crypter.unwrap(stateBlob, CLIENT_STATE_MAX_AGE_SECS);
    } catch (BlobCrypterException e) {
      // Probably too old, pretend we never saw it at all.
    }
  }
  if (state == null) {
    state = Maps.newHashMap();
  }
  this.state = state; 
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:23,代碼來源:OAuthClientState.java

示例4: testServletWithCallback

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
@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());
  expect(request.getQueryString()).andReturn("cs=foo&bar=baz");
  replay();
  servlet.doGet(this.request, this.recorder);
  verify();
  assertEquals(302, this.recorder.getHttpStatusCode());
  assertEquals("http://www.example.com/callback?bar=baz", this.recorder.getHeader("Location"));
  String cacheControl = this.recorder.getHeader("Cache-Control");
  assertEquals("private,max-age=3600", cacheControl);
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:18,代碼來源:OAuthCallbackServletTest.java

示例5: testServletWithCallback_noQueryParams

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
@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());
  expect(request.getQueryString()).andReturn("cs=foo");
  replay();
  servlet.doGet(this.request, this.recorder);
  verify();
  assertEquals(302, this.recorder.getHttpStatusCode());
  assertEquals("http://www.example.com/callback", this.recorder.getHeader("Location"));
  String cacheControl = this.recorder.getHeader("Cache-Control");
  assertEquals("private,max-age=3600", cacheControl);
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:18,代碼來源:OAuthCallbackServletTest.java

示例6: BlobCrypterSecurityTokenDecoder

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
@Inject
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);
    }
  } catch (IOException e) {
    // Someone specified securityTokenKeyFile, but we couldn't load the key.  That merits killing
    // the server.
    throw new RuntimeException(e);
  }
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:19,代碼來源:BlobCrypterSecurityTokenDecoder.java

示例7: createToken

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
/**
 * Decrypt and verify the provided security token.
 */
public SecurityToken createToken(Map<String, String> tokenParameters)
    throws SecurityTokenException {
  String token = tokenParameters.get(SecurityTokenDecoder.SECURITY_TOKEN_NAME);
  if (token == null || token.trim().length() == 0) {
    // No token is present, assume anonymous access
    return new AnonymousSecurityToken();
  }
  String[] fields = token.split(":");
  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);
  String crypted = fields[1];
  try {
    return BlobCrypterSecurityToken.decrypt(crypter, container, domain, crypted, activeUrl);
  } catch (BlobCrypterException e) {
    throw new SecurityTokenException(e);
  }
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:29,代碼來源:BlobCrypterSecurityTokenDecoder.java

示例8: configure

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void configure() {
    bind(BlobCrypter.class).annotatedWith(Names.named(OAuthFetcherConfig.OAUTH_STATE_CRYPTER))
            .toProvider(OAuthModule.OAuthCrypterProvider.class);
    bind(OAuthRequest.class).toProvider(OAuthModule.OAuthRequestProvider.class);

    //Required for SampleOAuthDataStore
    bind(String.class).annotatedWith(Names.named("shindig.canonical.json.db"))
        .toInstance("sampledata/canonicaldb.json");
    bind(OAuthDataStore.class).to(SampleOAuthDataStore.class);
}
 
開發者ID:apache,項目名稱:rave,代碼行數:15,代碼來源:OAuthGuiceModule.java

示例9: OAuthFetcherConfig

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
@Inject
public OAuthFetcherConfig(
    @Named(OAUTH_STATE_CRYPTER) BlobCrypter stateCrypter,
    GadgetOAuthTokenStore tokenStore,
    TimeSource clock,
    OAuthCallbackGenerator oauthCallbackGenerator,
    @Named("shindig.signing.viewer-access-tokens-enabled") boolean viewerAccessTokensEnabled) {
  this.stateCrypter = stateCrypter;
  this.tokenStore = tokenStore;
  this.clock = clock;
  this.oauthCallbackGenerator = oauthCallbackGenerator;
  this.viewerAccessTokensEnabled = viewerAccessTokensEnabled;
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:14,代碼來源:OAuthFetcherConfig.java

示例10: GadgetOAuthCallbackGenerator

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
@Inject
public GadgetOAuthCallbackGenerator(@Named("shindig.signing.enable-signed-callbacks")
    boolean enableSignedCallbacks, Processor processor, LockedDomainService lockedDomainService,
    UrlGenerator urlGenerator, @Named(OAuthFetcherConfig.OAUTH_STATE_CRYPTER)
    BlobCrypter stateCrypter) {
  this.enableSignedCallbacks = enableSignedCallbacks;
  this.processor = processor;
  this.lockedDomainService = lockedDomainService;
  this.urlGenerator = urlGenerator;
  this.stateCrypter = stateCrypter;
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:12,代碼來源:GadgetOAuthCallbackGenerator.java

示例11: OAuthResponseParams

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
/**
 * Create response parameters.
 */
public OAuthResponseParams(SecurityToken securityToken, HttpRequest originalRequest,
    BlobCrypter stateCrypter) {
  this.securityToken = securityToken;
  this.originalRequest = originalRequest;
  newClientState = new OAuthClientState(stateCrypter);
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:10,代碼來源:OAuthResponseParams.java

示例12: configure

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
@Override
protected void configure() {
  // Used for encrypting client-side OAuth state.
  bind(BlobCrypter.class).annotatedWith(Names.named(OAuthFetcherConfig.OAUTH_STATE_CRYPTER))
      .toProvider(OAuthCrypterProvider.class);

  // Used for persistent storage of OAuth access tokens.
  bind(OAuthStore.class).toProvider(OAuthStoreProvider.class);
  bind(OAuthRequest.class).toProvider(OAuthRequestProvider.class);
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:11,代碼來源:OAuthModule.java

示例13: OAuthCallbackState

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
public OAuthCallbackState(BlobCrypter crypter, String stateBlob) {
  this.crypter = crypter;
  Map<String, String> state = Maps.newHashMap();
  if (stateBlob != null) {
    try {
      state = crypter.unwrap(stateBlob, CALLBACK_STATE_MAX_AGE_SECS);
    } catch (BlobCrypterException e) {
      // Too old, or corrupt.  Ignore it.
    }
  }
  if (state == null) {
    state = Maps.newHashMap();
  }
  this.state = state;
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:16,代碼來源:OAuthCallbackState.java

示例14: testOAuthFetcherConfig

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
@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);
  assertEquals(crypter, config.getStateCrypter());
  assertEquals(tokenStore, config.getTokenStore());
  assertEquals(callbackGenerator, config.getOAuthCallbackGenerator());
  assertFalse(config.isViewerAccessTokensEnabled());
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:14,代碼來源:OAuthFetcherConfigTest.java

示例15: loadCrypterFromFile

import org.apache.shindig.common.crypto.BlobCrypter; //導入依賴的package包/類
/**
 * @return a crypter based on the name of the file passed in, rather than the contents
 */
@Override
protected BlobCrypter loadCrypterFromFile(File file) throws IOException {
  if (file.getPath().contains("fail")) {
    throw new IOException("Load failed: " + file);
  }
  return getBlobCrypter(file.getPath());
}
 
開發者ID:inevo,項目名稱:shindig-1.1-BETA5-incubating,代碼行數:11,代碼來源:BlobCrypterSecurityTokenDecoderTest.java


注:本文中的org.apache.shindig.common.crypto.BlobCrypter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。