CertificateFactorySpi.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* CertificateFactorySpi.java --- Certificate Factory Class
  2. Copyright (C) 1999 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.security.cert;
  32. import java.io.InputStream;
  33. import java.util.Collection;
  34. /**
  35. CertificateFactorySpi is the abstract class Service Provider
  36. Interface (SPI) for the CertificateFactory class. A provider
  37. must implment all the abstract methods if they wish to
  38. supply a certificate factory for a particular certificate
  39. type. Ex: X.509
  40. Certificate factories are used to generate certificates and
  41. certificate revocation lists (CRL) from their encoding.
  42. @since JDK 1.2
  43. @author Mark Benvenuto
  44. */
  45. public abstract class CertificateFactorySpi
  46. {
  47. /**
  48. Constructs a new CertificateFactorySpi
  49. */
  50. public CertificateFactorySpi()
  51. {}
  52. /**
  53. Generates a Certificate based on the encoded data read
  54. from the InputStream.
  55. The input stream must contain only one certificate.
  56. If there exists a specialized certificate class for the
  57. certificate format handled by the certificate factory
  58. then the return Ceritificate should be a typecast of it.
  59. Ex: A X.509 CertificateFactory should return X509Certificate.
  60. For X.509 certificates, the certificate in inStream must be
  61. DER encoded and supplied in binary or printable (Base64)
  62. encoding. If the certificate is in Base64 encoding, it must be
  63. bounded by -----BEGINCERTIFICATE-----, and
  64. -----END CERTIFICATE-----.
  65. @param inStream an input stream containing the certificate data
  66. @return a certificate initialized with InputStream data.
  67. @throws CertificateException Certificate parsing error
  68. */
  69. public abstract Certificate engineGenerateCertificate(InputStream inStream)
  70. throws CertificateException;
  71. /**
  72. Returns a collection of certificates that were read from the
  73. input stream. It may be empty, have only one, or have
  74. multiple certificates.
  75. For a X.509 certificate factory, the stream may contain a
  76. single DER encoded certificate or a PKCS#7 certificate
  77. chain. This is a PKCS#7 <I>SignedData</I> object with the
  78. most significant field being <I>certificates</I>. If no
  79. CRLs are present, then an empty collection is returned.
  80. @param inStream an input stream containing the certificates
  81. @return a collection of certificates initialized with
  82. the InputStream data.
  83. @throws CertificateException Certificate parsing error
  84. */
  85. public abstract Collection engineGenerateCertificates(InputStream inStream)
  86. throws CertificateException;
  87. /**
  88. Generates a CRL based on the encoded data read
  89. from the InputStream.
  90. The input stream must contain only one CRL.
  91. If there exists a specialized CRL class for the
  92. CRL format handled by the certificate factory
  93. then the return CRL should be a typecast of it.
  94. Ex: A X.509 CertificateFactory should return X509CRL.
  95. @param inStream an input stream containing the CRL data
  96. @return a CRL initialized with InputStream data.
  97. @throws CRLException CRL parsing error
  98. */
  99. public abstract CRL engineGenerateCRL(InputStream inStream)
  100. throws CRLException;
  101. /**
  102. Generates CRLs based on the encoded data read
  103. from the InputStream.
  104. For a X.509 certificate factory, the stream may contain a
  105. single DER encoded CRL or a PKCS#7 CRL set. This is a
  106. PKCS#7 <I>SignedData</I> object with the most significant
  107. field being <I>crls</I>. If no CRLs are present, then an
  108. empty collection is returned.
  109. @param inStream an input stream containing the CRLs
  110. @return a collection of CRLs initialized with
  111. the InputStream data.
  112. @throws CRLException CRL parsing error
  113. */
  114. public abstract Collection engineGenerateCRLs(InputStream inStream)
  115. throws CRLException;
  116. }