codec.x509.extensions
Class CertHashExtension

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--codec.asn1.ASN1AbstractCollection
                          |
                          +--codec.asn1.ASN1Sequence
                                |
                                +--codec.x509.X509Extension
                                      |
                                      +--codec.x509.extensions.CertHashExtension
All Implemented Interfaces:
ASN1Collection, ASN1Type, Cloneable, Collection, Externalizable, List, Serializable, X509Extension

public class CertHashExtension
extends X509Extension

id-sigi-at-certHash OBJECT IDENTIFIER ::= { 1 3 36 8 3 13 }

 certHash EXTENSION ::= {
   SYNTAX CertHashSyntax
   IDENTIFIED BY id-sigi-at-certHash
 }
 CertHashSyntax ::= SEQUENCE {
   hashAlgorithm AlgorithmIdentifier,
   certificateHash OCTET STRING
 }
 

Version:
"$Id: CertHashExtension.java,v 1.1 2004/08/16 13:31:37 pebinger Exp $"
Author:
Volker Roth
See Also:
Serialized Form

Field Summary
static String DEFAULT_HASH_ALG
           
static String EXTENSION_OID
           
 
Fields inherited from class codec.x509.X509Extension
critical, extnID, extnValue
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
CertHashExtension()
          Creates an instance ready for decoding.
CertHashExtension(byte[] cert, String alg)
          Creates an instance with a hash of the given encoded certificate where the hash is computed with the given hash algorithm.
CertHashExtension(X509Certificate cert)
          Creates an instance with the hash of the given certificate.
CertHashExtension(X509Certificate cert, String alg)
          Creates an instance with a hash of the given certificate where the hash is computed with the given hash algorithm.
 
Method Summary
 void decode(Decoder dec)
          Reads this collection from the given Decoder.
 AlgorithmIdentifier getHashAlgorithmID()
           
 String getHashAlgorithmName()
           
 boolean verify(byte[] cert)
           
 boolean verify(X509Certificate cert)
           
 
Methods inherited from class codec.x509.X509Extension
decodeExtensionValue, getCriticalExtensionOIDs, getEncoded, getExtensionValue, getNonCriticalExtensionOIDs, getOID, getValue, hasUnsupportedCriticalExtension, isCritical, setCritical, setOID, setValue, toString, toString
 
Methods inherited from class codec.asn1.ASN1Sequence
getTag
 
Methods inherited from class codec.asn1.ASN1AbstractCollection
checkConstraints, encode, getCollection, getConstraint, getTagClass, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, writeExternal
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Field Detail

DEFAULT_HASH_ALG

public static final String DEFAULT_HASH_ALG

EXTENSION_OID

public static final String EXTENSION_OID
Constructor Detail

CertHashExtension

public CertHashExtension()
                  throws ASN1Exception,
                         CertificateEncodingException
Creates an instance ready for decoding.

CertHashExtension

public CertHashExtension(X509Certificate cert)
                  throws ASN1Exception,
                         GeneralSecurityException
Creates an instance with the hash of the given certificate. The hash is computed with the default hash function DEFAULT_HASH_ALG.

CertHashExtension

public CertHashExtension(X509Certificate cert,
                         String alg)
                  throws ASN1Exception,
                         GeneralSecurityException
Creates an instance with a hash of the given certificate where the hash is computed with the given hash algorithm.
Throws:
NoSuchAlgorithmException - if the given algorithm is not available.
CertificateEncodingException - if the given certificate cannot be encoded correctly.
GeneralSecurityException - if there is another security related error condition.
ASN1Exception - hardly ever, this exception must be declared basically because it is declared in the constructor of the super class.

CertHashExtension

public CertHashExtension(byte[] cert,
                         String alg)
                  throws ASN1Exception,
                         GeneralSecurityException
Creates an instance with a hash of the given encoded certificate where the hash is computed with the given hash algorithm.
Throws:
NoSuchAlgorithmException - if the given algorithm is not available.
GeneralSecurityException - if there is another security related error condition.
ASN1Exception - hardly ever, this exception must be declared basically because it is declared in the constructor of the super class.
Method Detail

decode

public void decode(Decoder dec)
            throws ASN1Exception,
                   IOException
Description copied from class: ASN1AbstractCollection
Reads this collection from the given Decoder. This type is initialized with the decoded data. The components of the decoded collection must match the components of this collection. If they do then the components are also initialized with the decoded values. Otherwise an exception is thrown.
Overrides:
decode in class ASN1AbstractCollection
Following copied from class: codec.asn1.ASN1AbstractCollection
Parameters:
dec - The decoder to read from.

getHashAlgorithmID

public AlgorithmIdentifier getHashAlgorithmID()

getHashAlgorithmName

public String getHashAlgorithmName()

verify

public boolean verify(X509Certificate cert)
               throws NoSuchAlgorithmException,
                      CertificateEncodingException
Returns:
true if the hash of the given certificate equals the hash stored in this structure.

verify

public boolean verify(byte[] cert)
               throws NoSuchAlgorithmException
Returns:
true if the hash of the given certificate equals the hash stored in this structure.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.