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 */
019package org.apache.commons.compress.archivers.jar;
020
021import java.security.cert.Certificate;
022import java.util.jar.Attributes;
023import java.util.jar.JarEntry;
024import java.util.zip.ZipEntry;
025import java.util.zip.ZipException;
026
027import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
028
029/**
030 *
031 * @NotThreadSafe (parent is not thread-safe)
032 */
033public 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(final ZipEntry entry) throws ZipException {
040        super(entry);
041    }
042
043    public JarArchiveEntry(final String name) {
044        super(name);
045    }
046
047    public JarArchiveEntry(final ZipArchiveEntry entry) throws ZipException {
048        super(entry);
049    }
050
051    public JarArchiveEntry(final 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 // NOSONAR
078            final 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}