/** * Return the user ID of the user that is logged in. * * @throws IllegalStateException Thrown when no user is logged in. */ @Override protected String getUserId() { return AppEngineServletUtils.getUserId(); }
@Override protected boolean executeRefreshToken() throws IOException { JsonToken jwt = SignedTokenGenerator.createJsonTokenForScopes(scope, audience); String assertion; try { assertion = jwt.serializeAndSign(); } catch (SignatureException exception) { IOException rewrite = new IOException("Unable to sign JSON Web Token"); rewrite.initCause(exception); throw rewrite; } AssertionGrant tokenRequest = new AssertionGrant( transport, jsonFactory, authorizationServerUrl, ASSERTION_TYPE, assertion); return executeAccessTokenRequest(tokenRequest); } }
public byte[] sign(byte[] source) throws SignatureException { SigningResult key = identityService.signForApp(source); this.setSigningKeyId(key.getKeyName()); return key.getSignature(); } }
@Override protected boolean executeRefreshToken() throws IOException { JsonToken jwt = SignedTokenGenerator.createJsonTokenForScopes(scope, audience); String assertion; try { assertion = jwt.serializeAndSign(); } catch (SignatureException exception) { IOException rewrite = new IOException("Unable to sign JSON Web Token"); rewrite.initCause(exception); throw rewrite; } AssertionGrant tokenRequest = new AssertionGrant( transport, jsonFactory, authorizationServerUrl, ASSERTION_TYPE, assertion); return executeAccessTokenRequest(tokenRequest); } }
/** * 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; } }
/** * Return the user ID of the user that is logged in. * * @throws IllegalStateException Thrown when no user is logged in. */ @Override protected String getUserId() { return AppEngineServletUtils.getUserId(); }
/** * Return the user ID of the user that is logged in. * * @throws IllegalStateException Thrown when no user is logged in. */ @Override protected String getUserId() { return AppEngineServletUtils.getUserId(); }
/** * Return the user ID of the user that is logged in. * * @throws IllegalStateException Thrown when no user is logged in. */ @Override protected String getUserId() { return AppEngineServletUtils.getUserId(); }
/** * Return the user ID of the user that is logged in. * * @throws IllegalStateException Thrown when no user is logged in. */ @Override protected String getUserId() { return AppEngineServletUtils.getUserId(); }