    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class w3c.www.dsig.ResInfoExtension

    java.lang.Object
       |
       +----w3c.www.dsig.ResInfoExtension

public class ResInfoExtension
extends Object

ResInfo as defined by W3C Digital Signature Initative. The ResInfo (resource information) is a PICS-1.1 extension that contains zero or more cryptographic hashes of the document the label references. Hashes are stored in the resinfo as name value pairs where name is a URL identifying the message digest algorithm and the value is the base64 encoded hash as defined in the respective hash algorithm specification. Optionally, each hash can contain the date it was created.

This class implements this set of message digests and also supports calculating and verifying hashes.

Example:

      extension
        ( optional "http://www.w3.org/TR/1998/REC-DSig-label/resinfo-1_0"
           ( "http://www.w3.org/TR/1998/REC-DSig-label/SHA1" "base64-hash" )
           ( "http://www.w3.org/TR/1998/REC-DSig-label/MD5" "base64-hash"
             "1997.02.05T08:15-0500" ) )

##

EXTENSION_ID
  The name of the extension identifier (`http://www.w3.org/TR/1998/REC-DSig-label/resinfo-1_0`).

##

ResInfoExtension()
  Create an empty resource information

##

addDigest(String, DSigLabelInterface, ISODate)
  Calculate the message digest of the data referenced by the URL specified in the 'for' option of the label.
addDigest(String, InputStream, ISODate)
  Calculate the message digest of the data from the InputStream ins and add it to the resinfo.
addDigest(String, String, ISODate)
  Add the pre-computed message digest `val` for the algorithm `alg`.
containsDigest(String)
  Check if a message digest for the given algorithm exists in this resinfo.
digests()
  Enumerate the digest URLs.
getDigestDate(String)
  Get the ISODate of a digest function.
getDigestValue(String)
  Get the value of a digest function.
parse(Vector)
  Parse a Vector to a ResInfo extension.
removeDigest(String)
  Remove the message digest for the algorithm alg.
size()
  Return the number of hashes in this ResInfo.
toString()
  Return an S-Expression string representation of this ResInfo extension.
toVector()
  Return a normalized, Vector form of ResInfo Extension.
verify(DSigLabelInterface)
  Perform verification using the default policy as defined by the user.
verify(InputStream)
  Perform verification using the default policy as defined by the user.
verify(String, DSigLabelInterface)
  Verify if the hash of the document specified in the 'for' option of the label matches the hash stored in this resinfo.
verify(String, InputStream)
  Verify if the hash of the data in the InputStream ins equals the hash stored in this resinfo.
verifyAll(DSigLabelInterface)
  Verify if all hashes in the ResInfo extension match the document specified in the 'for' option of the label.
verifyAll(InputStream)
  Verify if all hashes in the ResInfo extension match the data from the InputStream.

##

EXTENSION_ID

     public static final String EXTENSION_ID

  The name of the extension identifier (`http://www.w3.org/TR/1998/REC-DSig-label/resinfo-1_0`).

##

ResInfoExtension

     public ResInfoExtension()

  Create an empty resource information

##

addDigest

     public void addDigest(String alg,
                           String val,
                           ISODate date)

  Add the pre-computed message digest `val` for the algorithm `alg`. The digest `val` needs to be in the correct base 64 encoded format. If date is not null it is added as the digest's date.

addDigest

     public void addDigest(String alg,
                           InputStream ins,
                           ISODate date) throws NoSuchAlgorithmException, IOException

  Calculate the message digest of the data from the InputStream ins and add it to the resinfo. If date is not null it is added as the digest's date.

  Throws: NoSuchAlgorithmException
    if the corresponding message digest algorithm cannot be found
  Throws: IOException
    if the input stream cannot be properly read.

addDigest

     public void addDigest(String alg,
                           DSigLabelInterface label,
                           ISODate date) throws NoSuchAlgorithmException, IOException, DSigException

  Calculate the message digest of the data referenced by the URL specified in the 'for' option of the label. If date is not null it is added as the digest's date.

  Throws: NoSuchAlgorithmException
    if the corresponding message digest algorithm cannot be found
  Throws: IOException
    if it cannot open a URL stream.
  Throws: DSigException
    if there is no 'for' option in the label (i.e. the label does not specify which URL to perform digest).

verify

     public Trivalue verify(DSigLabelInterface label)

  Perform verification using the default policy as defined by the user. However, this is not yet implemented and the method is equivalent to verify(label).

verify

     public Trivalue verify(InputStream ins)

  Perform verification using the default policy as defined by the user. However, this is not yet implemented and the method is equivalent to verifyAll(ins).

verify

     public Trivalue verify(String alg,
                            DSigLabelInterface label)

  Verify if the hash of the document specified in the 'for' option of the label matches the hash stored in this resinfo.

verify

     public Trivalue verify(String alg,
                            InputStream ins)

  Verify if the hash of the data in the InputStream ins equals the hash stored in this resinfo.

verifyAll

     public Trivalue verifyAll(DSigLabelInterface label)

  Verify if all hashes in the ResInfo extension match the document specified in the 'for' option of the label.

verifyAll

     public Trivalue verifyAll(InputStream ins)

  Verify if all hashes in the ResInfo extension match the data from the InputStream. Hashing is done in parallel in a single scan of the InputStream so there is no need to reset or reopen the inputstream.

removeDigest

     public boolean removeDigest(String alg)

  Remove the message digest for the algorithm alg. Return true if successful, false otherwise (no message digest for algorithm alg present).

containsDigest

     public boolean containsDigest(String alg)

  Check if a message digest for the given algorithm exists in this resinfo.

size

     public int size()

  Return the number of hashes in this ResInfo.

digests

     public Enumeration digests()

  Enumerate the digest URLs.

getDigestValue

     public String getDigestValue(String alg)

  Get the value of a digest function. Return null if not found. Applications should not need to use this, it is intended for internal use.

getDigestDate

     public ISODate getDigestDate(String alg)

  Get the ISODate of a digest function. Return null if the algorithm is not found or no date is present.

parse

     public void parse(Vector v)

  Parse a Vector to a ResInfo extension.

toVector

     public Vector toVector()

  Return a normalized, Vector form of ResInfo Extension.

toString

     public String toString()

  Return an S-Expression string representation of this ResInfo extension.

  Overrides:
    toString in class Object

    All Packages  Class Hierarchy  This Package  Previous  Next  Index