Search in sources :

Example 1 with IamResourceType

use of bio.terra.service.iam.IamResourceType in project jade-data-repo by DataBiosphere.

the class SamIam method listAuthorizedResourcesInner.

private List<UUID> listAuthorizedResourcesInner(AuthenticatedUserRequest userReq, IamResourceType iamResourceType) throws ApiException {
    ResourcesApi samResourceApi = samResourcesApi(userReq.getRequiredToken());
    List<ResourceAndAccessPolicy> resources = samResourceApi.listResourcesAndPolicies(iamResourceType.toString());
    return resources.stream().map(resource -> UUID.fromString(resource.getResourceId())).collect(Collectors.toList());
}
Also used : DataRepoException(bio.terra.common.exception.DataRepoException) Arrays(java.util.Arrays) IamResourceType(bio.terra.service.iam.IamResourceType) AccessPolicyMembership(org.broadinstitute.dsde.workbench.client.sam.model.AccessPolicyMembership) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) IamUnauthorizedException(bio.terra.service.iam.exception.IamUnauthorizedException) HashMap(java.util.HashMap) ApiException(org.broadinstitute.dsde.workbench.client.sam.ApiException) IamInternalServerErrorException(bio.terra.service.iam.exception.IamInternalServerErrorException) ArrayList(java.util.ArrayList) IamAction(bio.terra.service.iam.IamAction) GoogleApi(org.broadinstitute.dsde.workbench.client.sam.api.GoogleApi) Map(java.util.Map) ResourcesApi(org.broadinstitute.dsde.workbench.client.sam.api.ResourcesApi) Pair(org.broadinstitute.dsde.workbench.client.sam.Pair) AccessPolicyResponseEntry(org.broadinstitute.dsde.workbench.client.sam.model.AccessPolicyResponseEntry) PolicyModel(bio.terra.model.PolicyModel) Logger(org.slf4j.Logger) ApiClient(org.broadinstitute.dsde.workbench.client.sam.ApiClient) IamBadRequestException(bio.terra.service.iam.exception.IamBadRequestException) ResourceAndAccessPolicy(org.broadinstitute.dsde.workbench.client.sam.model.ResourceAndAccessPolicy) IamProviderInterface(bio.terra.service.iam.IamProviderInterface) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IamRole(bio.terra.service.iam.IamRole) Component(org.springframework.stereotype.Component) List(java.util.List) HttpStatusCodes(com.google.api.client.http.HttpStatusCodes) UserStatusInfo(bio.terra.model.UserStatusInfo) UsersApi(org.broadinstitute.dsde.workbench.client.sam.api.UsersApi) AuthenticatedUserRequest(bio.terra.service.iam.AuthenticatedUserRequest) ConfigurationService(bio.terra.service.configuration.ConfigurationService) Collections(java.util.Collections) IamNotFoundException(bio.terra.service.iam.exception.IamNotFoundException) ResourcesApi(org.broadinstitute.dsde.workbench.client.sam.api.ResourcesApi) ResourceAndAccessPolicy(org.broadinstitute.dsde.workbench.client.sam.model.ResourceAndAccessPolicy)

Example 2 with IamResourceType

use of bio.terra.service.iam.IamResourceType in project jade-data-repo by DataBiosphere.

the class SamIam method retrievePoliciesInner.

private List<PolicyModel> retrievePoliciesInner(AuthenticatedUserRequest userReq, IamResourceType iamResourceType, UUID resourceId) throws ApiException {
    ResourcesApi samResourceApi = samResourcesApi(userReq.getRequiredToken());
    List<AccessPolicyResponseEntry> results = samResourceApi.listResourcePolicies(iamResourceType.toString(), resourceId.toString());
    return results.stream().map(entry -> new PolicyModel().name(entry.getPolicyName()).members(entry.getPolicy().getMemberEmails())).collect(Collectors.toList());
}
Also used : DataRepoException(bio.terra.common.exception.DataRepoException) Arrays(java.util.Arrays) IamResourceType(bio.terra.service.iam.IamResourceType) AccessPolicyMembership(org.broadinstitute.dsde.workbench.client.sam.model.AccessPolicyMembership) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) IamUnauthorizedException(bio.terra.service.iam.exception.IamUnauthorizedException) HashMap(java.util.HashMap) ApiException(org.broadinstitute.dsde.workbench.client.sam.ApiException) IamInternalServerErrorException(bio.terra.service.iam.exception.IamInternalServerErrorException) ArrayList(java.util.ArrayList) IamAction(bio.terra.service.iam.IamAction) GoogleApi(org.broadinstitute.dsde.workbench.client.sam.api.GoogleApi) Map(java.util.Map) ResourcesApi(org.broadinstitute.dsde.workbench.client.sam.api.ResourcesApi) Pair(org.broadinstitute.dsde.workbench.client.sam.Pair) AccessPolicyResponseEntry(org.broadinstitute.dsde.workbench.client.sam.model.AccessPolicyResponseEntry) PolicyModel(bio.terra.model.PolicyModel) Logger(org.slf4j.Logger) ApiClient(org.broadinstitute.dsde.workbench.client.sam.ApiClient) IamBadRequestException(bio.terra.service.iam.exception.IamBadRequestException) ResourceAndAccessPolicy(org.broadinstitute.dsde.workbench.client.sam.model.ResourceAndAccessPolicy) IamProviderInterface(bio.terra.service.iam.IamProviderInterface) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IamRole(bio.terra.service.iam.IamRole) Component(org.springframework.stereotype.Component) List(java.util.List) HttpStatusCodes(com.google.api.client.http.HttpStatusCodes) UserStatusInfo(bio.terra.model.UserStatusInfo) UsersApi(org.broadinstitute.dsde.workbench.client.sam.api.UsersApi) AuthenticatedUserRequest(bio.terra.service.iam.AuthenticatedUserRequest) ConfigurationService(bio.terra.service.configuration.ConfigurationService) Collections(java.util.Collections) IamNotFoundException(bio.terra.service.iam.exception.IamNotFoundException) AccessPolicyResponseEntry(org.broadinstitute.dsde.workbench.client.sam.model.AccessPolicyResponseEntry) PolicyModel(bio.terra.model.PolicyModel) ResourcesApi(org.broadinstitute.dsde.workbench.client.sam.api.ResourcesApi)

Aggregations

DataRepoException (bio.terra.common.exception.DataRepoException)2 PolicyModel (bio.terra.model.PolicyModel)2 UserStatusInfo (bio.terra.model.UserStatusInfo)2 ConfigurationService (bio.terra.service.configuration.ConfigurationService)2 AuthenticatedUserRequest (bio.terra.service.iam.AuthenticatedUserRequest)2 IamAction (bio.terra.service.iam.IamAction)2 IamProviderInterface (bio.terra.service.iam.IamProviderInterface)2 IamResourceType (bio.terra.service.iam.IamResourceType)2 IamRole (bio.terra.service.iam.IamRole)2 IamBadRequestException (bio.terra.service.iam.exception.IamBadRequestException)2 IamInternalServerErrorException (bio.terra.service.iam.exception.IamInternalServerErrorException)2 IamNotFoundException (bio.terra.service.iam.exception.IamNotFoundException)2 IamUnauthorizedException (bio.terra.service.iam.exception.IamUnauthorizedException)2 HttpStatusCodes (com.google.api.client.http.HttpStatusCodes)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2