Search in sources :

Example 1 with Header

use of com.google.api.client.json.webtoken.JsonWebSignature.Header in project google-api-java-client by google.

the class GoogleIdTokenVerifierTest method testVerify.

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
}
Also used : Header(com.google.api.client.json.webtoken.JsonWebSignature.Header) Payload(com.google.api.client.googleapis.auth.oauth2.GoogleIdToken.Payload) JacksonFactory(com.google.api.client.json.jackson2.JacksonFactory)

Aggregations

Payload (com.google.api.client.googleapis.auth.oauth2.GoogleIdToken.Payload)1 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)1 Header (com.google.api.client.json.webtoken.JsonWebSignature.Header)1