use of com.pushtorefresh.storio3.Interceptor in project azure-iot-sdk-java by Azure.
the class ServiceClientCredentialsProvider method applyCredentialsFilter.
@Override
public void applyCredentialsFilter(OkHttpClient.Builder clientBuilder) {
Interceptor authenticationInterceptor = chain -> {
Request authenticatedRequest = chain.request().newBuilder().header(AUTHORIZATION, sasTokenProvider.getSasToken()).build();
return chain.proceed(authenticatedRequest);
};
clientBuilder.interceptors().add(authenticationInterceptor);
}
use of com.pushtorefresh.storio3.Interceptor in project azure-iot-sdk-java by Azure.
the class ServiceClientBearerTokenCredentialProvider method applyCredentialsFilter.
@Override
public void applyCredentialsFilter(OkHttpClient.Builder clientBuilder) {
Interceptor authenticationInterceptor = chain -> {
String authorizationValue = tokenProvider.getBearerToken();
Request authenticatedRequest = chain.request().newBuilder().header(AUTHORIZATION, authorizationValue).build();
return chain.proceed(authenticatedRequest);
};
clientBuilder.interceptors().add(authenticationInterceptor);
}
use of com.pushtorefresh.storio3.Interceptor in project BigImageViewer by Piasy.
the class GlideProgressSupport method createInterceptor.
private static Interceptor createInterceptor(final ResponseProgressListener listener) {
return new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Response response = chain.proceed(request);
return response.newBuilder().body(new OkHttpProgressResponseBody(request.url(), response.body(), listener)).build();
}
};
}
use of com.pushtorefresh.storio3.Interceptor in project storio by pushtorefresh.
the class ChainImpl method proceed.
// can be null on PreparedGetObject
@Nullable
@Override
public <Result, WrappedResult, Data> Result proceed(@NonNull PreparedOperation<Result, WrappedResult, Data> operation) {
if (!interceptors.hasNext()) {
throw new IllegalStateException("proceed was called on empty iterator");
}
calls++;
// Confirm that this is the only call to chain.proceed().
if (calls > 1) {
throw new IllegalStateException("nextInterceptor " + interceptors.previous() + " must call proceed() exactly once");
}
// Call the nextChain nextInterceptor in the chain.
final Interceptor nextInterceptor = interceptors.next();
final ChainImpl nextChain = new ChainImpl(interceptors);
return nextInterceptor.intercept(operation, nextChain);
}
use of com.pushtorefresh.storio3.Interceptor in project storio by pushtorefresh.
the class ChainImpl method buildChain.
@NonNull
public static Interceptor.Chain buildChain(@NonNull List<Interceptor> registeredInterceptors, @NonNull Interceptor realInterceptor) {
final List<Interceptor> interceptors = new ArrayList<Interceptor>(registeredInterceptors.size() + 1);
interceptors.addAll(registeredInterceptors);
interceptors.add(realInterceptor);
for (Interceptor interceptor : interceptors) {
if (interceptor == null) {
throw new IllegalArgumentException("Interceptor should not be null");
}
}
return new ChainImpl(interceptors.listIterator());
}
Aggregations