|
|
@ -267,18 +267,25 @@ public class MQTTAdapterListener implements MqttCallback, Runnable {
|
|
|
|
|
|
|
|
|
|
|
|
private String getToken(String clientId, String clientSecret)
|
|
|
|
private String getToken(String clientId, String clientSecret)
|
|
|
|
throws UserStoreException, JWTClientException {
|
|
|
|
throws UserStoreException, JWTClientException {
|
|
|
|
String scopes = mqttBrokerConnectionConfiguration.getBrokerScopes();
|
|
|
|
PrivilegedCarbonContext.startTenantFlow();
|
|
|
|
String username = mqttBrokerConnectionConfiguration.getUsername();
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true);
|
|
|
|
if (mqttBrokerConnectionConfiguration.isGlobalCredentailSet()) {
|
|
|
|
try {
|
|
|
|
username = PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
|
|
|
String scopes = mqttBrokerConnectionConfiguration.getBrokerScopes();
|
|
|
|
.getUserRealm().getRealmConfiguration().getAdminUserName() + "@" + PrivilegedCarbonContext
|
|
|
|
String username = mqttBrokerConnectionConfiguration.getUsername();
|
|
|
|
.getThreadLocalCarbonContext().getTenantDomain(true);
|
|
|
|
if (mqttBrokerConnectionConfiguration.isGlobalCredentailSet()) {
|
|
|
|
}
|
|
|
|
username = PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
|
|
|
|
|
|
|
.getUserRealm().getRealmConfiguration().getAdminUserName() + "@" + PrivilegedCarbonContext
|
|
|
|
|
|
|
|
.getThreadLocalCarbonContext().getTenantDomain(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JWTClientManagerService jwtClientManagerService = InputAdapterServiceDataHolder.getJwtClientManagerService();
|
|
|
|
JWTClientManagerService jwtClientManagerService =
|
|
|
|
AccessTokenInfo accessTokenInfo = jwtClientManagerService.getJWTClient().getAccessToken(
|
|
|
|
InputAdapterServiceDataHolder.getJwtClientManagerService();
|
|
|
|
clientId, clientSecret, username, scopes);
|
|
|
|
AccessTokenInfo accessTokenInfo = jwtClientManagerService.getJWTClient().getAccessToken(
|
|
|
|
return accessTokenInfo.getAccessToken();
|
|
|
|
clientId, clientSecret, username, scopes);
|
|
|
|
|
|
|
|
return accessTokenInfo.getAccessToken();
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
PrivilegedCarbonContext.endTenantFlow();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String getBase64Encode(String key, String value) {
|
|
|
|
private String getBase64Encode(String key, String value) {
|
|
|
|