Package com.google.api.client.json.jackson2

Examples of com.google.api.client.json.jackson2.JacksonFactory


  public void testExecuteRefreshToken() throws Exception {

    HttpTransport transport = new MockMetadataServerTransport(ACCESS_TOKEN);

    ComputeCredential credential = new ComputeCredential(transport, new JacksonFactory());

    assertTrue(credential.refreshToken());
    assertEquals(ACCESS_TOKEN, credential.getAccessToken());
  }
View Full Code Here


  private static final String CLIENT_ID = "812741506391.apps.googleusercontent.com";
  private static final String CLIENT_SECRET = "{client_secret}";

  public void testBuilder() {
    GoogleAuthorizationCodeFlow.Builder builder = new GoogleAuthorizationCodeFlow.Builder(
        new MockHttpTransport(), new JacksonFactory(), CLIENT_ID, CLIENT_SECRET,
        ImmutableList.of("https://www.googleapis.com/auth/userinfo.email"));
    assertNull(builder.getApprovalPrompt());
    assertNull(builder.getAccessType());
  }
View Full Code Here

    MockGoogleClientRequest<String> jsonHttpRequest2 =
        new MockGoogleClientRequest<String>(client, METHOD2, URI_TEMPLATE2, null, String.class);
    credential = new MockCredential();

    ObjectParser parser =
        testBinary ? new ProtoObjectParser() : new JsonObjectParser(new JacksonFactory());
    BatchRequest batchRequest =
        new BatchRequest(transport, credential).setBatchUrl(new GenericUrl(TEST_BATCH_URL));
    HttpRequest request1 = jsonHttpRequest1.buildHttpRequest();
    request1.setParser(parser);
    HttpRequest request2 = jsonHttpRequest2.buildHttpRequest();
View Full Code Here

        .build();
    MockGoogleClientRequest<String> jsonHttpRequest1 =
        new MockGoogleClientRequest<String>(client, METHOD1, URI_TEMPLATE1, null, String.class);
    MockGoogleClientRequest<String> jsonHttpRequest2 =
        new MockGoogleClientRequest<String>(client, METHOD2, URI_TEMPLATE2, null, String.class);
    ObjectParser parser = new JsonObjectParser(new JacksonFactory());
    BatchRequest batchRequest =
        new BatchRequest(transport, null).setBatchUrl(new GenericUrl(TEST_BATCH_URL));
    HttpRequest request1 = jsonHttpRequest1.buildHttpRequest();
    request1.setParser(parser);
    HttpRequest request2 = jsonHttpRequest2.buildHttpRequest();
View Full Code Here

    return payload;
  }

  public void testBuilder() throws Exception {
    GoogleIdTokenVerifier.Builder builder = new GoogleIdTokenVerifier.Builder(
        new GooglePublicKeysManagerTest.PublicCertsMockHttpTransport(), new JacksonFactory()).setIssuer(
        ISSUER).setAudience(TRUSTED_CLIENT_IDS);
    assertEquals(Clock.SYSTEM, builder.getClock());
    assertEquals(ISSUER, builder.getIssuer());
    assertTrue(TRUSTED_CLIENT_IDS.equals(builder.getAudience()));
    Clock clock = new FixedClock(4);
View Full Code Here

    assertEquals(TRUSTED_CLIENT_IDS, Lists.newArrayList(verifier.getAudience()));
  }

  public void testVerify() throws Exception {
    GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(
        new GooglePublicKeysManagerTest.PublicCertsMockHttpTransport(), new JacksonFactory()).build();
    Header header = new Header();
    header.setAlgorithm("RS25");
    Payload payload = newPayload(CLIENT_ID);
    Payload payload2 = newPayload(CLIENT_ID + "2");
    GoogleIdToken idToken = new GoogleIdToken(header, payload, new byte[0], new byte[0]);
    GoogleIdToken idToken2 = new GoogleIdToken(header, payload2, new byte[0], new byte[0]);
    assertFalse(verifier.verify(idToken));
    assertFalse(verifier.verify(idToken2));
    verifier = new GoogleIdTokenVerifier(
        new GooglePublicKeysManagerTest.PublicCertsMockHttpTransport(), new JacksonFactory());
    assertFalse(verifier.verify(idToken));
    assertFalse(verifier.verify(idToken2));
    // TODO(yanivi): add a unit test that returns true
  }
View Full Code Here

  private static final String REDIRECT_URI = "https://oauth2-login-demo.appspot.com/code";

  public void test() {
    GoogleAuthorizationCodeTokenRequest request =
        new GoogleAuthorizationCodeTokenRequest(new MockHttpTransport(),
            new JacksonFactory(),
            CLIENT_ID,
            CLIENT_SECRET,
            CODE,
            REDIRECT_URI);
    ClientParametersAuthentication clientAuthentication =
View Full Code Here

  private static final int AGE = 42;

  public void testBuilder() throws Exception {
    HttpTransport transport = new MockHttpTransport();
    JsonFactory jsonFactory = new JacksonFactory();
    GooglePublicKeysManager.Builder builder = new GooglePublicKeysManager.Builder(transport, jsonFactory);

    GooglePublicKeysManager certs = builder.build();
    assertEquals(transport, certs.getTransport());
    assertEquals(jsonFactory, certs.getJsonFactory());
View Full Code Here

    }
  }

  public void testRefresh() throws Exception {
    GooglePublicKeysManager certs = new GooglePublicKeysManager.Builder(
        new PublicCertsMockHttpTransport(), new JacksonFactory()).build();
    certs.refresh();
    assertEquals(2, certs.getPublicKeys().size());
  }
View Full Code Here

  public void testLoadCerts_cache() throws Exception {
    PublicCertsMockHttpTransport transport = new PublicCertsMockHttpTransport();
    transport.useAgeHeader = true;
    GooglePublicKeysManager certs = new GooglePublicKeysManager.Builder(
        transport, new JacksonFactory()).setClock(new FixedClock(100)).build();

    certs.refresh();
    assertEquals(2, certs.getPublicKeys().size());
    assertEquals(100 + (MAX_AGE - AGE) * 1000, certs.getExpirationTimeMilliseconds());
  }
View Full Code Here

TOP

Related Classes of com.google.api.client.json.jackson2.JacksonFactory

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.