use of models.security.UserInfo in project coprhd-controller by CoprHD.
the class Models method currentAdminTenantForVcenter.
@Util
public static String currentAdminTenantForVcenter() {
String sessionTenant = session.get(TENANT_ID);
if (sessionTenant != null && canSelectTenantForVcenters(sessionTenant)) {
return validateSessionTenantForVcenter(sessionTenant);
} else {
session.remove(TENANT_ID);
UserInfo info = Security.getUserInfo();
if (Security.isTenantAdmin() && !Security.isHomeTenantAdmin()) {
for (URI tenant : info.getSubTenants()) {
String tenantId = tenant.toString();
if (info.hasSubTenantRole(tenantId, Security.TENANT_ADMIN)) {
return tenantId;
}
}
}
// fallback to the home tenant if nothing else matches
return info.getTenant();
}
}
Aggregations