use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class ApprovalService method getApprovals.
/**
* Gets the list of approvals
*
* @param tenantId the URN of a tenant
* @brief List Approvals
* @return a list of approvals
* @throws DatabaseException when a DB error occurs
*/
@GET
@Path("")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ApprovalList getApprovals(@DefaultValue("") @QueryParam(SearchConstants.TENANT_ID_PARAM) String tenantId) throws DatabaseException {
StorageOSUser user = getUserFromContext();
if (StringUtils.isBlank(tenantId)) {
tenantId = user.getTenantId();
}
verifyAuthorizedInTenantOrg(uri(tenantId), getUserFromContext());
List<ApprovalRequest> approvals = approvalManager.getApprovals(uri(tenantId));
ApprovalList approvalList = new ApprovalList();
for (ApprovalRequest approval : approvals) {
NamedRelatedResourceRep approvalRestRep = toNamedRelatedResource(ResourceTypeEnum.APPROVAL, approval.getId(), approval.getLabel());
approvalList.getApprovals().add(approvalRestRep);
}
return approvalList;
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class CatalogCategoryService method createCatalogCategory.
/**
* Creates a new catalog category in the supplied parent catalog category
*
* @param createParam
* the parameter to create a new catalog category
* @prereq none
* @brief Create Catalog Category
* @return none
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
@Path("")
public CatalogCategoryRestRep createCatalogCategory(CatalogCategoryCreateParam createParam) {
StorageOSUser user = getUserFromContext();
String tenantId = createParam.getTenantId();
if (StringUtils.isBlank(tenantId)) {
tenantId = user.getTenantId();
}
verifyAuthorizedInTenantOrg(uri(tenantId), user);
CatalogCategory parentCatalogCategory = queryResource(createParam.getCatalogCategoryId());
validateCatalogCategoryParam(createParam.getCatalogCategoryId(), createParam, null);
CatalogCategory catalogCategory = createNewCatalogCategory(parentCatalogCategory, createParam);
catalogCategoryManager.createCatalogCategory(catalogCategory);
auditOpSuccess(OperationTypeEnum.CREATE_CATALOG_CATEGORY, catalogCategory.auditParameters());
return map(catalogCategory);
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class CatalogCategoryService method filterCategoriesByACLs.
/**
* filter out the categories which user don't have access to
*
* @param categories
* @return
*/
private List<CatalogCategory> filterCategoriesByACLs(List<CatalogCategory> categories) {
List<CatalogCategory> filteredCatalogCategories = Lists.newArrayList();
StorageOSUser storageOSUser = getUserFromContext();
String username = storageOSUser.getName();
if (isAdministrator(storageOSUser)) {
log.debug(username + " has SystemAdmin or TenantAdmin Role, can view all categories.");
filteredCatalogCategories.addAll(categories);
return filteredCatalogCategories;
}
for (CatalogCategory category : categories) {
if (hasAccess(storageOSUser, category)) {
filteredCatalogCategories.add(category);
}
}
return filteredCatalogCategories;
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class CatalogCategoryService method upgradeAvailable.
/**
* Check to see if an update to the service catalog is available
*
* @prereq none
* @brief Check for Service Catalog Update
* @return True if Update Available
*/
@GET
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
@Path("/upgrade")
public CatalogUpgrade upgradeAvailable(@DefaultValue("") @QueryParam(SearchConstants.TENANT_ID_PARAM) String tenantId) {
StorageOSUser user = getUserFromContext();
if (StringUtils.isBlank(tenantId)) {
tenantId = user.getTenantId();
}
verifyAuthorizedInTenantOrg(uri(tenantId), user);
CatalogUpgrade catalogUpgrade = new CatalogUpgrade();
catalogUpgrade.setUpgradeAvailable(catalogCategoryManager.isCatalogUpdateAvailable(uri(tenantId)));
return catalogUpgrade;
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class CatalogCategoryService method getRootCatalogCategory.
/**
* Get the root catalog category for a tenant
*
* @prereq none
* @brief Get Root Catalog Category
* @return Root Catalog Category
*/
@GET
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("")
public CatalogCategoryRestRep getRootCatalogCategory(@DefaultValue("") @QueryParam(SearchConstants.TENANT_ID_PARAM) String tenantId) {
StorageOSUser user = getUserFromContext();
if (StringUtils.isBlank(tenantId)) {
tenantId = user.getTenantId();
}
verifyAuthorizedInTenantOrg(uri(tenantId), user);
CatalogCategory catalogCategory = catalogCategoryManager.getOrCreateRootCategory(uri(tenantId));
return map(catalogCategory);
}
Aggregations