/** * Set the {@link SessionConfiguration} information */ public Builder setSessionConfiguration(SessionConfiguration configuration) { if (scopes != null) { this.scopes = new HashSet<>(configuration.getScopes()); } if (customScopes != null) { this.customScopes = new HashSet<>(configuration.getCustomScopes()); } this.clientId = configuration.getClientId(); this.clientSecret = configuration.getClientSecret(); this.redirectUri = configuration.getRedirectUri(); this.loginHost = configuration.getLoginHost(); return this; }
@Test public void getScopes_whenSetOnBuilder_setsOnConfiguration() throws Exception { List<Scope> scopes = Arrays.asList(Scope.ALL_TRIPS, Scope.HISTORY); SessionConfiguration config = new SessionConfiguration.Builder() .setClientId("clientId") .setScopes(scopes) .build(); assertTrue(scopes.containsAll(config.getScopes())); }
/** * Creates an {@link OAuth2Credentials} object that can be used by any of the servlets. * * Throws an {@throws IOException} when no client ID or secret found in secrets.properties */ static OAuth2Credentials createOAuth2Credentials(SessionConfiguration config) throws IOException { return new OAuth2Credentials.Builder() .setCredentialDataStoreFactory(MemoryDataStoreFactory.getDefaultInstance()) .setRedirectUri(config.getRedirectUri()) .setScopes(config.getScopes()) .setClientSecrets(config.getClientId(), config.getClientSecret()) .build(); }