001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     * http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    package org.apache.commons.compress.archivers.jar;
020    
021    import java.security.cert.Certificate;
022    import java.util.jar.Attributes;
023    import java.util.jar.JarEntry;
024    import java.util.zip.ZipEntry;
025    import java.util.zip.ZipException;
026    
027    import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
028    
029    /**
030     *
031     * @NotThreadSafe (parent is not thread-safe)
032     */
033    public class JarArchiveEntry extends ZipArchiveEntry {
034    
035        // These are always null - see https://issues.apache.org/jira/browse/COMPRESS-18 for discussion
036        private final Attributes manifestAttributes = null;
037        private final Certificate[] certificates = null;
038    
039        public JarArchiveEntry(ZipEntry entry) throws ZipException {
040            super(entry);
041        }
042    
043        public JarArchiveEntry(String name) {
044            super(name);
045        }
046    
047        public JarArchiveEntry(ZipArchiveEntry entry) throws ZipException {
048            super(entry);
049        }
050    
051        public JarArchiveEntry(JarEntry entry) throws ZipException {
052            super(entry);
053    
054        }
055    
056        /**
057         * This method is not implemented and won't ever be.
058         * The JVM equivalent has a different name {@link java.util.jar.JarEntry#getAttributes()}
059         *
060         * @deprecated since 1.5, do not use; always returns null
061         * @return Always returns null.
062         */
063        @Deprecated
064        public Attributes getManifestAttributes() {
065            return manifestAttributes;
066        }
067    
068        /**
069         * Return a copy of the list of certificates or null if there are none.
070         *
071         * @return Always returns null in the current implementation
072         *
073         * @deprecated since 1.5, not currently implemented
074         */
075        @Deprecated
076        public Certificate[] getCertificates() {
077            if (certificates != null) { // never true currently
078                Certificate[] certs = new Certificate[certificates.length];
079                System.arraycopy(certificates, 0, certs, 0, certs.length);
080                return certs;
081            }
082            /*
083             * Note, the method
084             * Certificate[] java.util.jar.JarEntry.getCertificates()
085             * also returns null or the list of certificates (but not copied)
086             */
087            return null;
088        }
089    
090        @Override
091        public boolean equals(Object o) {
092            return super.equals(o);
093        }
094    
095        @Override
096        public int hashCode() {
097            return super.hashCode();
098        }
099    }