use of bio.terra.common.exception.UnauthorizedException in project jade-data-repo by DataBiosphere.
the class CreateDatasetAuthzIamStep method undoStep.
@Override
public StepResult undoStep(FlightContext context) throws InterruptedException {
FlightMap workingMap = context.getWorkingMap();
UUID datasetId = workingMap.get(DatasetWorkingMapKeys.DATASET_ID, UUID.class);
try {
iamClient.deleteDatasetResource(userReq, datasetId);
} catch (UnauthorizedException ex) {
// suppress exception
logger.error("NEEDS CLEANUP: delete sam resource for dataset " + datasetId.toString(), ex);
} catch (NotFoundException ex) {
// if the SAM resource is not found, then it was likely not created -- continue undoing
}
return StepResult.getStepResultSuccess();
}
use of bio.terra.common.exception.UnauthorizedException in project jade-data-repo by DataBiosphere.
the class SnapshotAuthzIamStep method undoStep.
@Override
public StepResult undoStep(FlightContext context) {
FlightMap workingMap = context.getWorkingMap();
UUID snapshotId = workingMap.get(SnapshotWorkingMapKeys.SNAPSHOT_ID, UUID.class);
try {
sam.deleteSnapshotResource(userReq, snapshotId);
// We do not need to remove the ACL from the files or BigQuery. It disappears
// when SAM deletes the ACL. How 'bout that!
} catch (UnauthorizedException ex) {
// suppress exception
logger.error("NEEDS CLEANUP: delete sam resource for snapshot " + snapshotId.toString());
logger.warn(ex.getMessage());
}
return StepResult.getStepResultSuccess();
}
use of bio.terra.common.exception.UnauthorizedException in project terra-external-credentials-manager by DataBiosphere.
the class OidcApiController method getUserIdFromSam.
private String getUserIdFromSam() {
try {
var header = request.getHeader("authorization");
if (header == null)
throw new UnauthorizedException("User is not authorized");
var accessToken = BearerTokenParser.parse(header);
return samService.samUsersApi(accessToken).getUserStatusInfo().getUserSubjectId();
} catch (ApiException e) {
throw new ExternalCredsException(e, e.getCode() == HttpStatus.NOT_FOUND.value() ? HttpStatus.FORBIDDEN : HttpStatus.INTERNAL_SERVER_ERROR);
}
}
Aggregations