FileDocCategorySizeDatePackage
DefaultSignedAttributeTableGenerator.javaAPI DocBouncy Castle Crypto API 1.41 (Java 1.5)3169Wed Oct 01 10:55:28 BST 2008org.bouncycastle.cms

DefaultSignedAttributeTableGenerator

public class DefaultSignedAttributeTableGenerator extends Object implements CMSAttributeTableGenerator
Default signed attributes generator.

Fields Summary
private final Hashtable
table
Constructors Summary
public DefaultSignedAttributeTableGenerator()
Initialise to use all defaults

        table = new Hashtable();
    
public DefaultSignedAttributeTableGenerator(org.bouncycastle.asn1.cms.AttributeTable attributeTable)
Initialise with some extra attributes or overrides.

param
attributeTable initial attribute table to use.

        if (attributeTable != null)
        {
            table = attributeTable.toHashtable();
        }
        else
        {
            table = new Hashtable();
        }
    
Methods Summary
protected java.util.HashtablecreateStandardAttributeTable(java.util.Map parameters)
Create a standard attribute table from the passed in parameters - this will normally include contentType, signingTime, and messageDigest. If the constructor using an AttributeTable was used, entries in it for contentType, signingTime, and messageDigest will override the generated ones.

param
parameters source parameters for table generation.
return
a filled in Hashtable of attributes.

        Hashtable std = (Hashtable)table.clone();

        if (!std.containsKey(CMSAttributes.contentType))
        {
            Attribute attr = new Attribute(CMSAttributes.contentType,
                              new DERSet((DERObjectIdentifier)parameters.get(CMSAttributeTableGenerator.CONTENT_TYPE)));
            std.put(attr.getAttrType(), attr);
        }

        if (!std.containsKey(CMSAttributes.signingTime))
        {
            Attribute attr = new Attribute(CMSAttributes.signingTime, new DERSet(new Time(new Date())));
            std.put(attr.getAttrType(), attr);
        }

        if (!std.containsKey(CMSAttributes.messageDigest))
        {
            byte[] hash = (byte[])parameters.get(CMSAttributeTableGenerator.DIGEST);
            Attribute attr;

            if (hash != null)
            {
                attr = new Attribute(CMSAttributes.messageDigest, new DERSet(new DEROctetString(hash)));
            }
            else
            {
                attr = new Attribute(CMSAttributes.messageDigest, new DERSet(new DERNull()));
            }

            std.put(attr.getAttrType(), attr);
        }

        return std;
    
public org.bouncycastle.asn1.cms.AttributeTablegetAttributes(java.util.Map parameters)

param
parameters source parameters
return
the populated attribute table

        return new AttributeTable(createStandardAttributeTable(parameters));