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;
}
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();
}
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);
}
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);
}
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);
}
Aggregations