1. /*
  2. * @(#)SecureCacheResponse.java 1.1 03/09/22
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.net;
  8. import java.security.cert.Certificate;
  9. import javax.net.ssl.SSLPeerUnverifiedException;
  10. import java.security.Principal;
  11. import java.util.List;
  12. /**
  13. * Represents a cache response originally retrieved through secure
  14. * means, such as TLS.
  15. *
  16. * @since 1.5
  17. */
  18. public abstract class SecureCacheResponse extends CacheResponse {
  19. /**
  20. * Returns the cipher suite in use on the original connection that
  21. * retrieved the network resource.
  22. *
  23. * @return a string representing the cipher suite
  24. */
  25. public abstract String getCipherSuite();
  26. /**
  27. * Returns the certificate chain that were sent to the server during
  28. * handshaking of the original connection that retrieved the
  29. * network resource. Note: This method is useful only
  30. * when using certificate-based cipher suites.
  31. *
  32. * @return an immutable List of Certificate representing the
  33. * certificate chain that was sent to the server. If no
  34. * certificate chain was sent, null will be returned.
  35. * @see #getLocalPrincipal()
  36. */
  37. public abstract List<Certificate> getLocalCertificateChain();
  38. /**
  39. * Returns the server's certificate chain, which was established as
  40. * part of defining the session in the original connection that
  41. * retrieved the network resource, from cache. Note: This method
  42. * can be used only when using certificate-based cipher suites;
  43. * using it with non-certificate-based cipher suites, such as
  44. * Kerberos, will throw an SSLPeerUnverifiedException.
  45. *
  46. * @return an immutable List of Certificate representing the server's
  47. * certificate chain.
  48. * @throws SSLPeerUnverifiedException if the peer is not verified.
  49. * @see #getPeerPrincipal()
  50. */
  51. public abstract List<Certificate> getServerCertificateChain()
  52. throws SSLPeerUnverifiedException;
  53. /**
  54. * Returns the server's principal which was established as part of
  55. * defining the session during the original connection that
  56. * retrieved the network resource.
  57. *
  58. * @return the server's principal. Returns an X500Principal of the
  59. * end-entity certiticate for X509-based cipher suites, and
  60. * KerberosPrincipal for Kerberos cipher suites.
  61. *
  62. * @throws SSLPeerUnverifiedException if the peer was not verified.
  63. *
  64. * @see #getServerCertificateChain()
  65. * @see #getLocalPrincipal()
  66. */
  67. public abstract Principal getPeerPrincipal()
  68. throws SSLPeerUnverifiedException;
  69. /**
  70. * Returns the principal that was sent to the server during
  71. * handshaking in the original connection that retrieved the
  72. * network resource.
  73. *
  74. * @return the principal sent to the server. Returns an X500Principal
  75. * of the end-entity certificate for X509-based cipher suites, and
  76. * KerberosPrincipal for Kerberos cipher suites. If no principal was
  77. * sent, then null is returned.
  78. *
  79. * @see #getLocalCertificateChain()
  80. * @see #getPeerPrincipal()
  81. */
  82. public abstract Principal getLocalPrincipal();
  83. }