/** * @param builder builder * * @since 1.14 */ protected AppIdentityCredential(Builder builder) { // Lazily retrieved rather than setting as the default value in order to not add runtime // dependencies on AppIdentityServiceFactory unless it is actually being used. appIdentityService = builder.appIdentityService == null ? AppIdentityServiceFactory.getAppIdentityService() : builder.appIdentityService; scopes = builder.scopes; }
public AppIdentityAccessTokenProvider() { this.appIdentityService = AppIdentityServiceFactory.getAppIdentityService(); }
@Provides @Singleton AppIdentityService provideAppIdentityService() { return AppIdentityServiceFactory.getAppIdentityService(); }
/** * Create a new AppEngineCredential. * * @param scopes Collection of scopes to request. * @param appIdentityService Custom service used for signing. * * @deprecated Use {@link #newBuilder()} instead. This constructor will either be deleted or made * private in a later version. */ @Deprecated public AppEngineCredentials(Collection<String> scopes, AppIdentityService appIdentityService) { this.scopes = scopes == null ? ImmutableSet.<String>of() : ImmutableList.copyOf(scopes); this.appIdentityService = appIdentityService != null ? appIdentityService : AppIdentityServiceFactory.getAppIdentityService(); this.appIdentityServiceClassName = this.appIdentityService.getClass().getName(); scopesRequired = this.scopes.isEmpty(); }
@Before public void setUp() { appIdentity = AppIdentityServiceFactory.getAppIdentityService(); }
/** * Static function to create a signable JSON token initialized with the proper parameters for * performing an assertion token request. * * @param scope Scope for which we are requesting access. * @param audience Audience field in the json web token. * @return Signable JSON web token (JWT). */ public static JsonToken createJsonTokenForScopes(String scope, String audience) { AppIdentityService identityService = AppIdentityServiceFactory.getAppIdentityService(); AppEngineSigner signer = new AppEngineSigner("", identityService); SignedJsonAssertionToken jwt = new SignedJsonAssertionToken(signer); jwt.setAudience(audience); jwt.setScope(scope); jwt.setNonce(Long.toString(GENERATOR.nextLong())); Instant now = new Instant(); jwt.setIssuedAt(now); jwt.setExpiration(now.plus(Duration.standardHours(1))); LOGGER.fine("JWT: " + jwt.toString()); return jwt; } }