1. /*
  2. * @(#)JarEntry.java 1.21 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.util.jar;
  8. import java.io.IOException;
  9. import java.util.zip.ZipEntry;
  10. import java.security.CodeSigner;
  11. import java.security.cert.Certificate;
  12. /**
  13. * This class is used to represent a JAR file entry.
  14. */
  15. public
  16. class JarEntry extends ZipEntry {
  17. Attributes attr;
  18. Certificate[] certs;
  19. CodeSigner[] signers;
  20. /**
  21. * Creates a new <code>JarEntry</code> for the specified JAR file
  22. * entry name.
  23. *
  24. * @param name the JAR file entry name
  25. * @exception NullPointerException if the entry name is <code>null</code>
  26. * @exception IllegalArgumentException if the entry name is longer than
  27. * 0xFFFF bytes.
  28. */
  29. public JarEntry(String name) {
  30. super(name);
  31. }
  32. /**
  33. * Creates a new <code>JarEntry</code> with fields taken from the
  34. * specified <code>ZipEntry</code> object.
  35. * @param ze the <code>ZipEntry</code> object to create the
  36. * <code>JarEntry</code> from
  37. */
  38. public JarEntry(ZipEntry ze) {
  39. super(ze);
  40. }
  41. /**
  42. * Creates a new <code>JarEntry</code> with fields taken from the
  43. * specified <code>JarEntry</code> object.
  44. *
  45. * @param je the <code>JarEntry</code> to copy
  46. */
  47. public JarEntry(JarEntry je) {
  48. this((ZipEntry)je);
  49. this.attr = je.attr;
  50. this.certs = je.certs;
  51. this.signers = je.signers;
  52. }
  53. /**
  54. * Returns the <code>Manifest</code> <code>Attributes</code> for this
  55. * entry, or <code>null</code> if none.
  56. *
  57. * @return the <code>Manifest</code> <code>Attributes</code> for this
  58. * entry, or <code>null</code> if none
  59. */
  60. public Attributes getAttributes() throws IOException {
  61. return attr;
  62. }
  63. /**
  64. * Returns the <code>Certificate</code> objects for this entry, or
  65. * <code>null</code> if none. This method can only be called once
  66. * the <code>JarEntry</code> has been completely verified by reading
  67. * from the entry input stream until the end of the stream has been
  68. * reached. Otherwise, this method will return <code>null</code>.
  69. *
  70. * <p>The returned certificate array comprises all the signer certificates
  71. * that were used to verify this entry. Each signer certificate is
  72. * followed by its supporting certificate chain (which may be empty).
  73. * Each signer certificate and its supporting certificate chain are ordered
  74. * bottom-to-top (i.e., with the signer certificate first and the (root)
  75. * certificate authority last).
  76. *
  77. * @return the <code>Certificate</code> objects for this entry, or
  78. * <code>null</code> if none.
  79. */
  80. public Certificate[] getCertificates() {
  81. return certs;
  82. }
  83. /**
  84. * Returns the <code>CodeSigner</code> objects for this entry, or
  85. * <code>null</code> if none. This method can only be called once
  86. * the <code>JarEntry</code> has been completely verified by reading
  87. * from the entry input stream until the end of the stream has been
  88. * reached. Otherwise, this method will return <code>null</code>.
  89. *
  90. * <p>The returned array comprises all the code signers that have signed
  91. * this entry.
  92. *
  93. * @return the <code>CodeSigner</code> objects for this entry, or
  94. * <code>null</code> if none.
  95. *
  96. * @since 1.5
  97. */
  98. public CodeSigner[] getCodeSigners() {
  99. return signers;
  100. }
  101. }