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;
}
}
}
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;
}
}
}
use of feign.RequestInterceptor in project product-apim by wso2.
the class ApiClient method setCredentials.
/**
* Helper method to configure the username/password for basic auth or password OAuth
*
* @param username Username
* @param password Password
*/
public void setCredentials(String username, String password) {
for (RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
if (apiAuthorization instanceof HttpBasicAuth) {
HttpBasicAuth basicAuth = (HttpBasicAuth) apiAuthorization;
basicAuth.setCredentials(username, password);
return;
}
if (apiAuthorization instanceof OAuth) {
OAuth oauth = (OAuth) apiAuthorization;
oauth.getTokenRequestBuilder().setUsername(username).setPassword(password);
return;
}
}
throw new RuntimeException("No Basic authentication or OAuth configured!");
}
use of feign.RequestInterceptor in project product-apim by wso2.
the class ApiClient method setApiKey.
/**
* Helper method to configure the first api key found
*
* @param apiKey API key
*/
public void setApiKey(String apiKey) {
for (RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
if (apiAuthorization instanceof ApiKeyAuth) {
ApiKeyAuth keyAuth = (ApiKeyAuth) apiAuthorization;
keyAuth.setApiKey(apiKey);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
}
use of feign.RequestInterceptor in project product-apim by wso2.
the class ApiClient method setApiKey.
/**
* Helper method to configure the first api key found
*
* @param apiKey API key
*/
public void setApiKey(String apiKey) {
for (RequestInterceptor apiAuthorization : apiAuthorizations.values()) {
if (apiAuthorization instanceof ApiKeyAuth) {
ApiKeyAuth keyAuth = (ApiKeyAuth) apiAuthorization;
keyAuth.setApiKey(apiKey);
return;
}
}
throw new RuntimeException("No API key authentication configured!");
}
Aggregations