001: /*
002: * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package java.net;
027:
028: import java.security.cert.Certificate;
029: import javax.net.ssl.SSLPeerUnverifiedException;
030: import java.security.Principal;
031: import java.util.List;
032:
033: /**
034: * Represents a cache response originally retrieved through secure
035: * means, such as TLS.
036: *
037: * @since 1.5
038: */
039: public abstract class SecureCacheResponse extends CacheResponse {
040: /**
041: * Returns the cipher suite in use on the original connection that
042: * retrieved the network resource.
043: *
044: * @return a string representing the cipher suite
045: */
046: public abstract String getCipherSuite();
047:
048: /**
049: * Returns the certificate chain that were sent to the server during
050: * handshaking of the original connection that retrieved the
051: * network resource. Note: This method is useful only
052: * when using certificate-based cipher suites.
053: *
054: * @return an immutable List of Certificate representing the
055: * certificate chain that was sent to the server. If no
056: * certificate chain was sent, null will be returned.
057: * @see #getLocalPrincipal()
058: */
059: public abstract List<Certificate> getLocalCertificateChain();
060:
061: /**
062: * Returns the server's certificate chain, which was established as
063: * part of defining the session in the original connection that
064: * retrieved the network resource, from cache. Note: This method
065: * can be used only when using certificate-based cipher suites;
066: * using it with non-certificate-based cipher suites, such as
067: * Kerberos, will throw an SSLPeerUnverifiedException.
068: *
069: * @return an immutable List of Certificate representing the server's
070: * certificate chain.
071: * @throws SSLPeerUnverifiedException if the peer is not verified.
072: * @see #getPeerPrincipal()
073: */
074: public abstract List<Certificate> getServerCertificateChain()
075: throws SSLPeerUnverifiedException;
076:
077: /**
078: * Returns the server's principal which was established as part of
079: * defining the session during the original connection that
080: * retrieved the network resource.
081: *
082: * @return the server's principal. Returns an X500Principal of the
083: * end-entity certiticate for X509-based cipher suites, and
084: * KerberosPrincipal for Kerberos cipher suites.
085: *
086: * @throws SSLPeerUnverifiedException if the peer was not verified.
087: *
088: * @see #getServerCertificateChain()
089: * @see #getLocalPrincipal()
090: */
091: public abstract Principal getPeerPrincipal()
092: throws SSLPeerUnverifiedException;
093:
094: /**
095: * Returns the principal that was sent to the server during
096: * handshaking in the original connection that retrieved the
097: * network resource.
098: *
099: * @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: }
|