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.Arrays;
023import java.util.jar.Attributes;
024import java.util.jar.JarEntry;
025import java.util.zip.ZipEntry;
026import java.util.zip.ZipException;
027
028import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
029
030/**
031 *
032 * @NotThreadSafe (parent is not thread-safe)
033 */
034public class JarArchiveEntry extends ZipArchiveEntry {
035
036    // These are always null - see https://issues.apache.org/jira/browse/COMPRESS-18 for discussion
037    private final Attributes manifestAttributes = null;
038    private final Certificate[] certificates = null;
039
040    public JarArchiveEntry(final JarEntry entry) throws ZipException {
041        super(entry);
042
043    }
044
045    public JarArchiveEntry(final String name) {
046        super(name);
047    }
048
049    public JarArchiveEntry(final ZipArchiveEntry entry) throws ZipException {
050        super(entry);
051    }
052
053    public JarArchiveEntry(final ZipEntry entry) throws ZipException {
054        super(entry);
055    }
056
057    /**
058     * Return a copy of the list of certificates or null if there are none.
059     *
060     * @return Always returns null in the current implementation
061     *
062     * @deprecated since 1.5, not currently implemented
063     */
064    @Deprecated
065    public Certificate[] getCertificates() {
066        if (certificates != null) { // never true currently // NOSONAR
067            return Arrays.copyOf(certificates, certificates.length);
068        }
069        /*
070         * Note, the method
071         * Certificate[] java.util.jar.JarEntry.getCertificates()
072         * also returns null or the list of certificates (but not copied)
073         */
074        return null;
075    }
076
077    /**
078     * This method is not implemented and won't ever be.
079     * The JVM equivalent has a different name {@link java.util.jar.JarEntry#getAttributes()}
080     *
081     * @deprecated since 1.5, do not use; always returns null
082     * @return Always returns null.
083     */
084    @Deprecated
085    public Attributes getManifestAttributes() {
086        return manifestAttributes;
087    }
088
089}