use of org.wso2.carbon.stratos.common.beans.TenantInfoBean in project carbon-business-process by wso2.
the class BPSUserIdentityManager method getTenantIdFromUserId.
private int getTenantIdFromUserId(String userId) throws Exception {
String[] userNameTokens = userId.split("@");
int tenantId = BPMNConstants.SUPER_TENANT_ID;
if (userNameTokens.length > 1) {
TenantInfoBean tenantInfoBean = tenantMgtAdminService.getTenant(userNameTokens[userNameTokens.length - 1]);
if (tenantInfoBean != null) {
tenantId = tenantInfoBean.getTenantId();
} else {
throw new Exception("Error retrieving tenant id from userId :" + userId);
}
}
return tenantId;
}
use of org.wso2.carbon.stratos.common.beans.TenantInfoBean in project carbon-business-process by wso2.
the class BPSUserIdentityManager method findGroupsByUser.
@Override
public List<Group> findGroupsByUser(String userId) {
List<Group> groups = new ArrayList<Group>();
try {
String[] userNameTokens = userId.split("@");
int tenantId = BPMNConstants.SUPER_TENANT_ID;
if (userNameTokens.length > 1) {
TenantInfoBean tenantInfoBean = tenantMgtAdminService.getTenant(userNameTokens[userNameTokens.length - 1]);
if (tenantInfoBean != null) {
tenantId = tenantInfoBean.getTenantId();
} else {
log.error("Could not retrieve tenant ID for tenant domain : " + userNameTokens[userNameTokens.length - 1]);
return new ArrayList<Group>();
}
}
String[] roles = registryService.getUserRealm(tenantId).getUserStoreManager().getRoleListOfUser(userId);
for (String role : roles) {
Group group = new GroupEntity(role);
groups.add(group);
}
} catch (UserStoreException e) {
String msg = "Failed to get roles of the user: " + userId + ". Returning an empty roles list.";
log.error(msg, e);
} catch (Exception e) {
log.error("error retrieving user tenant info", e);
}
return groups;
}
Aggregations