2362N/A * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * <p>A signature file as defined in the <a 0N/A * essentially the same structure as a Manifest file in that it is a 0N/A * set of RFC 822 headers (sections). The first section contains meta 0N/A * data relevant to the entire file (i.e "Signature-Version:1.0") and 0N/A * each subsequent section contains data relevant to specific entries: 0N/A * <p>Each entry section contains the name of an entry (which must 0N/A * have a counterpart in the manifest). Like the manifest it contains 0N/A * a hash, the hash of the manifest section correspondind to the 0N/A * name. Since the manifest entry contains the hash of the data, this 0N/A * is equivalent to a signature of the data, plus the attributes of 0N/A * the manifest entry. 0N/A * <p>This signature file format deal with PKCS7 encoded DSA signature 0N/A * block. It should be straightforward to extent to support other 0N/A * @author David Brown 0N/A * @author Benjamin Renaud */ 0N/A /* Are we debugging? */ 0N/A /* list of headers that all pertain to a particular file in the 0N/A /* Right now we only support SHA hashes */ 0N/A * The manifest we're working with. */ 0N/A * The file name for the file. This is the raw name, i.e. the 0N/A * extention-less 8 character name (such as MYSIGN) which wil be 0N/A * used to build the signature filename (MYSIGN.SF) and the block 0N/A * filename (MYSIGN.DSA) */ 0N/A /* The digital signature block corresponding to this signature 0N/A * Private constructor which takes a name a given signature 0N/A * file. The name must be extension-less and less or equal to 8 0N/A * character in length. */ 0N/A * Private constructor which takes a name a given signature file 0N/A * and a new file predicate. If it is a new file, a main header 0N/A * Constructs a new Signature file corresponding to a given 0N/A * Manifest. All entries in the manifest are signed. 0N/A * @param manifest the manifest to use. 0N/A * @param name for this signature file. This should 0N/A * be less than 8 characters, and without a suffix (i.e. 0N/A * without a period in it. 0N/A * @exception JarException if an invalid name is passed in. 0N/A * Constructs a new Signature file corresponding to a given 0N/A * Manifest. Specific entries in the manifest are signed. 0N/A * @param manifest the manifest to use. 0N/A * @param entries the entries to sign. 0N/A * @param filename for this signature file. This should 0N/A * be less than 8 characters, and without a suffix (i.e. 0N/A * without a period in it. 0N/A * @exception JarException if an invalid name is passed in. 0N/A * Construct a Signature file from an input stream. 0N/A * @exception IOException if an invalid name is passed in or if a 0N/A * stream exception occurs. 0N/A * Construct a Signature file from an input stream. 0N/A * @exception IOException if an invalid name is passed in or if a 0N/A * stream exception occurs. 0N/A * Returns the name of the signature file, ending with a ".SF" 0N/A * Returns the name of the block file, ending with a block suffix 0N/A * such as ".DSA". */ 0N/A * Returns the signature block associated with this file. 0N/A * Sets the signature block associated with this file. 0N/A * Add a set of entries from the current manifest. 0N/A * Add a specific entry from the current manifest. 0N/A * Get the entry corresponding to a given name. Returns null if 0N/A *the entry does not exist. 0N/A * Returns the n-th entry. The global header is a entry 0. */ 0N/A * Returns an enumeration of the entries. 0N/A * Given a manifest entry, computes the signature entry for this 0N/A * Add a signature file at current position in a stream 0N/A /* the first header in the file should be the global one. 0N/A * It should say "SignatureFile-Version: x.x"; barf if not 0N/A "Signature-Version: 1.0 in 1st header");