Search in sources :

Example 66 with StorageOSUser

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;
}
Also used : ApprovalList(com.emc.vipr.model.catalog.ApprovalList) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) ApprovalRequest(com.emc.storageos.db.client.model.uimodels.ApprovalRequest) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 67 with StorageOSUser

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);
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogCategoryMapper.createNewCatalogCategory(com.emc.sa.api.mapper.CatalogCategoryMapper.createNewCatalogCategory) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) 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 68 with StorageOSUser

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;
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogCategoryMapper.createNewCatalogCategory(com.emc.sa.api.mapper.CatalogCategoryMapper.createNewCatalogCategory) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory)

Example 69 with StorageOSUser

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;
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogUpgrade(com.emc.vipr.model.catalog.CatalogUpgrade) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 70 with StorageOSUser

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);
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogCategoryMapper.createNewCatalogCategory(com.emc.sa.api.mapper.CatalogCategoryMapper.createNewCatalogCategory) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) 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