use of net.petafuel.styx.api.v1.consent.entity.POSTConsentResponse in project styx by petafuel.
the class CreateConsentResource method createConsent.
/**
* Creates a consent Resource on the target aspsp xs2a interface
*
* @param postConsentRequest must contain recurringIndicator and the AccountAccess
* @return returns SCA related data for the consent authorisation
* @throws BankRequestFailedException in case something goes wrong while communicating to the ASPSP interface
*/
@RequiresMandatoryHeader
@AcceptsPreStepAuth
@POST
@Path("/consents")
public Response createConsent(@Valid @NotNull POSTConsentRequest postConsentRequest) throws BankRequestFailedException {
Consent requestConsent = new Consent();
requestConsent.setCombinedServiceIndicator(false);
requestConsent.setRecurringIndicator(postConsentRequest.isRecurringIndicator());
requestConsent.setFrequencyPerDay(4);
requestConsent.setAccess(postConsentRequest.getAccess());
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setConsent(requestConsent);
xs2AFactoryInput.setPsu(getPsu());
IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
ioProcessor.modifyInput(xs2AFactoryInput);
AISRequest xs2ARequest = new AISRequestFactory().create(getXS2AStandard().getRequestClassProvider().consentCreation(), xs2AFactoryInput);
xs2ARequest.getHeaders().putAll(getAdditionalHeaders());
xs2ARequest.setTppRedirectPreferred(getRedirectPreferred());
ioProcessor.modifyRequest(xs2ARequest, xs2AFactoryInput);
Consent consent = getXS2AStandard().getCs().createConsent(xs2ARequest);
POSTConsentResponse postConsentResponse = new POSTConsentResponse();
postConsentResponse.setConsentId(consent.getId());
postConsentResponse.setAspspScaApproach(consent.getSca().getApproach());
postConsentResponse.setPsuMessage(consent.getPsuMessage());
postConsentResponse.setLinks(consent.getLinks());
SCAApproach approach = SCAHandler.decision(consent);
if (approach instanceof OAuth2) {
postConsentResponse.getLinks().getScaOAuth().setUrl(((OAuth2) approach).getAuthoriseLink());
}
AspspUrlMapper aspspUrlMapper = new AspspUrlMapper(consent.getId(), null);
postConsentResponse.setLinks(aspspUrlMapper.map(postConsentResponse.getLinks()));
LOG.info("Created new AIS consent for bic={}", getXS2AStandard().getAspsp().getBic());
return Response.status(Response.Status.CREATED).entity(postConsentResponse).build();
}
use of net.petafuel.styx.api.v1.consent.entity.POSTConsentResponse in project styx by petafuel.
the class ConsentResourcesConsorsTest method A_createConsentTest.
@Override
@Test
@Category(IntegrationTest.class)
public void A_createConsentTest() throws IOException {
Response response = createConsentEndpoint();
Assertions.assertEquals(201, response.getStatus());
POSTConsentResponse consentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), POSTConsentResponse.class);
Assertions.assertNotNull(consentResponse.getConsentId());
Assertions.assertNotNull(consentResponse.getAspspScaApproach());
Assertions.assertNotNull(consentResponse.getLinks());
Response validateConsent = ClientBuilder.newClient().target(consentResponse.getLinks().getScaRedirect().getUrl() + "?psu-id=" + getPsuId()).request().buildGet().invoke();
Assertions.assertTrue(validateConsent.readEntity(String.class).contains("valid"));
consentId = consentResponse.getConsentId();
}
use of net.petafuel.styx.api.v1.consent.entity.POSTConsentResponse in project styx by petafuel.
the class ConsentResourcesFiduciaTest method A_createConsentTest.
@Override
@Test
@Category(IntegrationTest.class)
public void A_createConsentTest() throws IOException {
Response response = createConsentEndpoint();
Assertions.assertEquals(201, response.getStatus());
POSTConsentResponse consentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), POSTConsentResponse.class);
Assertions.assertNotNull(consentResponse.getConsentId());
Assertions.assertNotNull(consentResponse.getAspspScaApproach());
Assertions.assertNotNull(consentResponse.getLinks());
consentId = consentResponse.getConsentId();
}
use of net.petafuel.styx.api.v1.consent.entity.POSTConsentResponse in project styx by petafuel.
the class ConsentResourcesTargoTest method A_createConsentTest.
@Override
@Test
@Category(IntegrationTest.class)
public void A_createConsentTest() throws IOException {
Response response = createConsentEndpoint();
Assertions.assertEquals(201, response.getStatus());
POSTConsentResponse consentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), POSTConsentResponse.class);
Assertions.assertNotNull(consentResponse.getConsentId());
Assertions.assertNotNull(consentResponse.getAspspScaApproach());
Assertions.assertNotNull(consentResponse.getLinks());
consentId = consentResponse.getConsentId();
}
use of net.petafuel.styx.api.v1.consent.entity.POSTConsentResponse in project styx by petafuel.
the class ConsentResourcesSparkasseTest method A_createConsentTest.
@Override
@Test
@Category(IntegrationTest.class)
public void A_createConsentTest() throws IOException {
Response response = createConsentEndpoint();
Assertions.assertEquals(201, response.getStatus());
POSTConsentResponse consentResponse = jsonb.fromJson(IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8), POSTConsentResponse.class);
Assertions.assertNotNull(consentResponse.getConsentId());
Assertions.assertNotNull(consentResponse.getAspspScaApproach());
Assertions.assertNotNull(consentResponse.getLinks());
consentId = consentResponse.getConsentId();
}
Aggregations