public class

SignatureFile

extends Object
java.lang.Object
   ↳ sun.tools.jar.SignatureFile

Class Overview

A signature file as defined in the Manifest and Signature Format. It has essentially the same structure as a Manifest file in that it is a set of RFC 822 headers (sections). The first section contains meta data relevant to the entire file (i.e "Signature-Version:1.0") and each subsequent section contains data relevant to specific entries: entry sections.

Each entry section contains the name of an entry (which must have a counterpart in the manifest). Like the manifest it contains a hash, the hash of the manifest section correspondind to the name. Since the manifest entry contains the hash of the data, this is equivalent to a signature of the data, plus the attributes of the manifest entry.

This signature file format deal with PKCS7 encoded DSA signature block. It should be straightforward to extent to support other algorithms.

Summary

Public Constructors
SignatureFile(Manifest manifest, String name)
Constructs a new Signature file corresponding to a given Manifest.
SignatureFile(Manifest manifest, String[] entries, String filename)
Constructs a new Signature file corresponding to a given Manifest.
SignatureFile(InputStream is, String filename)
Construct a Signature file from an input stream.
SignatureFile(InputStream is)
Construct a Signature file from an input stream.
SignatureFile(byte[] bytes)
Public Methods
void add(String[] entries)
Add a set of entries from the current manifest.
void add(String entry)
Add a specific entry from the current manifest.
Enumeration entries()
Returns an enumeration of the entries.
MessageHeader entryAt(int n)
Returns the n-th entry.
PKCS7 getBlock()
Returns the signature block associated with this file.
String getBlockName()
Returns the name of the block file, ending with a block suffix such as ".DSA".
MessageHeader getEntry(String name)
Get the entry corresponding to a given name.
String getName()
Returns the name of the signature file, ending with a ".SF" suffix
void setBlock(PKCS7 block)
Sets the signature block associated with this file.
void stream(OutputStream os)
Add a signature file at current position in a stream
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public SignatureFile (Manifest manifest, String name)

Constructs a new Signature file corresponding to a given Manifest. All entries in the manifest are signed.

Parameters
manifest the manifest to use.
name for this signature file. This should be less than 8 characters, and without a suffix (i.e. without a period in it.
Throws
JarException if an invalid name is passed in.

public SignatureFile (Manifest manifest, String[] entries, String filename)

Constructs a new Signature file corresponding to a given Manifest. Specific entries in the manifest are signed.

Parameters
manifest the manifest to use.
entries the entries to sign.
filename for this signature file. This should be less than 8 characters, and without a suffix (i.e. without a period in it.
Throws
JarException if an invalid name is passed in.

public SignatureFile (InputStream is, String filename)

Construct a Signature file from an input stream.

Throws
IOException if an invalid name is passed in or if a stream exception occurs.

public SignatureFile (InputStream is)

Construct a Signature file from an input stream.

Throws
IOException if an invalid name is passed in or if a stream exception occurs.

public SignatureFile (byte[] bytes)

Throws
IOException

Public Methods

public void add (String[] entries)

Add a set of entries from the current manifest.

Throws
JarException

public void add (String entry)

Add a specific entry from the current manifest.

Throws
JarException

public Enumeration entries ()

Returns an enumeration of the entries.

public MessageHeader entryAt (int n)

Returns the n-th entry. The global header is a entry 0.

public PKCS7 getBlock ()

Returns the signature block associated with this file.

public String getBlockName ()

Returns the name of the block file, ending with a block suffix such as ".DSA".

public MessageHeader getEntry (String name)

Get the entry corresponding to a given name. Returns null if the entry does not exist.

public String getName ()

Returns the name of the signature file, ending with a ".SF" suffix

public void setBlock (PKCS7 block)

Sets the signature block associated with this file.

public void stream (OutputStream os)

Add a signature file at current position in a stream

Throws
IOException