Search in sources :

Example 6 with RequestInterceptor

use of feign.RequestInterceptor in project product-apim by wso2.

the class ApiClient method setAccessToken.

/**
 * Helper method to pre-set the oauth access token of the first oauth found in the apiAuthorizations (there
 * should be only one)
 *
 * @param accessToken Access Token
 * @param expiresIn   Validity period in seconds
 */
public void setAccessToken(String accessToken, Long expiresIn) {
    for (RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
        if (apiAuthorization instanceof OAuth) {
            OAuth oauth = (OAuth) apiAuthorization;
            oauth.setAccessToken(accessToken, expiresIn);
            return;
        }
    }
}
Also used : RequestInterceptor(feign.RequestInterceptor) OAuth(org.wso2.carbon.apimgt.rest.integration.tests.store.auth.OAuth)

Example 7 with RequestInterceptor

use of feign.RequestInterceptor in project product-apim by wso2.

the class ApiClient method configureAuthorizationFlow.

/**
 * Helper method to configure the oauth accessCode/implicit flow parameters
 *
 * @param clientId     Client ID
 * @param clientSecret Client secret
 * @param redirectURI  Redirect URI
 */
public void configureAuthorizationFlow(String clientId, String clientSecret, String redirectURI) {
    for (RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
        if (apiAuthorization instanceof OAuth) {
            OAuth oauth = (OAuth) apiAuthorization;
            oauth.getTokenRequestBuilder().setClientId(clientId).setClientSecret(clientSecret).setRedirectURI(redirectURI);
            oauth.getAuthenticationRequestBuilder().setClientId(clientId).setRedirectURI(redirectURI);
            return;
        }
    }
}
Also used : RequestInterceptor(feign.RequestInterceptor) OAuth(org.wso2.carbon.apimgt.rest.integration.tests.store.auth.OAuth)

Example 8 with RequestInterceptor

use of feign.RequestInterceptor in project product-apim by wso2.

the class ApiClient method registerAccessTokenListener.

/**
 * Configures a listener which is notified when a new access token is received.
 *
 * @param accessTokenListener Acesss token listener
 */
public void registerAccessTokenListener(AccessTokenListener accessTokenListener) {
    for (RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
        if (apiAuthorization instanceof OAuth) {
            OAuth oauth = (OAuth) apiAuthorization;
            oauth.registerAccessTokenListener(accessTokenListener);
            return;
        }
    }
}
Also used : RequestInterceptor(feign.RequestInterceptor) OAuth(org.wso2.carbon.apimgt.rest.integration.tests.store.auth.OAuth)

Example 9 with RequestInterceptor

use of feign.RequestInterceptor in project product-apim by wso2.

the class HttpBasicAuth method apply.

@Override
public void apply(RequestTemplate template) {
    RequestInterceptor requestInterceptor = new BasicAuthRequestInterceptor(username, password);
    requestInterceptor.apply(template);
}
Also used : BasicAuthRequestInterceptor(feign.auth.BasicAuthRequestInterceptor) BasicAuthRequestInterceptor(feign.auth.BasicAuthRequestInterceptor) RequestInterceptor(feign.RequestInterceptor)

Example 10 with RequestInterceptor

use of feign.RequestInterceptor in project product-apim by wso2.

the class HttpBasicAuth method apply.

@Override
public void apply(RequestTemplate template) {
    RequestInterceptor requestInterceptor = new BasicAuthRequestInterceptor(username, password);
    requestInterceptor.apply(template);
}
Also used : BasicAuthRequestInterceptor(feign.auth.BasicAuthRequestInterceptor) BasicAuthRequestInterceptor(feign.auth.BasicAuthRequestInterceptor) RequestInterceptor(feign.RequestInterceptor)

Aggregations

RequestInterceptor (feign.RequestInterceptor)20 OAuth (org.wso2.carbon.apimgt.rest.integration.tests.store.auth.OAuth)4 BasicAuthRequestInterceptor (feign.auth.BasicAuthRequestInterceptor)3 RequestTemplate (feign.RequestTemplate)2 MockResponse (okhttp3.mockwebserver.MockResponse)2 Test (org.junit.Test)2 ApiKeyAuth (org.wso2.carbon.apimgt.rest.integration.tests.store.auth.ApiKeyAuth)1 HttpBasicAuth (org.wso2.carbon.apimgt.rest.integration.tests.store.auth.HttpBasicAuth)1