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