FileDocCategorySizeDatePackage
TSTInfo.javaAPI DocAndroid 1.5 API6985Wed May 06 22:41:06 BST 2009org.bouncycastle.asn1.tsp

TSTInfo

public class TSTInfo extends org.bouncycastle.asn1.ASN1Encodable

Fields Summary
org.bouncycastle.asn1.DERInteger
version
org.bouncycastle.asn1.DERObjectIdentifier
tsaPolicyId
MessageImprint
messageImprint
org.bouncycastle.asn1.DERInteger
serialNumber
org.bouncycastle.asn1.DERGeneralizedTime
genTime
Accuracy
accuracy
org.bouncycastle.asn1.DERBoolean
ordering
org.bouncycastle.asn1.DERInteger
nonce
org.bouncycastle.asn1.x509.GeneralName
tsa
org.bouncycastle.asn1.x509.X509Extensions
extensions
Constructors Summary
public TSTInfo(org.bouncycastle.asn1.ASN1Sequence seq)

        Enumeration e = seq.getObjects();

        // version
        version = DERInteger.getInstance(e.nextElement());

        // tsaPolicy
        tsaPolicyId = DERObjectIdentifier.getInstance(e.nextElement());

        // messageImprint
        messageImprint = MessageImprint.getInstance(e.nextElement());

        // serialNumber
        serialNumber = DERInteger.getInstance(e.nextElement());

        // genTime
        genTime = DERGeneralizedTime.getInstance(e.nextElement());

        // default for ordering
        // BEGIN android-changed
        ordering = DERBoolean.FALSE;
        // END android-changed
        
        while (e.hasMoreElements())
        {
            DERObject o = (DERObject) e.nextElement();

            if (o instanceof ASN1TaggedObject)
            {
                DERTaggedObject tagged = (DERTaggedObject) o;

                switch (tagged.getTagNo())
                {
                case 0:
                    tsa = GeneralName.getInstance(tagged, true);
                    break;
                case 1:
                    extensions = X509Extensions.getInstance(tagged, false);
                    break;
                default:
                    throw new IllegalArgumentException("Unknown tag value " + tagged.getTagNo());
                }
            }
            else if (o instanceof DERSequence)
            {
                accuracy = Accuracy.getInstance(o);
            }
            else if (o instanceof DERBoolean)
            {
                ordering = DERBoolean.getInstance(o);
            }
            else if (o instanceof DERInteger)
            {
                nonce = DERInteger.getInstance(o);
            }

        }
    
public TSTInfo(org.bouncycastle.asn1.DERObjectIdentifier tsaPolicyId, MessageImprint messageImprint, org.bouncycastle.asn1.DERInteger serialNumber, org.bouncycastle.asn1.DERGeneralizedTime genTime, Accuracy accuracy, org.bouncycastle.asn1.DERBoolean ordering, org.bouncycastle.asn1.DERInteger nonce, org.bouncycastle.asn1.x509.GeneralName tsa, org.bouncycastle.asn1.x509.X509Extensions extensions)

        version = new DERInteger(1);
        this.tsaPolicyId = tsaPolicyId;
        this.messageImprint = messageImprint;
        this.serialNumber = serialNumber;
        this.genTime = genTime;

        this.accuracy = accuracy;
        this.ordering = ordering;
        this.nonce = nonce;
        this.tsa = tsa;
        this.extensions = extensions;
    
Methods Summary
public AccuracygetAccuracy()

        return accuracy;
    
public org.bouncycastle.asn1.x509.X509ExtensionsgetExtensions()

        return extensions;
    
public org.bouncycastle.asn1.DERGeneralizedTimegetGenTime()

        return genTime;
    
public static org.bouncycastle.asn1.tsp.TSTInfogetInstance(java.lang.Object o)

        if (o == null || o instanceof TSTInfo)
        {
            return (TSTInfo) o;
        }
        else if (o instanceof ASN1Sequence)
        {
            return new TSTInfo((ASN1Sequence) o);
        }
        else if (o instanceof ASN1OctetString)
        {
            try
            {
                return getInstance(new ASN1InputStream(((ASN1OctetString)o).getOctets()).readObject());
            }
            catch (IOException ioEx)
            {
                throw new IllegalArgumentException(
                        "Bad object format in 'TSTInfo' factory.");
            }
        }

        throw new IllegalArgumentException(
                "Unknown object in 'TSTInfo' factory : "
                        + o.getClass().getName() + ".");
    
public MessageImprintgetMessageImprint()

        return messageImprint;
    
public org.bouncycastle.asn1.DERIntegergetNonce()

        return nonce;
    
public org.bouncycastle.asn1.DERBooleangetOrdering()

        return ordering;
    
public org.bouncycastle.asn1.DERObjectIdentifiergetPolicy()

        return tsaPolicyId;
    
public org.bouncycastle.asn1.DERIntegergetSerialNumber()

        return serialNumber;
    
public org.bouncycastle.asn1.x509.GeneralNamegetTsa()

        return tsa;
    
public org.bouncycastle.asn1.DERObjecttoASN1Object()

TSTInfo ::= SEQUENCE {
version INTEGER { v1(1) },
policy TSAPolicyId,
messageImprint MessageImprint,
-- MUST have the same value as the similar field in
-- TimeStampReq
serialNumber INTEGER,
-- Time-Stamping users MUST be ready to accommodate integers
-- up to 160 bits.
genTime GeneralizedTime,
accuracy Accuracy OPTIONAL,
ordering BOOLEAN DEFAULT FALSE,
nonce INTEGER OPTIONAL,
-- MUST be present if the similar field was present
-- in TimeStampReq. In that case it MUST have the same value.
tsa [0] GeneralName OPTIONAL,
extensions [1] IMPLICIT Extensions OPTIONAL }

        DEREncodableVector seq = new DEREncodableVector();
        seq.add(version);

        seq.add(tsaPolicyId);
        seq.add(messageImprint);
        seq.add(serialNumber);
        seq.add(genTime);

        if (accuracy != null)
        {
            seq.add(accuracy);
        }
        
        if (ordering != null && ordering.isTrue())
        {
            seq.add(ordering);
        }
        
        if (nonce != null)
        {
            seq.add(nonce);
        }
        
        if (tsa != null)
        {
            seq.add(new DERTaggedObject(true, 0, tsa));
        }
        
        if (extensions != null)
        {
            seq.add(new DERTaggedObject(false, 1, extensions));
        }

        return new DERSequence(seq);