ClientCertRequest.java revision f271c8ecd02c415858e0497dc586d99d9dd96de5
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 */ 40public interface ClientCertRequest { 41 /** 42 * Returns the acceptable types of asymmetric keys (can be null). 43 */ 44 public String[] getKeyTypes(); 45 46 /** 47 * Returns the acceptable certificate issuers for the certificate 48 * matching the private key (can be null). 49 */ 50 public Principal[] getPrincipals(); 51 52 /** 53 * Returns the host name of the server requesting the certificate. 54 */ 55 public String getHost(); 56 57 /** 58 * Returns the port number of the server requesting the certificate. 59 */ 60 public int getPort(); 61 62 /** 63 * Proceed with the specified private key and client certificate chain. 64 * Remember the user's positive choice and use it for future requests. 65 */ 66 public void proceed(PrivateKey privateKey, X509Certificate[] chain); 67 68 /** 69 * Ignore the request for now. Do not remember user's choice. 70 */ 71 public void ignore(); 72 73 /** 74 * Cancel this request. Remember the user's choice and use it for 75 * future requests. 76 */ 77 public void cancel(); 78} 79