use of net.petafuel.styx.core.xs2a.entities.SCA in project styx by petafuel.
the class BasicAuthorisationService method startAuthorisation.
protected SCA startAuthorisation(StartAuthorisationRequest request) throws BankRequestFailedException {
this.setUrl(this.url + request.getServicePath());
this.createBody(RequestType.POST, JSON, request);
this.createHeaders(request);
try (Response response = this.execute();
Jsonb jsonb = JsonbBuilder.create()) {
String responseBody = extractResponseBody(response, 201);
SCA sca = jsonb.fromJson(responseBody, SCA.class);
SCAUtils.parseSCAApproach(sca, response);
return sca;
} catch (Exception e) {
throw new BankRequestFailedException(e.getMessage(), e);
}
}
use of net.petafuel.styx.core.xs2a.entities.SCA in project styx by petafuel.
the class BasicAuthorisationService method selectAuthenticationMethod.
protected SCA selectAuthenticationMethod(SelectAuthenticationMethodRequest selectAuthenticationMethodRequest) throws BankRequestFailedException {
this.setUrl(this.url + selectAuthenticationMethodRequest.getServicePath());
this.createBody(RequestType.PUT, JSON, selectAuthenticationMethodRequest);
this.createHeaders(selectAuthenticationMethodRequest);
try (Response response = this.execute();
Jsonb jsonb = JsonbBuilder.create()) {
String responseBody = extractResponseBody(response, 200);
SCA sca = jsonb.fromJson(responseBody, SCA.class);
SCAUtils.parseSCAApproach(sca, response);
return sca;
} catch (Exception e) {
throw new BankRequestFailedException(e.getMessage(), e);
}
}
use of net.petafuel.styx.core.xs2a.entities.SCA in project styx by petafuel.
the class BasicAuthorisationService method updatePSUIdentification.
protected SCA updatePSUIdentification(UpdatePSUIdentificationRequest updatePSUIdentificationRequest) throws BankRequestFailedException {
this.setUrl(this.url + updatePSUIdentificationRequest.getServicePath());
this.createBody(RequestType.PUT, JSON, updatePSUIdentificationRequest);
this.createHeaders(updatePSUIdentificationRequest);
try (Response response = this.execute();
Jsonb jsonb = JsonbBuilder.create()) {
String responseBody = extractResponseBody(response, 200);
SCA sca = jsonb.fromJson(responseBody, SCA.class);
SCAUtils.parseSCAApproach(sca, response);
return sca;
} catch (Exception e) {
throw new BankRequestFailedException(e.getMessage(), e);
}
}
use of net.petafuel.styx.core.xs2a.entities.SCA in project styx by petafuel.
the class BerlinGroupPIS method startAuthorisation.
@Override
public /*
* BerlinGroup 1.2: the authorisationId of an Authorisation Resource is not a json key in the start SCA Request
* Therefore we take it out of an authorisation link that contains this id
*/
SCA startAuthorisation(SCARequest xs2ARequest) throws BankRequestFailedException {
this.setUrl(this.url + xs2ARequest.getServicePath());
this.createBody(RequestType.POST, JSON, xs2ARequest);
this.createHeaders(xs2ARequest);
try (Response response = this.execute();
Jsonb jsonb = JsonbBuilder.create()) {
String responseBody = extractResponseBody(response, 201);
SCA sca = jsonb.fromJson(responseBody, SCA.class);
SCAUtils.parseSCAApproach(sca, response);
// extract the authorisation id out of an Href Object that contains the authorisations/... route
for (Map.Entry<LinkType, Links.Href> entry : sca.getLinks().getUrlMapping().entrySet()) {
if (entry.getValue().getUrl().contains("authorisations/")) {
String[] routeParts = entry.getValue().getUrl().split("/");
sca.setAuthorisationId(routeParts[routeParts.length - 1]);
break;
}
}
return sca;
} catch (Exception e) {
throw new BankRequestFailedException(e.getMessage(), e);
}
}
use of net.petafuel.styx.core.xs2a.entities.SCA in project styx by petafuel.
the class ConsentAuthorisationResource method startConsentAuthorisation.
/**
* Starts a consent authorisation
*
* @param consentId of the target consent
* @return a GetConsentResponse object
* @throws BankRequestFailedException if something went wrong between the core service and the aspsp
*/
@AcceptsPreStepAuth
@POST
@RequiresPSU
@Path("/consents/{consentId}/authorisations")
public Response startConsentAuthorisation(@NotEmpty @NotBlank @PathParam("consentId") String consentId, @Valid AuthorisationRequest authorisationRequest) throws BankRequestFailedException {
consentId = Sanitizer.replaceEscSeq(consentId);
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setConsentId(consentId);
xs2AFactoryInput.setPsuData(authorisationRequest.getPsuData());
IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
ioProcessor.modifyInput(xs2AFactoryInput);
SCARequest xs2AAuthorisationRequest = new SCARequestFactory().create(getXS2AStandard().getRequestClassProvider().scaStart(), xs2AFactoryInput);
xs2AAuthorisationRequest.getHeaders().putAll(getAdditionalHeaders());
if (getRedirectPreferred() != null) {
xs2AAuthorisationRequest.setTppRedirectPreferred(getRedirectPreferred());
}
ioProcessor.modifyRequest(xs2AAuthorisationRequest, xs2AFactoryInput);
SCA consentSCA = getXS2AStandard().getCs().startAuthorisation(xs2AAuthorisationRequest);
AspspUrlMapper aspspUrlMapper = new AspspUrlMapper(consentId, consentSCA.getAuthorisationId());
consentSCA.setLinks(aspspUrlMapper.map(consentSCA.getLinks()));
LOG.info("Consent Authorisation started for consentId={} scaStatus={} scaApproach={}", consentId, consentSCA.getScaStatus(), consentSCA.getApproach());
return Response.status(ResponseConstant.CREATED).entity(consentSCA).build();
}
Aggregations