ClientCertRequest.java revision b6aa97e0a0cd13846c148716fc0c7947422cea04
1/* 2 * Copyright (C) 2014 The Android Open Source Project 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 */ 16 17package android.webkit; 18 19import java.security.Principal; 20import java.security.PrivateKey; 21import java.security.cert.X509Certificate; 22 23/** 24 * ClientCertRequest: The user receives an instance of this class as 25 * a parameter of {@link WebViewClient#onReceivedClientCertRequest}. 26 * The request includes the parameters to choose the client certificate, 27 * such as the host name and the port number requesting the cert, the acceptable 28 * key types and the principals. 29 * 30 * The user should call one of the interface methods to indicate how to deal 31 * with the client certificate request. All methods should be called on 32 * UI thread. 33 * 34 * WebView caches the {@link #proceed} and {@link #cancel} responses in memory 35 * and uses them to handle future client certificate requests for the same 36 * host/port pair. The user can clear the cached data using 37 * {@link WebView#clearClientCertPreferences}. 38 * 39 * TODO(sgurun) unhide 40 * @hide 41 */ 42public interface ClientCertRequest { 43 /** 44 * Returns the acceptable types of asymmetric keys (can be null). 45 */ 46 public String[] getKeyTypes(); 47 48 /** 49 * Returns the acceptable certificate issuers for the certificate 50 * matching the private key (can be null). 51 */ 52 public Principal[] getPrincipals(); 53 54 /** 55 * Returns the host name of the server requesting the certificate. 56 */ 57 public String getHost(); 58 59 /** 60 * Returns the port number of the server requesting the certificate. 61 */ 62 public int getPort(); 63 64 /** 65 * Proceed with the specified private key and client certificate chain. 66 * Remember the user's positive choice and use it for future requests. 67 */ 68 public void proceed(PrivateKey privateKey, X509Certificate[] chain); 69 70 /** 71 * Ignore the request for now. Do not remember user's choice. 72 */ 73 public void ignore(); 74 75 /** 76 * Cancel this request. Remember the user's choice and use it for 77 * future requests. 78 */ 79 public void cancel(); 80} 81