Search in sources :

Example 46 with StorageOSUser

use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.

the class CatalogCategoryService method filterServicesByACLs.

/**
 * filter out the services which user don't have access to
 *
 * @param services
 * @return
 */
private List<CatalogService> filterServicesByACLs(List<CatalogService> services) {
    List<CatalogService> filteredCatalogServices = Lists.newArrayList();
    StorageOSUser storageOSUser = getUserFromContext();
    String username = storageOSUser.getName();
    if (isAdministrator(storageOSUser)) {
        log.debug(username + " has SystemAdmin or TenantAdmin Role, can view all categories.");
        filteredCatalogServices.addAll(services);
        return filteredCatalogServices;
    }
    for (CatalogService service : services) {
        if (hasAccess(storageOSUser, service)) {
            filteredCatalogServices.add(service);
        }
    }
    return filteredCatalogServices;
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService)

Example 47 with StorageOSUser

use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.

the class CatalogCategoryService method upgradeCatalog.

/**
 * Update the service catalog to the latest version
 *
 * @prereq none
 * @brief Service Catalog Update
 * @return none
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
@Path("/upgrade")
public Response upgradeCatalog(@DefaultValue("") @QueryParam(SearchConstants.TENANT_ID_PARAM) String tenantId) {
    StorageOSUser user = getUserFromContext();
    if (StringUtils.isBlank(tenantId)) {
        tenantId = user.getTenantId();
    }
    verifyAuthorizedInTenantOrg(uri(tenantId), user);
    try {
        catalogCategoryManager.upgradeCatalog(uri(tenantId));
    } catch (IOException e) {
        log.error("Failed to upgrade catalog", e);
        return Response.serverError().build();
    }
    return Response.ok().build();
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) IOException(java.io.IOException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 48 with StorageOSUser

use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.

the class CatalogPreferenceService method get.

@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("")
public CatalogPreferencesRestRep get(@DefaultValue("") @QueryParam(SearchConstants.TENANT_ID_PARAM) String tenantId) {
    StorageOSUser user = getUserFromContext();
    if (StringUtils.isBlank(tenantId)) {
        tenantId = user.getTenantId();
    }
    verifyAuthorizedInTenantOrg(uri(tenantId), user);
    TenantPreferences catalogPreferences = catalogPreferenceManager.getPreferencesByTenant(tenantId);
    return map(catalogPreferences);
}
Also used : TenantPreferences(com.emc.storageos.db.client.model.uimodels.TenantPreferences) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 49 with StorageOSUser

use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.

the class CatalogPreferenceService method update.

@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("")
@CheckPermission(roles = { Role.TENANT_ADMIN })
public CatalogPreferencesRestRep update(CatalogPreferencesUpdateParam param) {
    String tenantId = param.getTenantId();
    StorageOSUser user = getUserFromContext();
    if (StringUtils.isBlank(tenantId)) {
        tenantId = user.getTenantId();
    }
    verifyAuthorizedInTenantOrg(uri(tenantId), user);
    TenantPreferences tenantPreferences = catalogPreferenceManager.getPreferencesByTenant(tenantId);
    validateParam(uri(tenantId), param, tenantPreferences);
    updateObject(tenantPreferences, param);
    catalogPreferenceManager.updatePreferences(tenantPreferences);
    auditOpSuccess(OperationTypeEnum.UPDATE_CATALOG_PREFERENCES, tenantPreferences.auditParameters());
    tenantPreferences = catalogPreferenceManager.getPreferences(tenantPreferences.getId());
    return map(tenantPreferences);
}
Also used : TenantPreferences(com.emc.storageos.db.client.model.uimodels.TenantPreferences) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 50 with StorageOSUser

use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.

the class CatalogServiceService method getRecentCatalogServices.

/**
 * Gets the list a user's recent services
 *
 * @brief List user's recent catalog services
 * @return a list of user's recent services
 * @throws DatabaseException when a DB error occurs
 */
@GET
@Path("/recent")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public CatalogServiceList getRecentCatalogServices() throws DatabaseException {
    StorageOSUser user = getUserFromContext();
    List<CatalogService> catalogServices = catalogServiceManager.getRecentCatalogServices(user);
    return toCatalogServiceList(catalogServices);
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)105 Produces (javax.ws.rs.Produces)59 Path (javax.ws.rs.Path)53 URI (java.net.URI)50 GET (javax.ws.rs.GET)36 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)31 Consumes (javax.ws.rs.Consumes)24 POST (javax.ws.rs.POST)15 ArrayList (java.util.ArrayList)13 Order (com.emc.storageos.db.client.model.uimodels.Order)12 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)12 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)11 NamedURI (com.emc.storageos.db.client.model.NamedURI)10 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)10 PUT (javax.ws.rs.PUT)10 Operation (com.emc.storageos.db.client.model.Operation)9 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)9 HashSet (java.util.HashSet)9 StringSet (com.emc.storageos.db.client.model.StringSet)8 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)8