src/java.net.http/share/classes/jdk/internal/net/http/common/ImmutableSSLSession.java
author chegar
Wed, 02 May 2018 02:36:17 -0700
changeset 49944 4690a2871b44
parent 49765 ee6f7a61f3a5
child 54099 fd332722014c
permissions -rw-r--r--
8202423: Small HTTP Client refresh Reviewed-by: chegar, dfuchs, michaelm, prappo Contributed-by: Chris Hegarty <chris.hegarty@oracle.com>, Daniel Fuchs <daniel.fuchs@oracle.com>, Michael McMahon <michael.x.mcmahon@oracle.com>, Pavel Rappo <pavel.rappo@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49765
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
     1
/*
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
     4
 *
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    10
 *
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    15
 * accompanied this code).
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    16
 *
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    20
 *
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    23
 * questions.
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    24
 */
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    25
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    26
package jdk.internal.net.http.common;
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    27
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    28
import java.security.Principal;
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    29
import java.util.List;
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    30
import javax.net.ssl.SSLSession;
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    31
import javax.net.ssl.SSLSessionContext;
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    32
import javax.net.ssl.SSLPeerUnverifiedException;
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    33
import javax.net.ssl.SNIServerName;
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    34
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    35
/**
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    36
 * All mutating methods throw UnsupportedOperationException
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    37
 */
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    38
public class ImmutableSSLSession implements SSLSession {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    39
    private final SSLSession delegate;
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    40
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    41
    ImmutableSSLSession(SSLSession session) {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    42
        this.delegate = session;
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    43
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    44
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    45
    public byte[] getId() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    46
        return delegate.getId();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    47
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    48
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    49
    public SSLSessionContext getSessionContext() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    50
        return delegate.getSessionContext();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    51
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    52
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    53
    public long getCreationTime() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    54
        return delegate.getCreationTime();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    55
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    56
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    57
    public long getLastAccessedTime() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    58
        return delegate.getLastAccessedTime();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    59
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    60
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    61
    public void invalidate() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    62
        throw new UnsupportedOperationException("session is not mutable");
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    63
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    64
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    65
    public boolean isValid() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    66
        return delegate.isValid();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    67
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    68
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    69
    public void putValue(String name, Object value) {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    70
        throw new UnsupportedOperationException("session is not mutable");
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    71
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    72
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    73
    public Object getValue(String name) {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    74
        return delegate.getValue(name);
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    75
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    76
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    77
    public void removeValue(String name) {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    78
        throw new UnsupportedOperationException("session is not mutable");
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    79
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    80
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    81
    public String [] getValueNames() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    82
        return delegate.getValueNames();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    83
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    84
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    85
    public java.security.cert.Certificate [] getPeerCertificates()
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    86
            throws SSLPeerUnverifiedException {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    87
        return delegate.getPeerCertificates();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    88
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    89
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    90
    public java.security.cert.Certificate [] getLocalCertificates() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    91
        return delegate.getLocalCertificates();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    92
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    93
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    94
    @Deprecated
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    95
    public javax.security.cert.X509Certificate [] getPeerCertificateChain()
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    96
            throws SSLPeerUnverifiedException {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    97
        return delegate.getPeerCertificateChain();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    98
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
    99
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   100
    public Principal getPeerPrincipal()
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   101
            throws SSLPeerUnverifiedException {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   102
        return delegate.getPeerPrincipal();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   103
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   104
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   105
    public Principal getLocalPrincipal() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   106
        return delegate.getLocalPrincipal();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   107
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   108
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   109
    public String getCipherSuite() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   110
        return delegate.getCipherSuite();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   111
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   112
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   113
    public String getProtocol() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   114
        return delegate.getProtocol();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   115
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   116
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   117
    public String getPeerHost() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   118
        return delegate.getPeerHost();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   119
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   120
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   121
    public int getPeerPort() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   122
        return delegate.getPeerPort();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   123
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   124
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   125
    public int getPacketBufferSize() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   126
        return delegate.getPacketBufferSize();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   127
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   128
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   129
    public int getApplicationBufferSize() {
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   130
        return delegate.getApplicationBufferSize();
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   131
    }
ee6f7a61f3a5 8197564: HTTP Client implementation
chegar
parents:
diff changeset
   132
}