Search in sources :

Example 1 with ApiVersionBeanDto

use of io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto in project apiman by apiman.

the class DeveloperPortalResourceImpl method getApiVersion.

@Override
public ApiVersionBeanDto getApiVersion(String orgId, String apiId, String apiVersion) {
    securityContext.checkPermissionsOrDiscoverability(EntityType.API, orgId, apiId, apiVersion, Set.of(PermissionType.apiView));
    ApiVersionBeanDto v = apiService.getApiVersion(orgId, apiId, apiVersion);
    // TODO(msavy): probably a nicer way of doing this.
    Set<ApiPlanBeanDto> filteredPlans = v.getPlans().stream().filter(ap -> securityContext.hasPermission(PermissionType.planView, orgId) || permittedDiscoverability(ap.getDiscoverability())).collect(Collectors.toSet());
    v.setPlans(filteredPlans);
    // TODO(msavy): make new projection for this.
    return RestHelper.hideSensitiveDataFromApiVersionBean(v);
}
Also used : DiscoverabilityLevel(io.apiman.manager.api.beans.idm.DiscoverabilityLevel) IDeveloperPortalResource(io.apiman.manager.api.rest.IDeveloperPortalResource) ApiVersionNotFoundException(io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException) Path(javax.ws.rs.Path) ISecurityContext(io.apiman.manager.api.security.ISecurityContext) GatewayNotFoundException(io.apiman.manager.api.rest.exceptions.GatewayNotFoundException) PolicyBean(io.apiman.manager.api.beans.policies.PolicyBean) DevPortalService(io.apiman.manager.api.service.DevPortalService) OrganizationAlreadyExistsException(io.apiman.manager.api.rest.exceptions.OrganizationAlreadyExistsException) PermissionsHelper(io.apiman.manager.api.rest.impl.util.PermissionsHelper) EntityType(io.apiman.manager.api.security.ISecurityContext.EntityType) Inject(javax.inject.Inject) ApiVersionEndpointSummaryBean(io.apiman.manager.api.beans.summary.ApiVersionEndpointSummaryBean) PlanVersionNotFoundException(io.apiman.manager.api.rest.exceptions.PlanVersionNotFoundException) ApimanLoggerFactory(io.apiman.common.logging.ApimanLoggerFactory) ApiVersionBeanDto(io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto) OrganizationBean(io.apiman.manager.api.beans.orgs.OrganizationBean) ApiService(io.apiman.manager.api.service.ApiService) PolicyNotFoundException(io.apiman.manager.api.rest.exceptions.PolicyNotFoundException) Transactional(javax.transaction.Transactional) OrganizationService(io.apiman.manager.api.service.OrganizationService) SearchResultsBean(io.apiman.manager.api.beans.search.SearchResultsBean) ApiDefinitionStream(io.apiman.manager.api.service.ApiService.ApiDefinitionStream) Set(java.util.Set) BeanUtils(io.apiman.manager.api.beans.BeanUtils) InvalidSearchCriteriaException(io.apiman.manager.api.rest.exceptions.InvalidSearchCriteriaException) UUID(java.util.UUID) DeveloperApiPlanSummaryDto(io.apiman.manager.api.beans.developers.DeveloperApiPlanSummaryDto) Collectors(java.util.stream.Collectors) NewOrganizationBean(io.apiman.manager.api.beans.orgs.NewOrganizationBean) ApiVersionSummaryBean(io.apiman.manager.api.beans.summary.ApiVersionSummaryBean) NotAuthorizedException(io.apiman.manager.api.rest.exceptions.NotAuthorizedException) ApiVersionPolicySummaryDto(io.apiman.manager.api.beans.developers.ApiVersionPolicySummaryDto) ApiSummaryBean(io.apiman.manager.api.beans.summary.ApiSummaryBean) InvalidApiStatusException(io.apiman.manager.api.rest.exceptions.InvalidApiStatusException) List(java.util.List) IApimanLogger(io.apiman.common.logging.IApimanLogger) ApiPlanBeanDto(io.apiman.manager.api.beans.apis.dto.ApiPlanBeanDto) OrganizationNotFoundException(io.apiman.manager.api.rest.exceptions.OrganizationNotFoundException) PolicySummaryBean(io.apiman.manager.api.beans.summary.PolicySummaryBean) Response(javax.ws.rs.core.Response) PlanService(io.apiman.manager.api.service.PlanService) SearchCriteriaBean(io.apiman.manager.api.beans.search.SearchCriteriaBean) ApplicationScoped(javax.enterprise.context.ApplicationScoped) SearchService(io.apiman.manager.api.service.SearchService) ExceptionFactory(io.apiman.manager.api.rest.exceptions.util.ExceptionFactory) PermissionType(io.apiman.manager.api.beans.idm.PermissionType) RestHelper(io.apiman.manager.api.rest.impl.util.RestHelper) ApiVersionBeanDto(io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto) ApiPlanBeanDto(io.apiman.manager.api.beans.apis.dto.ApiPlanBeanDto)

Example 2 with ApiVersionBeanDto

use of io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto in project apiman by apiman.

the class DeveloperResourceImpl method getAllApiVersions.

@Override
public List<DeveloperApiVersionBeanDto> getAllApiVersions(String id) throws DeveloperNotFoundException, NotAuthorizedException {
    securityContext.checkIfUserIsCurrentUser(id);
    List<ApiVersionBeanDto> apiVersionBeans = new ArrayList<>();
    List<ContractSummaryBean> contracts = getAllClientContracts(id);
    for (ContractSummaryBean contract : contracts) {
        ApiVersionBeanDto apiVersion = apiService.getApiVersion(contract.getApiOrganizationId(), contract.getApiId(), contract.getApiVersion());
        if (securityContext.isAdmin()) {
            apiVersionBeans.add(apiVersion);
        } else {
            apiVersionBeans.add(RestHelper.hideSensitiveDataFromApiVersionBean(apiVersion));
        }
    }
    return apiVersionBeans.stream().map(DeveloperMapper.INSTANCE::toDto).collect(Collectors.toList());
}
Also used : ApiVersionBeanDto(io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto) DeveloperApiVersionBeanDto(io.apiman.manager.api.beans.developers.DeveloperApiVersionBeanDto) ArrayList(java.util.ArrayList) ContractSummaryBean(io.apiman.manager.api.beans.summary.ContractSummaryBean) DeveloperMapper(io.apiman.manager.api.beans.developers.DeveloperMapper)

Example 3 with ApiVersionBeanDto

use of io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto in project apiman by apiman.

the class OrganizationResourceImpl method getApiVersion.

@Override
public ApiVersionBeanDto getApiVersion(String organizationId, String apiId, String version) throws ApiVersionNotFoundException {
    securityContext.checkPermissionsOrDiscoverability(API, organizationId, apiId, version, Set.of(PermissionType.apiView));
    if (securityContext.hasPermission(PermissionType.apiView, organizationId)) {
        return apiService.getApiVersion(organizationId, apiId, version);
    } else {
        ApiVersionBeanDto av = apiService.getApiVersion(organizationId, apiId, version);
        Set<ApiPlanBeanDto> filteredPlans = av.getPlans().stream().filter(avp -> securityContext.getPermittedDiscoverabilities().contains(avp.getDiscoverability())).collect(Collectors.toSet());
        av.setPlans(filteredPlans);
        return av;
    }
}
Also used : PolicyChainBean(io.apiman.manager.api.beans.policies.PolicyChainBean) MemberBean(io.apiman.manager.api.beans.members.MemberBean) ApiPlanSummaryBean(io.apiman.manager.api.beans.summary.ApiPlanSummaryBean) ClientAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ClientAlreadyExistsException) UpdateApiBean(io.apiman.manager.api.beans.apis.UpdateApiBean) ISecurityContext(io.apiman.manager.api.security.ISecurityContext) ApiVersionAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ApiVersionAlreadyExistsException) GatewayNotFoundException(io.apiman.manager.api.rest.exceptions.GatewayNotFoundException) InvalidVersionException(io.apiman.manager.api.rest.exceptions.InvalidVersionException) OrganizationAlreadyExistsException(io.apiman.manager.api.rest.exceptions.OrganizationAlreadyExistsException) PLAN(io.apiman.manager.api.security.ISecurityContext.EntityType.PLAN) Valid(javax.validation.Valid) ApiVersionEndpointSummaryBean(io.apiman.manager.api.beans.summary.ApiVersionEndpointSummaryBean) MediaType(javax.ws.rs.core.MediaType) DownloadType(io.apiman.manager.api.beans.download.DownloadType) ApiManagerConfig(io.apiman.manager.api.core.config.ApiManagerConfig) OrganizationBean(io.apiman.manager.api.beans.orgs.OrganizationBean) EntityStillActiveException(io.apiman.manager.api.rest.exceptions.EntityStillActiveException) NewApiDefinitionBean(io.apiman.manager.api.beans.apis.NewApiDefinitionBean) PolicyNotFoundException(io.apiman.manager.api.rest.exceptions.PolicyNotFoundException) Transactional(javax.transaction.Transactional) ApiVersionStatusBean(io.apiman.manager.api.beans.apis.ApiVersionStatusBean) PlanAlreadyExistsException(io.apiman.manager.api.rest.exceptions.PlanAlreadyExistsException) ApiDefinitionStream(io.apiman.manager.api.service.ApiService.ApiDefinitionStream) Set(java.util.Set) ApiAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ApiAlreadyExistsException) NotAuthorizedException(io.apiman.manager.api.rest.exceptions.NotAuthorizedException) UserNotFoundException(io.apiman.manager.api.rest.exceptions.UserNotFoundException) IOUtils(org.apache.commons.io.IOUtils) ApiPlanBeanDto(io.apiman.manager.api.beans.apis.dto.ApiPlanBeanDto) AuditEntryBean(io.apiman.manager.api.beans.audit.AuditEntryBean) UsageHistogramBean(io.apiman.manager.api.beans.metrics.UsageHistogramBean) PlanVersionSummaryBean(io.apiman.manager.api.beans.summary.PlanVersionSummaryBean) UpdateClientBean(io.apiman.manager.api.beans.clients.UpdateClientBean) PlanBean(io.apiman.manager.api.beans.plans.PlanBean) PlanSummaryBean(io.apiman.manager.api.beans.summary.PlanSummaryBean) BooleanUtils(org.apache.commons.lang3.BooleanUtils) ResponseStatsHistogramBean(io.apiman.manager.api.beans.metrics.ResponseStatsHistogramBean) EntityType(io.apiman.manager.api.security.ISecurityContext.EntityType) HttpServletRequest(javax.servlet.http.HttpServletRequest) PlanVersionNotFoundException(io.apiman.manager.api.rest.exceptions.PlanVersionNotFoundException) IOrganizationResource(io.apiman.manager.api.rest.IOrganizationResource) RoleNotFoundException(io.apiman.manager.api.rest.exceptions.RoleNotFoundException) UsagePerClientBean(io.apiman.manager.api.beans.metrics.UsagePerClientBean) InvalidNameException(io.apiman.manager.api.rest.exceptions.InvalidNameException) DataAccessUtilMixin(io.apiman.manager.api.rest.impl.util.DataAccessUtilMixin) UsagePerPlanBean(io.apiman.manager.api.beans.metrics.UsagePerPlanBean) IPolicyProbeResponse(io.apiman.gateway.engine.beans.IPolicyProbeResponse) ApiVersionBeanDto(io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto) NewPlanVersionBean(io.apiman.manager.api.beans.plans.NewPlanVersionBean) GrantRolesBean(io.apiman.manager.api.beans.idm.GrantRolesBean) ClientVersionNotFoundException(io.apiman.manager.api.rest.exceptions.ClientVersionNotFoundException) IOException(java.io.IOException) NewOrganizationBean(io.apiman.manager.api.beans.orgs.NewOrganizationBean) ApiRegistryBean(io.apiman.manager.api.beans.summary.ApiRegistryBean) InvalidApiStatusException(io.apiman.manager.api.rest.exceptions.InvalidApiStatusException) DownloadBean(io.apiman.manager.api.beans.download.DownloadBean) UpdateApiVersionBean(io.apiman.manager.api.beans.apis.UpdateApiVersionBean) Messages(io.apiman.manager.api.rest.exceptions.i18n.Messages) ApiNotFoundException(io.apiman.manager.api.rest.exceptions.ApiNotFoundException) ExceptionFactory(io.apiman.manager.api.rest.exceptions.util.ExceptionFactory) ContractAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ContractAlreadyExistsException) NewPlanBean(io.apiman.manager.api.beans.plans.NewPlanBean) ApiBeanDto(io.apiman.manager.api.beans.apis.dto.ApiBeanDto) InvalidClientStatusException(io.apiman.manager.api.rest.exceptions.InvalidClientStatusException) NewApiBean(io.apiman.manager.api.beans.apis.NewApiBean) URL(java.net.URL) ApiVersionNotFoundException(io.apiman.manager.api.rest.exceptions.ApiVersionNotFoundException) HistogramIntervalType(io.apiman.manager.api.beans.metrics.HistogramIntervalType) NewContractBean(io.apiman.manager.api.beans.contracts.NewContractBean) StatsService(io.apiman.manager.api.service.StatsService) UpdateOrganizationBean(io.apiman.manager.api.beans.orgs.UpdateOrganizationBean) API(io.apiman.manager.api.security.ISecurityContext.EntityType.API) ApiDefinitionType(io.apiman.manager.api.beans.apis.ApiDefinitionType) IDownloadManager(io.apiman.manager.api.core.IDownloadManager) ResponseStatsPerClientBean(io.apiman.manager.api.beans.metrics.ResponseStatsPerClientBean) ClientVersionAlreadyExistsException(io.apiman.manager.api.rest.exceptions.ClientVersionAlreadyExistsException) InvalidPlanStatusException(io.apiman.manager.api.rest.exceptions.InvalidPlanStatusException) ApimanLoggerFactory(io.apiman.common.logging.ApimanLoggerFactory) SystemErrorException(io.apiman.manager.api.rest.exceptions.SystemErrorException) ContractNotFoundException(io.apiman.manager.api.rest.exceptions.ContractNotFoundException) ApiService(io.apiman.manager.api.service.ApiService) Context(javax.ws.rs.core.Context) ClientUsagePerApiBean(io.apiman.manager.api.beans.metrics.ClientUsagePerApiBean) OrganizationService(io.apiman.manager.api.service.OrganizationService) KeyValueTagDto(io.apiman.manager.api.beans.apis.dto.KeyValueTagDto) ContractService(io.apiman.manager.api.service.ContractService) Collectors(java.util.stream.Collectors) ApiVersionSummaryBean(io.apiman.manager.api.beans.summary.ApiVersionSummaryBean) NewClientVersionBean(io.apiman.manager.api.beans.clients.NewClientVersionBean) ApiSummaryBean(io.apiman.manager.api.beans.summary.ApiSummaryBean) ClientSummaryBean(io.apiman.manager.api.beans.summary.ClientSummaryBean) List(java.util.List) IApimanLogger(io.apiman.common.logging.IApimanLogger) PolicySummaryBean(io.apiman.manager.api.beans.summary.PolicySummaryBean) Response(javax.ws.rs.core.Response) PlanService(io.apiman.manager.api.service.PlanService) ClientNotFoundException(io.apiman.manager.api.rest.exceptions.ClientNotFoundException) PermissionType(io.apiman.manager.api.beans.idm.PermissionType) IBlobStore(io.apiman.manager.api.core.IBlobStore) PolicyBean(io.apiman.manager.api.beans.policies.PolicyBean) PlanNotFoundException(io.apiman.manager.api.rest.exceptions.PlanNotFoundException) ContractBean(io.apiman.manager.api.beans.contracts.ContractBean) Inject(javax.inject.Inject) ClientBean(io.apiman.manager.api.beans.clients.ClientBean) ResponseStatsSummaryBean(io.apiman.manager.api.beans.metrics.ResponseStatsSummaryBean) InvalidMetricCriteriaException(io.apiman.manager.api.rest.exceptions.InvalidMetricCriteriaException) PlanVersionBean(io.apiman.manager.api.beans.plans.PlanVersionBean) ClientAppService(io.apiman.manager.api.service.ClientAppService) ClientVersionSummaryBean(io.apiman.manager.api.beans.summary.ClientVersionSummaryBean) SearchResultsBean(io.apiman.manager.api.beans.search.SearchResultsBean) ContractSummaryBean(io.apiman.manager.api.beans.summary.ContractSummaryBean) PlanVersionAlreadyExistsException(io.apiman.manager.api.rest.exceptions.PlanVersionAlreadyExistsException) ClientVersionBean(io.apiman.manager.api.beans.clients.ClientVersionBean) NewApiVersionBean(io.apiman.manager.api.beans.apis.NewApiVersionBean) NewPolicyBean(io.apiman.manager.api.beans.policies.NewPolicyBean) OrganizationNotFoundException(io.apiman.manager.api.rest.exceptions.OrganizationNotFoundException) UpdatePolicyBean(io.apiman.manager.api.beans.policies.UpdatePolicyBean) UpdatePlanBean(io.apiman.manager.api.beans.plans.UpdatePlanBean) RequestScoped(javax.enterprise.context.RequestScoped) NewClientBean(io.apiman.manager.api.beans.clients.NewClientBean) ResponseStatsPerPlanBean(io.apiman.manager.api.beans.metrics.ResponseStatsPerPlanBean) ApiKeyBean(io.apiman.manager.api.beans.clients.ApiKeyBean) RestHelper(io.apiman.manager.api.rest.impl.util.RestHelper) InputStream(java.io.InputStream) ApiVersionBeanDto(io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto) ApiPlanBeanDto(io.apiman.manager.api.beans.apis.dto.ApiPlanBeanDto)

Example 4 with ApiVersionBeanDto

use of io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto in project apiman by apiman.

the class RestHelper method hideSensitiveDataFromApiVersionBean.

/**
 * This method will hide sensitive data, such as created by, from the result
 *
 * @param apiVersionBean the apiVersionBean
 * @return the apiVersionBean without sensitive data
 */
public static ApiVersionBeanDto hideSensitiveDataFromApiVersionBean(ApiVersionBeanDto apiVersionBean) {
    ApiBeanDto api = new ApiBeanDto();
    api.setId(apiVersionBean.getApi().getId());
    api.setName(apiVersionBean.getApi().getName());
    api.setDescription(apiVersionBean.getApi().getDescription());
    api.setImage(apiVersionBean.getApi().getImage());
    OrganizationBean org = new OrganizationBean();
    org.setId(apiVersionBean.getApi().getOrganization().getId());
    org.setName(apiVersionBean.getApi().getOrganization().getName());
    org.setDescription(apiVersionBean.getApi().getOrganization().getDescription());
    api.setOrganization(org);
    ApiVersionBeanDto apiVersion = new ApiVersionBeanDto();
    apiVersion.setApi(api);
    apiVersion.setStatus(apiVersionBean.getStatus());
    apiVersion.setEndpointType(apiVersionBean.getEndpointType());
    apiVersion.setEndpointContentType(apiVersionBean.getEndpointContentType());
    apiVersion.setGateways(apiVersionBean.getGateways());
    apiVersion.setPublicAPI(apiVersionBean.isPublicAPI());
    apiVersion.setPlans(apiVersionBean.getPlans());
    apiVersion.setVersion(apiVersionBean.getVersion());
    apiVersion.setDefinitionType(apiVersionBean.getDefinitionType());
    apiVersion.setPublicDiscoverability(apiVersionBean.getPublicDiscoverability());
    apiVersion.setExtendedDescription(apiVersionBean.getExtendedDescription());
    // dates
    apiVersion.setCreatedOn(apiVersionBean.getCreatedOn());
    apiVersion.setModifiedOn(apiVersionBean.getModifiedOn());
    apiVersion.setPublishedOn(apiVersionBean.getPublishedOn());
    apiVersion.setRetiredOn(apiVersionBean.getRetiredOn());
    return apiVersion;
}
Also used : ApiBeanDto(io.apiman.manager.api.beans.apis.dto.ApiBeanDto) ApiVersionBeanDto(io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto) OrganizationBean(io.apiman.manager.api.beans.orgs.OrganizationBean)

Aggregations

ApiVersionBeanDto (io.apiman.manager.api.beans.apis.dto.ApiVersionBeanDto)4 OrganizationBean (io.apiman.manager.api.beans.orgs.OrganizationBean)3 ApimanLoggerFactory (io.apiman.common.logging.ApimanLoggerFactory)2 IApimanLogger (io.apiman.common.logging.IApimanLogger)2 ApiBeanDto (io.apiman.manager.api.beans.apis.dto.ApiBeanDto)2 ApiPlanBeanDto (io.apiman.manager.api.beans.apis.dto.ApiPlanBeanDto)2 PermissionType (io.apiman.manager.api.beans.idm.PermissionType)2 ContractSummaryBean (io.apiman.manager.api.beans.summary.ContractSummaryBean)2 IPolicyProbeResponse (io.apiman.gateway.engine.beans.IPolicyProbeResponse)1 BeanUtils (io.apiman.manager.api.beans.BeanUtils)1 ApiDefinitionType (io.apiman.manager.api.beans.apis.ApiDefinitionType)1 ApiVersionStatusBean (io.apiman.manager.api.beans.apis.ApiVersionStatusBean)1 NewApiBean (io.apiman.manager.api.beans.apis.NewApiBean)1 NewApiDefinitionBean (io.apiman.manager.api.beans.apis.NewApiDefinitionBean)1 NewApiVersionBean (io.apiman.manager.api.beans.apis.NewApiVersionBean)1 UpdateApiBean (io.apiman.manager.api.beans.apis.UpdateApiBean)1 UpdateApiVersionBean (io.apiman.manager.api.beans.apis.UpdateApiVersionBean)1 KeyValueTagDto (io.apiman.manager.api.beans.apis.dto.KeyValueTagDto)1 AuditEntryBean (io.apiman.manager.api.beans.audit.AuditEntryBean)1 ApiKeyBean (io.apiman.manager.api.beans.clients.ApiKeyBean)1