mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
fixed multi tenant issues after testing
This commit is contained in:
parent
2cfc4540f4
commit
e0f6e9579d
@ -32,6 +32,10 @@
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-codec.wso2</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.analytics-common</groupId>
|
||||
<artifactId>org.wso2.carbon.event.input.adapter.core</artifactId>
|
||||
|
||||
@ -42,7 +42,6 @@ public class MQTTEventAdapter implements InputEventAdapter {
|
||||
private MQTTAdapterListener mqttAdapterListener;
|
||||
private MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration;
|
||||
|
||||
|
||||
public MQTTEventAdapter(InputEventAdapterConfiguration eventAdapterConfiguration,
|
||||
Map<String, String> globalProperties) {
|
||||
this.eventAdapterConfiguration = eventAdapterConfiguration;
|
||||
|
||||
@ -267,18 +267,25 @@ public class MQTTAdapterListener implements MqttCallback, Runnable {
|
||||
|
||||
private String getToken(String clientId, String clientSecret)
|
||||
throws UserStoreException, JWTClientException {
|
||||
String scopes = mqttBrokerConnectionConfiguration.getBrokerScopes();
|
||||
String username = mqttBrokerConnectionConfiguration.getUsername();
|
||||
if (mqttBrokerConnectionConfiguration.isGlobalCredentailSet()) {
|
||||
username = PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
||||
.getUserRealm().getRealmConfiguration().getAdminUserName() + "@" + PrivilegedCarbonContext
|
||||
.getThreadLocalCarbonContext().getTenantDomain(true);
|
||||
}
|
||||
PrivilegedCarbonContext.startTenantFlow();
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true);
|
||||
try {
|
||||
String scopes = mqttBrokerConnectionConfiguration.getBrokerScopes();
|
||||
String username = mqttBrokerConnectionConfiguration.getUsername();
|
||||
if (mqttBrokerConnectionConfiguration.isGlobalCredentailSet()) {
|
||||
username = PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
||||
.getUserRealm().getRealmConfiguration().getAdminUserName() + "@" + PrivilegedCarbonContext
|
||||
.getThreadLocalCarbonContext().getTenantDomain(true);
|
||||
}
|
||||
|
||||
JWTClientManagerService jwtClientManagerService = InputAdapterServiceDataHolder.getJwtClientManagerService();
|
||||
AccessTokenInfo accessTokenInfo = jwtClientManagerService.getJWTClient().getAccessToken(
|
||||
clientId, clientSecret, username, scopes);
|
||||
return accessTokenInfo.getAccessToken();
|
||||
JWTClientManagerService jwtClientManagerService =
|
||||
InputAdapterServiceDataHolder.getJwtClientManagerService();
|
||||
AccessTokenInfo accessTokenInfo = jwtClientManagerService.getJWTClient().getAccessToken(
|
||||
clientId, clientSecret, username, scopes);
|
||||
return accessTokenInfo.getAccessToken();
|
||||
} finally {
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
}
|
||||
}
|
||||
|
||||
private String getBase64Encode(String key, String value) {
|
||||
|
||||
@ -53,7 +53,7 @@ public class MQTTEventAdapterConstants {
|
||||
|
||||
public static final String EMPTY_STRING = "";
|
||||
public static final String GRANT_TYPE_PARAM_NAME = "grant_type";
|
||||
public static final String GRANT_TYPE = "password refresh_token";
|
||||
public static final String GRANT_TYPE = "password refresh_token urn:ietf:params:oauth:grant-type:jwt-bearer";
|
||||
public static final String TOKEN_SCOPE = "production";
|
||||
public static final String APPLICATION_NAME_PREFIX = "InputAdapter_";
|
||||
public static final String CLIENT_ID = "clientId";
|
||||
|
||||
@ -67,7 +67,7 @@ public class RegistrationProfile {
|
||||
String jsonString =
|
||||
"{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + "\", \"tokenScope\": " +
|
||||
"\"" + tokenScope + "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType +
|
||||
"\", \"saasApp\" :false }\n";
|
||||
"\", \"saasApp\" :true }\n";
|
||||
return jsonString;
|
||||
}
|
||||
}
|
||||
7
pom.xml
7
pom.xml
@ -793,6 +793,11 @@
|
||||
<!--<artifactId>commons-codec</artifactId>-->
|
||||
<!--<version>${commons-codec.wso2.version}</version>-->
|
||||
<!--</dependency>-->
|
||||
<dependency>
|
||||
<groupId>commons-codec.wso2</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>${commons-codec.version.wso2}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
@ -1179,7 +1184,7 @@
|
||||
|
||||
|
||||
<orbit.version.commons-httpclient>3.1.0.wso2v2</orbit.version.commons-httpclient>
|
||||
<!--<commons-codec.wso2.version>1.4.0.wso2v1</commons-codec.wso2.version>-->
|
||||
<commons-codec.version.wso2>1.4.0.wso2v1</commons-codec.version.wso2>
|
||||
<commons-codec.version>1.7</commons-codec.version>
|
||||
|
||||
<javaee-web-api.version>6.0</javaee-web-api.version>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user