Search in sources :

Example 1 with PreAuthResponse

use of net.petafuel.styx.api.v1.preauth.entity.PreAuthResponse in project styx by petafuel.

the class SinglePaymentWithPreAuthSparda method fetchPreStepUrl.

@Test
@Category(IntegrationTest.class)
public void fetchPreStepUrl() {
    Invocation.Builder invocationBuilder = target("/v1/preauth").request();
    invocationBuilder.header("token", pisAccessToken);
    invocationBuilder.header("PSU-BIC", BIC);
    invocationBuilder.header("scope", "pis");
    Invocation invocation = invocationBuilder.buildPost(null);
    Response response = invocation.invoke(Response.class);
    PreAuthResponse preAuthResponse = response.readEntity(PreAuthResponse.class);
    Assert.assertEquals(200, response.getStatus());
    System.out.println(preAuthResponse.getLinks().getAuthorizationEndpoint().getUrl());
}
Also used : Response(javax.ws.rs.core.Response) PreAuthResponse(net.petafuel.styx.api.v1.preauth.entity.PreAuthResponse) PreAuthResponse(net.petafuel.styx.api.v1.preauth.entity.PreAuthResponse) Invocation(javax.ws.rs.client.Invocation) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest)

Example 2 with PreAuthResponse

use of net.petafuel.styx.api.v1.preauth.entity.PreAuthResponse in project styx by petafuel.

the class PreAuthResource method preAuthenticate.

/**
 * Starts an OAuth sessions and returns the preauthId and the link to the authorization page
 * Relevant only for ASPSPs which support/require a preauth in order to access their XS2A interface
 *
 * @return 200 if successful
 */
@RequiresBIC
@CheckAccessToken(allowedServices = { XS2ATokenType.AIS, XS2ATokenType.PIS, XS2ATokenType.AISPIS, XS2ATokenType.PIIS })
@POST
@Path("/preauth")
public Response preAuthenticate(@NotEmpty @NotBlank @HeaderParam("scope") String scope) {
    Url url;
    if (Boolean.TRUE.equals(WebServer.isSandbox())) {
        url = getXS2AStandard().getAspsp().getSandboxUrl();
    } else {
        url = getXS2AStandard().getAspsp().getProductionUrl();
    }
    OAuthSession oAuthSession = OAuthService.startPreAuthSession(url, scope);
    String state = oAuthSession.getState();
    String link = OAuthService.buildLink(state, getXS2AStandard().getAspsp().getBic());
    Links links = new Links();
    links.setAuthorizationEndpoint(new Links.Href(link, LinkType.AUTHORIZATION_ENDPOINT));
    PreAuthResponse response = new PreAuthResponse(oAuthSession.getId().toString(), links);
    LOG.info("Successfully started pre-step Authentication within OAuthSession state={}", state);
    return Response.status(ResponseConstant.OK).entity(response).build();
}
Also used : PreAuthResponse(net.petafuel.styx.api.v1.preauth.entity.PreAuthResponse) PersistentOAuthSession(net.petafuel.styx.core.persistence.layers.PersistentOAuthSession) OAuthSession(net.petafuel.styx.core.xs2a.oauth.entities.OAuthSession) Links(net.petafuel.styx.core.xs2a.entities.Links) Url(net.petafuel.styx.core.banklookup.sad.entities.Url) Path(javax.ws.rs.Path) ApplicationPath(javax.ws.rs.ApplicationPath) CheckAccessToken(net.petafuel.styx.api.filter.authentication.boundary.CheckAccessToken) POST(javax.ws.rs.POST) RequiresBIC(net.petafuel.styx.api.filter.input.boundary.RequiresBIC)

Aggregations

PreAuthResponse (net.petafuel.styx.api.v1.preauth.entity.PreAuthResponse)2 ApplicationPath (javax.ws.rs.ApplicationPath)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Invocation (javax.ws.rs.client.Invocation)1 Response (javax.ws.rs.core.Response)1 IntegrationTest (net.petafuel.styx.api.IntegrationTest)1 StyxRESTTest (net.petafuel.styx.api.StyxRESTTest)1 CheckAccessToken (net.petafuel.styx.api.filter.authentication.boundary.CheckAccessToken)1 RequiresBIC (net.petafuel.styx.api.filter.input.boundary.RequiresBIC)1 Url (net.petafuel.styx.core.banklookup.sad.entities.Url)1 PersistentOAuthSession (net.petafuel.styx.core.persistence.layers.PersistentOAuthSession)1 Links (net.petafuel.styx.core.xs2a.entities.Links)1 OAuthSession (net.petafuel.styx.core.xs2a.oauth.entities.OAuthSession)1 Test (org.junit.Test)1 Category (org.junit.experimental.categories.Category)1