Search in sources :

Example 1 with AccessTokenService

use of net.petafuel.styx.core.xs2a.standards.ing.v1_0.services.AccessTokenService in project tesb-rt-se by Talend.

the class OAuthManagerApplication method getSingletons.

@Override
public Set<Object> getSingletons() {
    Set<Object> classes = new HashSet<Object>();
    ThirdPartyRegistrationService thirdPartyService = new ThirdPartyRegistrationService();
    thirdPartyService.setDataProvider(manager);
    AccessTokenService ats = new AccessTokenService();
    ats.setDataProvider(manager);
    classes.add(thirdPartyService);
    classes.add(ats);
    return classes;
}
Also used : ThirdPartyRegistrationService(oauth2.manager.ThirdPartyRegistrationService) AccessTokenService(org.apache.cxf.rs.security.oauth2.services.AccessTokenService) HashSet(java.util.HashSet)

Example 2 with AccessTokenService

use of net.petafuel.styx.core.xs2a.standards.ing.v1_0.services.AccessTokenService in project styx by petafuel.

the class STYX09 method generateINGAccessToken.

public void generateINGAccessToken(String url) {
    AccessTokenService service = new AccessTokenService();
    AccessTokenRequest request = new AccessTokenRequest();
    try {
        AccessToken retrievedAccessToken = service.tokenRequest(url + "/oauth2/token", request);
        // give a tolerance of 30 seconds to the expiry date in case of any software
        // related delays
        this.accessTokenValidUntil = Instant.now().plusSeconds((retrievedAccessToken.getExpiresIn() - 30));
        this.accessToken = retrievedAccessToken;
    } catch (BankRequestFailedException e) {
        LOG.error("Error getting ing access token:", e);
        ResponseEntity responseEntity = new ResponseEntity("Generating ING access token failed", ResponseConstant.INTERNAL_SERVER_ERROR, ResponseCategory.ERROR, ResponseOrigin.STYX);
        throw new StyxException(responseEntity);
    }
}
Also used : ResponseEntity(net.petafuel.styx.api.exception.ResponseEntity) AccessTokenService(net.petafuel.styx.core.xs2a.standards.ing.v1_0.services.AccessTokenService) AccessToken(net.petafuel.styx.core.xs2a.standards.ing.v1_0.entities.AccessToken) AccessTokenRequest(net.petafuel.styx.core.xs2a.standards.ing.v1_0.http.AccessTokenRequest) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException) StyxException(net.petafuel.styx.api.exception.StyxException)

Aggregations

HashSet (java.util.HashSet)1 ResponseEntity (net.petafuel.styx.api.exception.ResponseEntity)1 StyxException (net.petafuel.styx.api.exception.StyxException)1 BankRequestFailedException (net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)1 AccessToken (net.petafuel.styx.core.xs2a.standards.ing.v1_0.entities.AccessToken)1 AccessTokenRequest (net.petafuel.styx.core.xs2a.standards.ing.v1_0.http.AccessTokenRequest)1 AccessTokenService (net.petafuel.styx.core.xs2a.standards.ing.v1_0.services.AccessTokenService)1 ThirdPartyRegistrationService (oauth2.manager.ThirdPartyRegistrationService)1 AccessTokenService (org.apache.cxf.rs.security.oauth2.services.AccessTokenService)1