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