blob: 4c15df59d1511b85192ae7c1a5d18e538763ca42 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package java.util.jar;
27
28import java.io.IOException;
29import java.util.zip.ZipEntry;
30import java.security.CodeSigner;
31import java.security.cert.Certificate;
32
33/**
34 * This class is used to represent a JAR file entry.
35 */
36public
37class JarEntry extends ZipEntry {
38 Attributes attr;
39 Certificate[] certs;
40 CodeSigner[] signers;
41
42 /**
43 * Creates a new <code>JarEntry</code> for the specified JAR file
44 * entry name.
45 *
46 * @param name the JAR file entry name
47 * @exception NullPointerException if the entry name is <code>null</code>
48 * @exception IllegalArgumentException if the entry name is longer than
49 * 0xFFFF bytes.
50 */
51 public JarEntry(String name) {
52 super(name);
53 }
54
55 /**
56 * Creates a new <code>JarEntry</code> with fields taken from the
57 * specified <code>ZipEntry</code> object.
58 * @param ze the <code>ZipEntry</code> object to create the
59 * <code>JarEntry</code> from
60 */
61 public JarEntry(ZipEntry ze) {
62 super(ze);
63 }
64
65 /**
66 * Creates a new <code>JarEntry</code> with fields taken from the
67 * specified <code>JarEntry</code> object.
68 *
69 * @param je the <code>JarEntry</code> to copy
70 */
71 public JarEntry(JarEntry je) {
72 this((ZipEntry)je);
73 this.attr = je.attr;
74 this.certs = je.certs;
75 this.signers = je.signers;
76 }
77
78 /**
79 * Returns the <code>Manifest</code> <code>Attributes</code> for this
80 * entry, or <code>null</code> if none.
81 *
82 * @return the <code>Manifest</code> <code>Attributes</code> for this
83 * entry, or <code>null</code> if none
84 */
85 public Attributes getAttributes() throws IOException {
86 return attr;
87 }
88
89 /**
90 * Returns the <code>Certificate</code> objects for this entry, or
91 * <code>null</code> if none. This method can only be called once
92 * the <code>JarEntry</code> has been completely verified by reading
93 * from the entry input stream until the end of the stream has been
94 * reached. Otherwise, this method will return <code>null</code>.
95 *
96 * <p>The returned certificate array comprises all the signer certificates
97 * that were used to verify this entry. Each signer certificate is
98 * followed by its supporting certificate chain (which may be empty).
99 * Each signer certificate and its supporting certificate chain are ordered
100 * bottom-to-top (i.e., with the signer certificate first and the (root)
101 * certificate authority last).
102 *
103 * @return the <code>Certificate</code> objects for this entry, or
104 * <code>null</code> if none.
105 */
106 public Certificate[] getCertificates() {
107 return certs == null ? null : certs.clone();
108 }
109
110 /**
111 * Returns the <code>CodeSigner</code> objects for this entry, or
112 * <code>null</code> if none. This method can only be called once
113 * the <code>JarEntry</code> has been completely verified by reading
114 * from the entry input stream until the end of the stream has been
115 * reached. Otherwise, this method will return <code>null</code>.
116 *
117 * <p>The returned array comprises all the code signers that have signed
118 * this entry.
119 *
120 * @return the <code>CodeSigner</code> objects for this entry, or
121 * <code>null</code> if none.
122 *
123 * @since 1.5
124 */
125 public CodeSigner[] getCodeSigners() {
126 return signers == null ? null : signers.clone();
127 }
128}