Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.classpath.tools.jarsigner
Class SFHelper  view SFHelper download SFHelper.java

java.lang.Object
  extended bygnu.classpath.tools.jarsigner.SFHelper

public class SFHelper
extends java.lang.Object

A helper class for the .SF file found in signed jars.


Field Summary
private static int DSA_GENERATED
           
private static int FINISHED
           
private static gnu.java.security.OID hashAlgorithmIdentifierSHA1
          http://asn1.elibel.tm.fr/cgi-bin/oid/display?oid=1.3.14.3.2.26&action=display
private  java.util.jar.JarFile jar
           
private static java.util.logging.Logger log
           
private  java.util.jar.Manifest manifest
           
private static int READY
           
private static int SF_GENERATED
           
private  byte[] sfBytes
           
private  java.util.Map sfEntries
           
private  java.util.jar.Attributes sfMainAttributes
           
private static int STARTED
           
private  int state
           
private  HashUtils util
           
 
Constructor Summary
SFHelper(java.util.jar.JarFile jar)
           
 
Method Summary
(package private)  void finishSigning(boolean sectionsOnly)
           
(package private)  java.util.jar.Manifest getManifest()
           
(package private)  void startSigning()
           
(package private)  void updateEntry(java.util.jar.JarEntry entry)
          Hashes the designated JAR entry (the file itself); adds the resulting hash as an attribute to the manifest, and computes the hash of the added (to the Manifest) two headers and add the result as an attribute of the corresponding entry in the .SF file.
(package private)  void writeDSA(java.util.jar.JarOutputStream jar, java.security.PrivateKey signerKey, java.security.cert.Certificate[] certificates, boolean internalSF)
          The contents of the .DSA file is the DER encoded form of a PKCS#7 ContentInfo of the type SignedData.
(package private)  void writeSF(java.util.jar.JarOutputStream jar)
          Writes the contents of the .SF file to the designated JAR output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final java.util.logging.Logger log

READY

private static final int READY
See Also:
Constant Field Values

STARTED

private static final int STARTED
See Also:
Constant Field Values

FINISHED

private static final int FINISHED
See Also:
Constant Field Values

SF_GENERATED

private static final int SF_GENERATED
See Also:
Constant Field Values

DSA_GENERATED

private static final int DSA_GENERATED
See Also:
Constant Field Values

hashAlgorithmIdentifierSHA1

private static final gnu.java.security.OID hashAlgorithmIdentifierSHA1
http://asn1.elibel.tm.fr/cgi-bin/oid/display?oid=1.3.14.3.2.26&action=display


state

private int state

jar

private java.util.jar.JarFile jar

manifest

private java.util.jar.Manifest manifest

sfMainAttributes

private java.util.jar.Attributes sfMainAttributes

sfEntries

private java.util.Map sfEntries

sfBytes

private byte[] sfBytes

util

private HashUtils util
Constructor Detail

SFHelper

public SFHelper(java.util.jar.JarFile jar)
Method Detail

writeSF

void writeSF(java.util.jar.JarOutputStream jar)
       throws java.io.IOException
Writes the contents of the .SF file to the designated JAR output stream. Line-endings are platform-independent and consist of the 2-codepoint sequence 0x0D and 0x0A.


writeDSA

void writeDSA(java.util.jar.JarOutputStream jar,
              java.security.PrivateKey signerKey,
              java.security.cert.Certificate[] certificates,
              boolean internalSF)
        throws java.io.IOException,
               java.security.cert.CertificateEncodingException,
               java.security.cert.CRLException
The contents of the .DSA file is the DER encoded form of a PKCS#7 ContentInfo of the type SignedData.

The ContentInfo ASN.1 syntax is as described in the "PKCS#7 Cryptographic Message Syntax Standard" (RSA Labs) specifications:

 ContentInfo ::= SEQUENCE {
   contentType     ContentType,
   content     [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL
 }
 
 ContentType ::= OBJECT IDENTIFIER
 

The ContentType is an OID which determines the type of the contents field that follows it. For the .DSA file the OID is "1.2.840.113549.1.7.2", while the content field is the byte array representing the DER encoded form of a SignedData content-type. The ASN.1 syntax of the SignedData type is as follows:

 SignedData ::= SEQUENCE {
   version          Version, -- always 1 for PKCS#7 1.5
   digestAlgorithms DigestAlgorithmIdentifiers,
   contentInfo      ContentInfo,
   certificates [0] IMPLICIT ExtendedCertificatesAndCertificates OPTIONAL,
   crls         [1] IMPLICIT CertificateRevocationLists OPTIONAL,
   signerInfos      SignerInfos
 }
 
 DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier
 
 SignerInfos ::= SET OF SignerInfo
 

Finally the SignerInfo is a per-signer structure. Its ASN.1 syntax looks like so:

 SignerInfo ::= SEQUENCE {
   version                       Version, -- always 1 for PKCS#7 1.5
   issuerAndSerialNumber         IssuerAndSerialNumber,
   digestAlgorithm               DigestAlgorithmIdentifier,
   authenticatedAttributes   [0] IMPLICIT Attributes OPTIONAL,
   digestEncryptionAlgorithm     DigestEncryptionAlgorithmIdentifier,
   encryptedDigest               EncryptedDigest,
   unauthenticatedAttributes [1] IMPLICIT Attributes OPTIONAL
 }
 
 EncryptedDigest ::= OCTET STRING
 


getManifest

java.util.jar.Manifest getManifest()

startSigning

void startSigning()
            throws java.io.IOException

updateEntry

void updateEntry(java.util.jar.JarEntry entry)
           throws java.io.IOException
Hashes the designated JAR entry (the file itself); adds the resulting hash as an attribute to the manifest, and computes the hash of the added (to the Manifest) two headers and add the result as an attribute of the corresponding entry in the .SF file.


finishSigning

void finishSigning(boolean sectionsOnly)
             throws java.io.IOException