use of com.forgerock.openbanking.model.DirectorySoftwareStatement in project openbanking-aspsp by OpenBankingToolkit.
the class TppRegistrationService method updateTppMetrics.
private void updateTppMetrics(Tpp tpp, boolean isDeleted) {
log.debug("updateTppMetrics() creating metrics for Tpp {}. Is being {}", tpp.getClientId(), isDeleted ? "deleted" : "created");
TppEntry.TppEntryBuilder tppEntryBuilder = TppEntry.builder().created(new DateTime(tpp.getCreated())).deleted(isDeleted ? DateTime.now() : null).directoryId(tpp.getDirectoryId()).oidcClientId(tpp.getClientId()).logoUri(tpp.getLogo()).name(tpp.getName()).types(tpp.getTypes());
try {
DirectorySoftwareStatement ssaClaim = tpp.getDirectorySoftwareStatement();
tppEntryBuilder.softwareId(ssaClaim.getSoftware_id()).organisationId(ssaClaim.getOrg_id()).organisationName(ssaClaim.getOrg_name());
} catch (NullPointerException e) {
log.warn("Couldn't read TPP SSA, skipping SSA claims population to TPP entry for this TPP {}", tpp, e);
}
tppEntriesKPIService.pushTppEntry(tppEntryBuilder.build());
}
use of com.forgerock.openbanking.model.DirectorySoftwareStatement in project openbanking-aspsp by OpenBankingToolkit.
the class RegistrationRequestFactory method getRegistrationRequestFromManualRegistrationJson.
public RegistrationRequest getRegistrationRequestFromManualRegistrationJson(String registrationRequestJson, ManualRegistrationRequest manualRegistrationRequest, ObjectMapper objectMapper) throws DynamicClientRegistrationException {
String methodName = "getRegistrationRequestFromManualRegistrationJson()";
log.debug("{} called with regisratrationRequestJson; '{}', manualRegistrationRequest; '{}'", methodName, registrationRequestJson, manualRegistrationRequest);
try {
RegistrationRequest request = objectMapper.readValue(registrationRequestJson, RegistrationRequest.class);
request.setRedirectUris(manualRegistrationRequest.getRedirectUris());
String softwareStatementAssertion = manualRegistrationRequest.getSoftwareStatementAssertion();
if (StringUtils.isEmpty(softwareStatementAssertion)) {
String errorMessage = "Manual Request did not contain a valid software statement";
log.info("{} {}. registrationRequestJson is '{}'", methodName, errorMessage, registrationRequestJson);
throw new DynamicClientRegistrationException(errorMessage, DynamicClientRegistrationErrorType.INVALID_SOFTWARE_STATEMENT);
}
request.setSoftwareStatement(softwareStatementAssertion);
request.setJson(registrationRequestJson);
String ssaJwtSerialised = request.getSoftwareStatement();
RegistrationRequestJWTClaims softwareStatementClaims = getJwtClaimsSet(ssaJwtSerialised, JWTClaimsOrigin.SOFTWARE_STATEMENT_ASSERTION);
String issuer = softwareStatementClaims.getRequiredStringClaim(OpenBankingConstants.SSAClaims.ISSUER);
tppRegistrationService.validateSsaAgainstIssuingDirectoryJwksUri(ssaJwtSerialised, issuer);
DirectorySoftwareStatement regRequestSoftwareStatement = softwareStatementFactory.getSoftwareStatement(softwareStatementClaims);
request.setDirectorySoftwareStatement(regRequestSoftwareStatement);
log.debug("{}, returning registrationRequest; '{}'", methodName, request);
return request;
} catch (IOException | ParseException ioe) {
String errorMessage = "Could not map Manual Registration Request JWT fields to internal object";
log.info("{} {}", methodName, errorMessage, ioe);
throw new DynamicClientRegistrationException("Could not map registration request jwt fields to " + "internal object " + ioe.getMessage(), DynamicClientRegistrationErrorType.INVALID_CLIENT_METADATA);
}
}
use of com.forgerock.openbanking.model.DirectorySoftwareStatement in project openbanking-aspsp by OpenBankingToolkit.
the class RegistrationRequestFactory method getRegistrationRequestFromJwt.
public RegistrationRequest getRegistrationRequestFromJwt(String registrationRequestJwtSerialised) throws DynamicClientRegistrationException {
String methodName = "getRegistrationRequestFromJwt()";
try {
log.debug("{} called", methodName);
RegistrationRequestJWTClaims registrationRequestJWTClaims = getJwtClaimsSet(registrationRequestJwtSerialised, JWTClaimsOrigin.REGISTRATION_REQUEST_JWT);
String ssaJwtSerialised = registrationRequestJWTClaims.getRequiredStringClaim(RegistrationTppRequestClaims.SOFTWARE_STATEMENT);
RegistrationRequestJWTClaims ssaJwtClaims = getJwtClaimsSet(ssaJwtSerialised, JWTClaimsOrigin.SOFTWARE_STATEMENT_ASSERTION);
String issuer = ssaJwtClaims.getRequiredStringClaim(OpenBankingConstants.SSAClaims.ISSUER);
log.debug("{}, SSA issuer is '{}'", methodName, issuer);
tppRegistrationService.validateSsaAgainstIssuingDirectoryJwksUri(ssaJwtSerialised, issuer);
log.info("{}. SSA is valid and was issued by '{}'", methodName, issuer);
DirectorySoftwareStatement softwareStatement = softwareStatementFactory.getSoftwareStatement(ssaJwtClaims);
String softwareJwkUri = softwareStatement.getSoftware_jwks_endpoint();
String softwareClientId = ssaJwtClaims.getRequiredStringClaim(OpenBankingConstants.SSAClaims.SOFTWARE_CLIENT_ID);
tppRegistrationService.verifyTPPRegistrationRequestSignature(registrationRequestJwtSerialised, softwareClientId, softwareJwkUri);
Map<String, Object> registrationRequestClaimsAsJson = registrationRequestJWTClaims.toJSONObject();
String registrationRequestJson = JSONObjectUtils.toJSONString(registrationRequestClaimsAsJson);
try {
RegistrationRequest request = objectMapper.readValue(registrationRequestJson, RegistrationRequest.class);
request.setJson(registrationRequestJson);
request.setDirectorySoftwareStatement(softwareStatement);
return request;
} catch (IOException ioe) {
String errorMessage = "Could not map registration request jwt fields to internal object; " + ioe.getMessage();
log.info("{}; {} registrationRequestJson; '{}'", methodName, errorMessage, registrationRequestJson);
throw new DynamicClientRegistrationException(errorMessage, DynamicClientRegistrationErrorType.INVALID_CLIENT_METADATA);
}
} catch (ParseException pe) {
String errorMessage = "Could not parse the provided registration JWT";
log.info("{}; {} {}", methodName, errorMessage, registrationRequestJwtSerialised, pe);
throw new DynamicClientRegistrationException(errorMessage, DynamicClientRegistrationErrorType.INVALID_CLIENT_METADATA);
}
}
use of com.forgerock.openbanking.model.DirectorySoftwareStatement in project openbanking-aspsp by OpenBankingToolkit.
the class TppRegistrationServiceTest method shouldSucceedWhenSoftwareIdsMatch_verifyTPPRegistrationRequestAgainstSSA.
@Test
public void shouldSucceedWhenSoftwareIdsMatch_verifyTPPRegistrationRequestAgainstSSA() throws OBErrorException, OIDCException, DynamicClientRegistrationException {
// Given
DirectorySoftwareStatement directorySoftwareStatement = TestHelperFunctions.getValidFRDirectorySoftwareStatement();
RegistrationRequest regRequest = new RegistrationRequest();
regRequest.setSoftwareId(directorySoftwareStatement.getSoftware_client_id());
regRequest.setDirectorySoftwareStatement(directorySoftwareStatement);
// When
tppRegistrationService.verifyTPPRegistrationRequestAgainstSSA(regRequest);
// Then
}
use of com.forgerock.openbanking.model.DirectorySoftwareStatement in project openbanking-aspsp by OpenBankingToolkit.
the class TppRegistrationServiceTest method shouldSucceedWhenRequestRedirectUriInSsa_verifyTppRegistrationRequestAgainstSSA.
@Test
public void shouldSucceedWhenRequestRedirectUriInSsa_verifyTppRegistrationRequestAgainstSSA() throws OBErrorException, OIDCException, DynamicClientRegistrationException {
// Given
DirectorySoftwareStatement directorySoftwareStatement = TestHelperFunctions.getValidFRDirectorySoftwareStatement();
RegistrationRequest regRequest = new RegistrationRequest();
regRequest.setSoftwareId(directorySoftwareStatement.getSoftware_client_id());
regRequest.setRedirectUris(directorySoftwareStatement.getSoftware_redirect_uris());
regRequest.setSoftwareStatement(TestHelperFunctions.getValidSsaSerialised());
regRequest.setDirectorySoftwareStatement(directorySoftwareStatement);
// When
tppRegistrationService.verifyTPPRegistrationRequestAgainstSSA(regRequest);
// then
}
Aggregations