use of org.openhab.core.auth.client.oauth2.OAuthClientService in project openhab-addons by openhab.
the class MieleBridgeHandlerTest method getOAuthClientServiceMock.
private OAuthClientService getOAuthClientServiceMock() {
OAuthClientService oauthClientServiceMock = this.oauthClientServiceMock;
assertNotNull(oauthClientServiceMock);
return Objects.requireNonNull(oauthClientServiceMock);
}
use of org.openhab.core.auth.client.oauth2.OAuthClientService in project openhab-core by openhab.
the class OAuthFactoryImpl method getOAuthClientService.
@Override
@Nullable
public OAuthClientService getOAuthClientService(String handle) {
OAuthClientService clientImpl = oauthClientServiceCache.get(handle);
if (clientImpl == null || clientImpl.isClosed()) {
// This happens after reboot, or client was closed without factory knowing; create a new client
// the store has the handle/config data
clientImpl = OAuthClientServiceImpl.getInstance(handle, oAuthStoreHandler, tokenExpiresInBuffer, httpClientFactory);
if (clientImpl == null) {
return null;
}
oauthClientServiceCache.put(handle, clientImpl);
}
return clientImpl;
}
use of org.openhab.core.auth.client.oauth2.OAuthClientService in project openhab-core by openhab.
the class OAuthFactoryImpl method ungetOAuthService.
@SuppressWarnings("null")
@Override
public void ungetOAuthService(String handle) {
OAuthClientService clientImpl = oauthClientServiceCache.get(handle);
if (clientImpl == null) {
logger.debug("{} handle not found. Cannot unregisterOAuthServie", handle);
return;
}
clientImpl.close();
oauthClientServiceCache.remove(handle);
}
use of org.openhab.core.auth.client.oauth2.OAuthClientService in project openhab-core by openhab.
the class AbstractTestAgent method testGetAccessTokenByResourceOwnerPasswordCredentials.
@Override
public AccessTokenResponse testGetAccessTokenByResourceOwnerPasswordCredentials() throws OAuthException, IOException, OAuthResponseException {
logger.debug("test getOAuthTokenByResourceOwnerPasswordCredentials");
if (handle == null) {
logger.debug("Creating new oauth service");
oauthClientService = testCreateClient();
} else {
logger.debug("getting oauth client by handle: {}", handle);
oauthClientService = oauthFactory.getOAuthClientService(handle);
}
AccessTokenResponse accessTokenResponse = oauthClientService.getAccessTokenByResourceOwnerPasswordCredentials(username, password, scope);
logger.debug("Token: {}", accessTokenResponse);
return accessTokenResponse;
}
use of org.openhab.core.auth.client.oauth2.OAuthClientService in project smarthome by eclipse.
the class OAuthFactoryImpl method getOAuthClientService.
@Override
@Nullable
public OAuthClientService getOAuthClientService(String handle) {
OAuthClientService clientImpl = oauthClientServiceCache.get(handle);
if (clientImpl == null || clientImpl.isClosed()) {
// This happens after reboot, or client was closed without factory knowing; create a new client
// the store has the handle/config data
clientImpl = OAuthClientServiceImpl.getInstance(handle, oAuthStoreHandler, tokenExpiresInBuffer, httpClientFactory);
if (clientImpl == null) {
return null;
}
oauthClientServiceCache.put(handle, clientImpl);
}
return clientImpl;
}
Aggregations