use of bio.terra.service.iam.AuthenticatedUserRequest 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());
}
use of bio.terra.service.iam.AuthenticatedUserRequest in project jade-data-repo by DataBiosphere.
the class JobService method submitAndWait.
// submit a new job to stairway, wait for it to finish, then return the result
// protected method intended to be called only from JobBuilder
protected <T> T submitAndWait(Class<? extends Flight> flightClass, FlightMap parameterMap, Class<T> resultClass) {
String jobId = submit(flightClass, parameterMap);
waitForJob(jobId);
AuthenticatedUserRequest userReq = parameterMap.get(JobMapKeys.AUTH_USER_INFO.getKeyName(), AuthenticatedUserRequest.class);
return retrieveJobResult(jobId, resultClass, userReq).getResult();
}
use of bio.terra.service.iam.AuthenticatedUserRequest in project jade-data-repo by DataBiosphere.
the class RepositoryApiController method createSnapshot.
@Override
public ResponseEntity<JobModel> createSnapshot(@Valid @RequestBody SnapshotRequestModel snapshotRequestModel) {
AuthenticatedUserRequest userReq = getAuthenticatedInfo();
List<UUID> snapshotSourceDatasetIds = snapshotService.getSourceDatasetIdsFromSnapshotRequest(snapshotRequestModel);
// TODO auth should be put into flight?
List<UUID> unauthorized = getUnauthorizedSources(snapshotSourceDatasetIds, userReq);
if (unauthorized.isEmpty()) {
String jobId = snapshotService.createSnapshot(snapshotRequestModel, userReq);
// we can retrieve the job we just created
return jobToResponse(jobService.retrieveJob(jobId, userReq));
}
throw new IamUnauthorizedException("User is not authorized to create snapshots for these datasets " + unauthorized);
}
use of bio.terra.service.iam.AuthenticatedUserRequest in project jade-data-repo by DataBiosphere.
the class RepositoryApiController method ingestFile.
@Override
public ResponseEntity<JobModel> ingestFile(@PathVariable("id") String id, @Valid @RequestBody FileLoadModel ingestFile) {
AuthenticatedUserRequest userReq = getAuthenticatedInfo();
iamService.verifyAuthorization(userReq, IamResourceType.DATASET, id, IamAction.INGEST_DATA);
String jobId = fileService.ingestFile(id, ingestFile, userReq);
// we can retrieve the job we just created
return jobToResponse(jobService.retrieveJob(jobId, userReq));
}
use of bio.terra.service.iam.AuthenticatedUserRequest in project jade-data-repo by DataBiosphere.
the class RepositoryApiController method deleteSnapshot.
@Override
public ResponseEntity<JobModel> deleteSnapshot(@PathVariable("id") String id) {
AuthenticatedUserRequest userReq = getAuthenticatedInfo();
iamService.verifyAuthorization(userReq, IamResourceType.DATASNAPSHOT, id, IamAction.DELETE);
String jobId = snapshotService.deleteSnapshot(UUID.fromString(id), userReq);
// we can retrieve the job we just created
return jobToResponse(jobService.retrieveJob(jobId, userReq));
}
Aggregations