com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier Java Examples

The following examples show how to use com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Authenticator.java    From styx with Apache License 2.0 6 votes vote down vote up
Authenticator(GoogleIdTokenVerifier googleIdTokenVerifier,
              CloudResourceManager cloudResourceManager,
              Iam iam,
              AuthenticatorConfiguration configuration,
              WaitStrategy retryWaitStrategy,
              StopStrategy retryStopStrategy) {
  this.googleIdTokenVerifier =
      Objects.requireNonNull(googleIdTokenVerifier, "googleIdTokenVerifier");
  this.cloudResourceManager =
      Objects.requireNonNull(cloudResourceManager, "cloudResourceManager");
  this.iam = Objects.requireNonNull(iam, "iam");
  this.domainWhitelist = configuration.domainWhitelist();
  this.resourceWhitelist = configuration.resourceWhitelist();
  this.allowedAudiences = configuration.allowedAudiences();
  this.retryWaitStrategy = Objects.requireNonNull(retryWaitStrategy, "retryWaitStrategy");
  this.retryStopStrategy = Objects.requireNonNull(retryStopStrategy, "retryStopStrategy");
}
 
Example #2
Source File: SocialLogin.java    From PYX-Reloaded with Apache License 2.0 5 votes vote down vote up
@Contract("null -> null")
@Nullable
private static GoogleIdTokenVerifier instantiateGoogleHelper(String appId) {
    if (appId == null || appId.isEmpty()) return null;
    return new GoogleIdTokenVerifier.Builder(new GoogleApacheHttpTransport(), new JacksonFactory())
            .setAudience(Collections.singletonList(appId))
            .build();
}
 
Example #3
Source File: Authenticator.java    From styx with Apache License 2.0 5 votes vote down vote up
Authenticator(GoogleIdTokenVerifier googleIdTokenVerifier,
              CloudResourceManager cloudResourceManager,
              Iam iam,
              AuthenticatorConfiguration configuration) {
  this(googleIdTokenVerifier, cloudResourceManager, iam, configuration,
      DEFAULT_RETRY_WAIT_STRATEGY,
      DEFAULT_RETRY_STOP_STRATEGY);
}
 
Example #4
Source File: GoogleIdTokenVerifierTest.java    From styx with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  final var keyGen = KeyPairGenerator.getInstance("RSA");
  keyGen.initialize(571);
  KeyPair pair = keyGen.generateKeyPair();
  privateKey = pair.getPrivate();

  final var keysManager = new GooglePublicKeysManager(Utils.getDefaultTransport(), Utils.getDefaultJsonFactory());
  stubPublicKey(keysManager, pair.getPublic());

  verifier = new GoogleIdTokenVerifier(keysManager);
}
 
Example #5
Source File: AuthenticatorFactoryTest.java    From styx with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldBuildGoogleIdTokenVerifier() {
  final GoogleIdTokenVerifier googleIdTokenVerifier = new DefaultAuthenticatorFactory()
      .buildGoogleIdTokenVerifier(httpTransport, jsonFactory);
  assertThat(googleIdTokenVerifier.getTransport(), is(httpTransport));
  assertThat(googleIdTokenVerifier.getJsonFactory(), is(jsonFactory));
}
 
Example #6
Source File: EndpointsPeerAuthenticator.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
public EndpointsPeerAuthenticator() {
  Client client = Client.getInstance();
  GooglePublicKeysManager keyManager = new GooglePublicKeysManager.Builder(
      client.getHttpTransport(), client.getJsonFactory()).setPublicCertsEncodedUrl(
      PUBLIC_CERT_URL).build();
  GoogleIdTokenVerifier verifier =
      new GoogleIdTokenVerifier.Builder(keyManager).setIssuer(ISSUER).build();
  jwtAuthenticator = new GoogleJwtAuthenticator(verifier);
}
 
Example #7
Source File: Checker.java    From gplus-verifytoken-java with Apache License 2.0 5 votes vote down vote up
public Checker(String[] clientIDs, String audience) {
    mClientIDs = Arrays.asList(clientIDs);
    mAudience = audience;
    NetHttpTransport transport = new NetHttpTransport();
    mJFactory = new GsonFactory();
    mVerifier = new GoogleIdTokenVerifier(transport, mJFactory);
}
 
Example #8
Source File: Checker.java    From gplus-verifytoken-java with Apache License 2.0 5 votes vote down vote up
public Checker(String[] clientIDs, String audience) {
    mClientIDs = Arrays.asList(clientIDs);
    mAudience = audience;
    NetHttpTransport transport = new NetHttpTransport();
    mJFactory = new GsonFactory();
    mVerifier = new GoogleIdTokenVerifier(transport, mJFactory);
}
 
Example #9
Source File: GoogleSecurityServiceSupplier.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
private GoogleIdToken verifyToken(String token) throws GeneralSecurityException, IOException {
	GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(new NetHttpTransport(), JacksonFactory.getDefaultInstance())
			.setAudience(Collections.singletonList(GoogleSignInConfig.getClientId())).build();
	GoogleIdToken idToken = verifier.verify(token);
	return idToken;
}
 
Example #10
Source File: AuthenticatorFactory.java    From styx with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
GoogleIdTokenVerifier buildGoogleIdTokenVerifier(HttpTransport httpTransport, JsonFactory jsonFactory) {
  return new GoogleIdTokenVerifier(httpTransport, jsonFactory);
}
 
Example #11
Source File: AuthenticatorFactoryTest.java    From styx with Apache License 2.0 4 votes vote down vote up
@Override
GoogleIdTokenVerifier buildGoogleIdTokenVerifier(HttpTransport httpTransport,
                                                 JsonFactory jsonFactory) {
  return googleIdTokenVerifier;
}
 
Example #12
Source File: GoogleJwtAuthenticator.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
public GoogleJwtAuthenticator() {
  this(new GoogleIdTokenVerifier.Builder(Client.getInstance().getHttpTransport(),
      Client.getInstance().getJsonFactory()).build());
}
 
Example #13
Source File: GoogleJwtAuthenticator.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
public GoogleJwtAuthenticator(GoogleIdTokenVerifier verifier) {
  this.verifier = verifier;
}