Search in sources :

Example 6 with UserInfo

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();
    }
}
Also used : UserInfo(models.security.UserInfo) URI(java.net.URI) Util(play.mvc.Util)

Aggregations

UserInfo (models.security.UserInfo)6 Util (play.mvc.Util)3 URI (java.net.URI)2 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)1 OpenStackTenantsDataTable (models.datatable.OpenStackTenantsDataTable)1 TenantsDataTable (models.datatable.TenantsDataTable)1 Before (play.mvc.Before)1 BourneUtil (util.BourneUtil)1