blob: 64fd41455612ef7cccfc1ff33e13aff6a94f14f1 [file] [log] [blame]
Rahul Ravikumar05336002019-10-14 15:04:32 -07001/*
2 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package java.net;
27
28import java.security.cert.Certificate;
29import javax.net.ssl.SSLPeerUnverifiedException;
30import java.security.Principal;
31import java.util.List;
32
33/**
34 * Represents a cache response originally retrieved through secure
35 * means, such as TLS.
36 *
37 * @since 1.5
38 */
39public abstract class SecureCacheResponse extends CacheResponse {
40 /**
41 * Returns the cipher suite in use on the original connection that
42 * retrieved the network resource.
43 *
44 * @return a string representing the cipher suite
45 */
46 public abstract String getCipherSuite();
47
48 /**
49 * Returns the certificate chain that were sent to the server during
50 * handshaking of the original connection that retrieved the
51 * network resource. Note: This method is useful only
52 * when using certificate-based cipher suites.
53 *
54 * @return an immutable List of Certificate representing the
55 * certificate chain that was sent to the server. If no
56 * certificate chain was sent, null will be returned.
57 * @see #getLocalPrincipal()
58 */
59 public abstract List<Certificate> getLocalCertificateChain();
60
61 /**
62 * Returns the server's certificate chain, which was established as
63 * part of defining the session in the original connection that
64 * retrieved the network resource, from cache. Note: This method
65 * can be used only when using certificate-based cipher suites;
66 * using it with non-certificate-based cipher suites, such as
67 * Kerberos, will throw an SSLPeerUnverifiedException.
68 *
69 * @return an immutable List of Certificate representing the server's
70 * certificate chain.
71 * @throws SSLPeerUnverifiedException if the peer is not verified.
72 * @see #getPeerPrincipal()
73 */
74 public abstract List<Certificate> getServerCertificateChain()
75 throws SSLPeerUnverifiedException;
76
77 /**
78 * Returns the server's principal which was established as part of
79 * defining the session during the original connection that
80 * retrieved the network resource.
81 *
82 * @return the server's principal. Returns an X500Principal of the
83 * end-entity certiticate for X509-based cipher suites, and
84 * KerberosPrincipal for Kerberos cipher suites.
85 *
86 * @throws SSLPeerUnverifiedException if the peer was not verified.
87 *
88 * @see #getServerCertificateChain()
89 * @see #getLocalPrincipal()
90 */
91 public abstract Principal getPeerPrincipal()
92 throws SSLPeerUnverifiedException;
93
94 /**
95 * Returns the principal that was sent to the server during
96 * handshaking in the original connection that retrieved the
97 * network resource.
98 *
99 * @return the principal sent to the server. Returns an X500Principal
100 * of the end-entity certificate for X509-based cipher suites, and
101 * KerberosPrincipal for Kerberos cipher suites. If no principal was
102 * sent, then null is returned.
103 *
104 * @see #getLocalCertificateChain()
105 * @see #getPeerPrincipal()
106 */
107 public abstract Principal getLocalPrincipal();
108}