RecordingOkAuthenticator.java revision 3c938a3f6b61ce5e2dba0d039b03fe73b89fd26c
1/* 2 * Copyright (C) 2013 Square, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package com.squareup.okhttp.internal; 17 18import com.squareup.okhttp.OkAuthenticator; 19import java.io.IOException; 20import java.net.Proxy; 21import java.net.URL; 22import java.util.ArrayList; 23import java.util.List; 24 25public final class RecordingOkAuthenticator implements OkAuthenticator { 26 public final List<String> calls = new ArrayList<String>(); 27 public final Credential credential; 28 29 public RecordingOkAuthenticator(Credential credential) { 30 this.credential = credential; 31 } 32 33 @Override public Credential authenticate(Proxy proxy, URL url, List<Challenge> challenges) 34 throws IOException { 35 calls.add("authenticate" 36 + " proxy=" + proxy.type() 37 + " url=" + url 38 + " challenges=" + challenges); 39 return credential; 40 } 41 42 @Override public Credential authenticateProxy(Proxy proxy, URL url, List<Challenge> challenges) 43 throws IOException { 44 calls.add("authenticateProxy" 45 + " proxy=" + proxy.type() 46 + " url=" + url 47 + " challenges=" + challenges); 48 return credential; 49 } 50} 51