use of com.forgerock.openbanking.exceptions.OBErrorException in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpPaymentsEndpointWrapper method checkRequestAndConsentRiskMatch.
// The Risk section must matches the values specified in the consent.
public void checkRequestAndConsentRiskMatch(OBDomesticVRPRequest request, FRDomesticVRPConsent frConsent) throws OBErrorException {
OBRisk1 requestRisk = request.getRisk();
OBRisk1 consentRisk = toOBRisk1(frConsent.getRisk());
if (!requestRisk.equals(consentRisk)) {
throw new OBErrorException(OBRIErrorType.REQUEST_VRP_RISK_DOESNT_MATCH_CONSENT);
}
}
use of com.forgerock.openbanking.exceptions.OBErrorException in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpPaymentsEndpointWrapper method validateMaximumIndividualAmount.
private void validateMaximumIndividualAmount(OBDomesticVRPRequest vrpRequest, FRDomesticVRPConsent frConsent) throws OBErrorException {
FRDomesticVRPControlParameters controlParameters = frConsent.getVrpDetails().getData().getControlParameters();
Double consentAmount = Double.valueOf(controlParameters.getMaximumIndividualAmount().getAmount());
Double requestAmount = Double.valueOf(vrpRequest.getData().getInstruction().getInstructedAmount().getAmount());
if (requestAmount.compareTo(consentAmount) > 0) {
throw new OBErrorException(OBRIErrorType.REQUEST_VRP_CONTROL_PARAMETERS_RULES, VRPErrorControlParametersFields.RequestControlFields.MAX_INDIVIDUAL_AMOUNT, VRPErrorControlParametersFields.ConsentControlFields.MAX_INDIVIDUAL_AMOUNT);
}
}
use of com.forgerock.openbanking.exceptions.OBErrorException in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentsApiEndpointWrapper method verifyContentTypeHeader.
public void verifyContentTypeHeader(String contentTypeHeader) throws OBErrorException {
// Check the file content-type header is compatible with the consent type
MediaType consentContentType = consent.getFileType().getContentType();
log.debug("Consent indicates file content-type of: '{}'. Actual content-type header of submitted file: '{}'", consent.getFileType().getContentType(), contentTypeHeader);
if (!consentContentType.isCompatibleWith(MediaType.parseMediaType(contentTypeHeader))) {
log.warn("Content type header '{}' for payment file consent does not match the specified file type: '{}'. Expected content-type: {}", consentContentType, consent.getFileType(), consentContentType);
throw new OBErrorException(OBRIErrorType.REQUEST_MEDIA_TYPE_NOT_ACCEPTABLE, consentContentType);
}
log.debug("File content type is correct for consent id: ", consent.getId());
}
use of com.forgerock.openbanking.exceptions.OBErrorException in project openbanking-aspsp by OpenBankingToolkit.
the class Psd2WithSessionApiHelperService method getPsuNameFromSession.
public String getPsuNameFromSession(String obriSession) throws OBErrorException {
try {
SignedJWT session = cryptoApiClient.decryptJwe(obriSession);
String psuName = session.getJWTClaimsSet().getSubject();
return psuName;
} catch (Exception e) {
log.info("getPsuNameFromSession() caught exception getting psu name from session '{};", obriSession, e);
}
throw new OBErrorException(OBRIErrorType.SESSION_TOKEN_INVALID_FORMAT);
}
use of com.forgerock.openbanking.exceptions.OBErrorException in project openbanking-aspsp by OpenBankingToolkit.
the class AccessTokenService method verifyAccessTokenScopes.
public void verifyAccessTokenScopes(List<String> expectedScopes, SignedJWT accessToken) throws OBErrorException {
try {
List<String> scopes = getScopes(accessToken);
if (!scopes.containsAll(expectedScopes)) {
log.info("Access token did not contain expected scopes. Token scopes '{}' Expected scopes '{}'", scopes, expectedScopes);
throw new OBErrorException(OBRIErrorType.ACCESS_TOKEN_INVALID, "Did not contain the expected scopes");
}
log.debug("verifyAccessTokenScopes() accessToken contains expected scopes");
} catch (Exception e) {
throw new OBErrorException(OBRIErrorType.ACCESS_TOKEN_INVALID, "Access token did not contain valid " + "scopes");
}
}
Aggregations