use of bio.terra.common.exception.NotFoundException 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.NotFoundException in project terra-external-credentials-manager by DataBiosphere.
the class ProviderService method validateVisaWithProvider.
@VisibleForTesting
boolean validateVisaWithProvider(VisaVerificationDetails visaDetails) {
var providerProperties = externalCredsConfig.getProviders().get(visaDetails.getProviderName());
if (providerProperties == null) {
throw new NotFoundException(String.format("Provider %s not found", visaDetails.getProviderName()));
}
var validationEndpoint = providerProperties.getValidationEndpoint().orElseThrow(() -> new NotFoundException(String.format("Validation endpoint for provider %s not found", visaDetails.getProviderName())));
var response = WebClient.create(validationEndpoint).get().uri(uriBuilder -> uriBuilder.queryParam("visa", visaDetails.getVisaJwt()).build()).retrieve();
var responseBody = response.onStatus(HttpStatus::isError, clientResponse -> Mono.empty()).bodyToMono(String.class).block(Duration.of(1000, ChronoUnit.MILLIS));
log.info("Got visa validation response.", Map.of("linkedAccountId", visaDetails.getLinkedAccountId(), "providerName", visaDetails.getProviderName(), "validationResponse", Objects.requireNonNullElse(responseBody, "[null]")));
var visaValid = "valid".equalsIgnoreCase(responseBody);
if (visaValid) {
passportService.updateVisaLastValidated(visaDetails.getVisaId());
}
return visaValid;
}
use of bio.terra.common.exception.NotFoundException in project terra-external-credentials-manager by DataBiosphere.
the class ProviderService method deleteLink.
public void deleteLink(String userId, String providerName) {
var providerInfo = externalCredsConfig.getProviders().get(providerName);
if (providerInfo == null) {
throw new NotFoundException(String.format("Provider %s not found", providerName));
}
var linkedAccount = linkedAccountService.getLinkedAccount(userId, providerName).orElseThrow(() -> new NotFoundException("Link not found for user"));
revokeAccessToken(providerInfo, linkedAccount);
linkedAccountService.deleteLinkedAccount(userId, providerName);
}
Aggregations