use of org.wso2.carbon.apimgt.rest.integration.tests.store.auth.HttpBasicAuth 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!");
}
Aggregations