use of org.openremote.container.web.OAuthFilter in project openremote by openremote.
the class WebsocketIOClient method doConnect.
@Override
protected Future<Boolean> doConnect() {
if (oAuthGrant != null) {
LOG.fine("Retrieving OAuth access token: " + getClientUri());
ResteasyClient client = createClient(executorService, 1, CONNECTION_TIMEOUT_MILLISECONDS, null);
try {
OAuthFilter oAuthFilter = new OAuthFilter(client, oAuthGrant);
authHeaderValue = oAuthFilter.getAuthHeader();
if (TextUtil.isNullOrEmpty(authHeaderValue)) {
throw new RuntimeException("Returned access token is null");
}
LOG.fine("Retrieved access token via OAuth: " + getClientUri());
} catch (SocketException | ProcessingException e) {
LOG.log(Level.SEVERE, "Failed to retrieve OAuth access token for '" + getClientUri() + "': Connection error");
return CompletableFuture.completedFuture(false);
} catch (Exception e) {
LOG.log(Level.SEVERE, "Failed to retrieve OAuth access token: " + getClientUri());
return CompletableFuture.completedFuture(false);
} finally {
if (client != null) {
client.close();
}
}
}
return super.doConnect();
}
Aggregations