Search in sources :

Example 1 with MissingEnvironmentVariableException

use of io.cryostat.net.MissingEnvironmentVariableException in project cryostat by cryostatio.

the class OpenShiftAuthManager method computeAuthorizationEndpoint.

private CompletableFuture<String> computeAuthorizationEndpoint() {
    return oauthUrls.computeIfAbsent(AUTHORIZATION_URL_KEY, key -> {
        try {
            String oauthClient = this.getServiceAccountName();
            String tokenScope = this.getTokenScope();
            CompletableFuture<OAuthMetadata> oauthMetadata = this.computeOauthMetadata();
            String authorizeEndpoint = oauthMetadata.get().getAuthorizationEndpoint();
            URIBuilder builder = new URIBuilder(authorizeEndpoint);
            builder.addParameter("client_id", oauthClient);
            builder.addParameter("response_type", "token");
            builder.addParameter("response_mode", "fragment");
            builder.addParameter("scope", tokenScope);
            return CompletableFuture.completedFuture(builder.build().toString());
        } catch (ExecutionException | InterruptedException | URISyntaxException | MissingEnvironmentVariableException e) {
            return CompletableFuture.failedFuture(e);
        }
    });
}
Also used : MissingEnvironmentVariableException(io.cryostat.net.MissingEnvironmentVariableException) URISyntaxException(java.net.URISyntaxException) ExecutionException(java.util.concurrent.ExecutionException) URIBuilder(org.apache.http.client.utils.URIBuilder)

Aggregations

MissingEnvironmentVariableException (io.cryostat.net.MissingEnvironmentVariableException)1 URISyntaxException (java.net.URISyntaxException)1 ExecutionException (java.util.concurrent.ExecutionException)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1