|
|
@ -203,14 +203,23 @@ public class RaspberryPiServiceImpl implements RaspberryPiService {
|
|
|
|
throw new DeviceManagementException(msg);
|
|
|
|
throw new DeviceManagementException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (apiApplicationKey == null) {
|
|
|
|
if (apiApplicationKey == null) {
|
|
|
|
|
|
|
|
String adminUsername = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getAdminUserName();
|
|
|
|
|
|
|
|
String tenantAdminDomainName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
|
|
|
String applicationUsername = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm()
|
|
|
|
String applicationUsername = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm()
|
|
|
|
.getRealmConfiguration().getAdminUserName() + "@" + PrivilegedCarbonContext
|
|
|
|
.getRealmConfiguration().getAdminUserName() + "@" + PrivilegedCarbonContext
|
|
|
|
.getThreadLocalCarbonContext().getTenantDomain();
|
|
|
|
.getThreadLocalCarbonContext().getTenantDomain();
|
|
|
|
APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService();
|
|
|
|
APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService();
|
|
|
|
String[] tags = {RaspberrypiConstants.DEVICE_TYPE};
|
|
|
|
String[] tags = {RaspberrypiConstants.DEVICE_TYPE};
|
|
|
|
apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
|
|
|
|
try{
|
|
|
|
RaspberrypiConstants.DEVICE_TYPE, tags, KEY_TYPE, applicationUsername, true,
|
|
|
|
PrivilegedCarbonContext.startTenantFlow();
|
|
|
|
RaspberrypiConstants.APIM_APPLICATION_TOKEN_VALIDITY_PERIOD);
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantAdminDomainName);
|
|
|
|
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(adminUsername);
|
|
|
|
|
|
|
|
apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
|
|
|
|
|
|
|
|
RaspberrypiConstants.DEVICE_TYPE, tags, KEY_TYPE, applicationUsername, true,
|
|
|
|
|
|
|
|
RaspberrypiConstants.APIM_APPLICATION_TOKEN_VALIDITY_PERIOD);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
PrivilegedCarbonContext.endTenantFlow();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JWTClient jwtClient = APIUtil.getJWTClientManagerService().getJWTClient();
|
|
|
|
JWTClient jwtClient = APIUtil.getJWTClientManagerService().getJWTClient();
|
|
|
|
String scopes = " device_" + deviceId;
|
|
|
|
String scopes = " device_" + deviceId;
|
|
|
|