fixed multi tenant issues after testing

merge-requests/1/head
ayyoob 8 years ago
parent 2cfc4540f4
commit e0f6e9579d

@ -32,6 +32,10 @@
<url>http://wso2.org</url> <url>http://wso2.org</url>
<dependencies> <dependencies>
<dependency>
<groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.analytics-common</groupId> <groupId>org.wso2.carbon.analytics-common</groupId>
<artifactId>org.wso2.carbon.event.input.adapter.core</artifactId> <artifactId>org.wso2.carbon.event.input.adapter.core</artifactId>

@ -42,7 +42,6 @@ public class MQTTEventAdapter implements InputEventAdapter {
private MQTTAdapterListener mqttAdapterListener; private MQTTAdapterListener mqttAdapterListener;
private MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration; private MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration;
public MQTTEventAdapter(InputEventAdapterConfiguration eventAdapterConfiguration, public MQTTEventAdapter(InputEventAdapterConfiguration eventAdapterConfiguration,
Map<String, String> globalProperties) { Map<String, String> globalProperties) {
this.eventAdapterConfiguration = eventAdapterConfiguration; this.eventAdapterConfiguration = eventAdapterConfiguration;

@ -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) {

@ -53,7 +53,7 @@ public class MQTTEventAdapterConstants {
public static final String EMPTY_STRING = ""; public static final String EMPTY_STRING = "";
public static final String GRANT_TYPE_PARAM_NAME = "grant_type"; 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 TOKEN_SCOPE = "production";
public static final String APPLICATION_NAME_PREFIX = "InputAdapter_"; public static final String APPLICATION_NAME_PREFIX = "InputAdapter_";
public static final String CLIENT_ID = "clientId"; public static final String CLIENT_ID = "clientId";

@ -67,7 +67,7 @@ public class RegistrationProfile {
String jsonString = String jsonString =
"{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + "\", \"tokenScope\": " + "{\"callbackUrl\": \"" + callbackUrl + "\",\"clientName\": \"" + clientName + "\", \"tokenScope\": " +
"\"" + tokenScope + "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType + "\"" + tokenScope + "\", \"owner\": \"" + owner + "\"," + "\"grantType\": \"" + grantType +
"\", \"saasApp\" :false }\n"; "\", \"saasApp\" :true }\n";
return jsonString; return jsonString;
} }
} }

@ -793,6 +793,11 @@
<!--<artifactId>commons-codec</artifactId>--> <!--<artifactId>commons-codec</artifactId>-->
<!--<version>${commons-codec.wso2.version}</version>--> <!--<version>${commons-codec.wso2.version}</version>-->
<!--</dependency>--> <!--</dependency>-->
<dependency>
<groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version.wso2}</version>
</dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
@ -1179,7 +1184,7 @@
<orbit.version.commons-httpclient>3.1.0.wso2v2</orbit.version.commons-httpclient> <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> <commons-codec.version>1.7</commons-codec.version>
<javaee-web-api.version>6.0</javaee-web-api.version> <javaee-web-api.version>6.0</javaee-web-api.version>

Loading…
Cancel
Save