Home | History | Annotate | Download | only in http
      1 /*
      2  * Copyright 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.net.http;
     18 
     19 import java.security.Principal;
     20 import java.security.cert.Certificate;
     21 import java.security.cert.X509Certificate;
     22 
     23 import javax.net.ssl.SSLPeerUnverifiedException;
     24 import javax.net.ssl.SSLSession;
     25 import javax.net.ssl.SSLSessionContext;
     26 import javax.net.ssl.SSLSocket;
     27 import javax.net.ssl.X509TrustManager;
     28 
     29 /**
     30  * This is only used when a {@code certificate} is available but usage
     31  * requires a {@link SSLSession}.
     32  *
     33  * @hide
     34  */
     35 public class DelegatingSSLSession implements SSLSession {
     36     protected DelegatingSSLSession() {
     37     }
     38 
     39     public static class CertificateWrap extends DelegatingSSLSession {
     40         private final Certificate mCertificate;
     41 
     42         public CertificateWrap(Certificate certificate) {
     43             mCertificate = certificate;
     44         }
     45 
     46         @Override
     47         public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException {
     48             return new Certificate[] { mCertificate };
     49         }
     50     }
     51 
     52 
     53     @Override
     54     public int getApplicationBufferSize() {
     55         throw new UnsupportedOperationException();
     56     }
     57 
     58     @Override
     59     public String getCipherSuite() {
     60         throw new UnsupportedOperationException();
     61     }
     62 
     63     @Override
     64     public long getCreationTime() {
     65         throw new UnsupportedOperationException();
     66     }
     67 
     68     @Override
     69     public byte[] getId() {
     70         throw new UnsupportedOperationException();
     71     }
     72 
     73     @Override
     74     public long getLastAccessedTime() {
     75         throw new UnsupportedOperationException();
     76     }
     77 
     78     @Override
     79     public Certificate[] getLocalCertificates() {
     80         throw new UnsupportedOperationException();
     81     }
     82 
     83     @Override
     84     public Principal getLocalPrincipal() {
     85         throw new UnsupportedOperationException();
     86     }
     87 
     88     @Override
     89     public int getPacketBufferSize() {
     90         throw new UnsupportedOperationException();
     91     }
     92 
     93     @Override
     94     public javax.security.cert.X509Certificate[] getPeerCertificateChain()
     95             throws SSLPeerUnverifiedException {
     96         throw new UnsupportedOperationException();
     97     }
     98 
     99     @Override
    100     public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException {
    101         throw new UnsupportedOperationException();
    102     }
    103 
    104     @Override
    105     public String getPeerHost() {
    106         throw new UnsupportedOperationException();
    107     }
    108 
    109     @Override
    110     public int getPeerPort() {
    111         throw new UnsupportedOperationException();
    112     }
    113 
    114     @Override
    115     public Principal getPeerPrincipal() throws SSLPeerUnverifiedException {
    116         throw new UnsupportedOperationException();
    117     }
    118 
    119     @Override
    120     public String getProtocol() {
    121         throw new UnsupportedOperationException();
    122     }
    123 
    124     @Override
    125     public SSLSessionContext getSessionContext() {
    126         throw new UnsupportedOperationException();
    127     }
    128 
    129     @Override
    130     public Object getValue(String name) {
    131         throw new UnsupportedOperationException();
    132     }
    133 
    134     @Override
    135     public String[] getValueNames() {
    136         throw new UnsupportedOperationException();
    137     }
    138 
    139     @Override
    140     public void invalidate() {
    141         throw new UnsupportedOperationException();
    142     }
    143 
    144     @Override
    145     public boolean isValid() {
    146         throw new UnsupportedOperationException();
    147     }
    148 
    149     @Override
    150     public void putValue(String name, Object value) {
    151         throw new UnsupportedOperationException();
    152     }
    153 
    154     @Override
    155     public void removeValue(String name) {
    156         throw new UnsupportedOperationException();
    157     }
    158 }
    159