KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > util > jar > JarEntry


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
8 package java.util.jar;
9
10 import java.io.IOException JavaDoc;
11 import java.util.zip.ZipEntry JavaDoc;
12 import java.security.CodeSigner JavaDoc;
13 import java.security.cert.Certificate JavaDoc;
14
15 /**
16  * This class is used to represent a JAR file entry.
17  */

18 public
19 class JarEntry extends ZipEntry JavaDoc {
20     Attributes JavaDoc attr;
21     Certificate JavaDoc[] certs;
22     CodeSigner JavaDoc[] signers;
23
24     /**
25      * Creates a new <code>JarEntry</code> for the specified JAR file
26      * entry name.
27      *
28      * @param name the JAR file entry name
29      * @exception NullPointerException if the entry name is <code>null</code>
30      * @exception IllegalArgumentException if the entry name is longer than
31      * 0xFFFF bytes.
32      */

33     public JarEntry(String JavaDoc name) {
34     super(name);
35     }
36
37     /**
38      * Creates a new <code>JarEntry</code> with fields taken from the
39      * specified <code>ZipEntry</code> object.
40      * @param ze the <code>ZipEntry</code> object to create the
41      * <code>JarEntry</code> from
42      */

43     public JarEntry(ZipEntry JavaDoc ze) {
44     super(ze);
45     }
46
47     /**
48      * Creates a new <code>JarEntry</code> with fields taken from the
49      * specified <code>JarEntry</code> object.
50      *
51      * @param je the <code>JarEntry</code> to copy
52      */

53     public JarEntry(JarEntry JavaDoc je) {
54     this((ZipEntry JavaDoc)je);
55     this.attr = je.attr;
56     this.certs = je.certs;
57     this.signers = je.signers;
58     }
59
60     /**
61      * Returns the <code>Manifest</code> <code>Attributes</code> for this
62      * entry, or <code>null</code> if none.
63      *
64      * @return the <code>Manifest</code> <code>Attributes</code> for this
65      * entry, or <code>null</code> if none
66      */

67     public Attributes JavaDoc getAttributes() throws IOException JavaDoc {
68     return attr;
69     }
70
71     /**
72      * Returns the <code>Certificate</code> objects for this entry, or
73      * <code>null</code> if none. This method can only be called once
74      * the <code>JarEntry</code> has been completely verified by reading
75      * from the entry input stream until the end of the stream has been
76      * reached. Otherwise, this method will return <code>null</code>.
77      *
78      * <p>The returned certificate array comprises all the signer certificates
79      * that were used to verify this entry. Each signer certificate is
80      * followed by its supporting certificate chain (which may be empty).
81      * Each signer certificate and its supporting certificate chain are ordered
82      * bottom-to-top (i.e., with the signer certificate first and the (root)
83      * certificate authority last).
84      *
85      * @return the <code>Certificate</code> objects for this entry, or
86      * <code>null</code> if none.
87      */

88     public Certificate JavaDoc[] getCertificates() {
89     return certs;
90     }
91
92     /**
93      * Returns the <code>CodeSigner</code> objects for this entry, or
94      * <code>null</code> if none. This method can only be called once
95      * the <code>JarEntry</code> has been completely verified by reading
96      * from the entry input stream until the end of the stream has been
97      * reached. Otherwise, this method will return <code>null</code>.
98      *
99      * <p>The returned array comprises all the code signers that have signed
100      * this entry.
101      *
102      * @return the <code>CodeSigner</code> objects for this entry, or
103      * <code>null</code> if none.
104      *
105      * @since 1.5
106      */

107     public CodeSigner JavaDoc[] getCodeSigners() {
108     return signers;
109     }
110 }
111
Popular Tags