FileDocCategorySizeDatePackage
RecipientKeyIdentifier.javaAPI DocAndroid 1.5 API3981Wed May 06 22:41:06 BST 2009org.bouncycastle.asn1.cms

RecipientKeyIdentifier

public class RecipientKeyIdentifier extends org.bouncycastle.asn1.ASN1Encodable

Fields Summary
private org.bouncycastle.asn1.ASN1OctetString
subjectKeyIdentifier
private org.bouncycastle.asn1.DERGeneralizedTime
date
private OtherKeyAttribute
other
Constructors Summary
public RecipientKeyIdentifier(org.bouncycastle.asn1.ASN1OctetString subjectKeyIdentifier, org.bouncycastle.asn1.DERGeneralizedTime date, OtherKeyAttribute other)

        this.subjectKeyIdentifier = subjectKeyIdentifier;
        this.date = date;
        this.other = other;
    
public RecipientKeyIdentifier(org.bouncycastle.asn1.ASN1Sequence seq)

        subjectKeyIdentifier = ASN1OctetString.getInstance(
                                                    seq.getObjectAt(0));
        
        switch(seq.size())
        {
        case 1:
            break;
        case 2:
            if (seq.getObjectAt(1) instanceof DERGeneralizedTime)
            {
                date = (DERGeneralizedTime)seq.getObjectAt(1); 
            }
            else
            {
                other = OtherKeyAttribute.getInstance(seq.getObjectAt(2));
            }
            break;
        case 3:
            date  = (DERGeneralizedTime)seq.getObjectAt(1);
            other = OtherKeyAttribute.getInstance(seq.getObjectAt(2));
            break;
        default:
            throw new IllegalArgumentException("Invalid KEKIdentifier");
        }
    
Methods Summary
public org.bouncycastle.asn1.DERGeneralizedTimegetDate()

        return date;
    
public static org.bouncycastle.asn1.cms.RecipientKeyIdentifiergetInstance(org.bouncycastle.asn1.ASN1TaggedObject _ato, boolean _explicit)
return a RecipientKeyIdentifier object from a tagged object.

param
_ato the tagged object holding the object we want.
param
_explicit true if the object is meant to be explicitly tagged false otherwise.
exception
IllegalArgumentException if the object held by the tagged object cannot be converted.

        return getInstance(ASN1Sequence.getInstance(_ato, _explicit));
    
public static org.bouncycastle.asn1.cms.RecipientKeyIdentifiergetInstance(java.lang.Object _obj)
return a RecipientKeyIdentifier object from the given object.

param
_obj the object we want converted.
exception
IllegalArgumentException if the object cannot be converted.

        if(_obj == null || _obj instanceof RecipientKeyIdentifier)
        {
            return (RecipientKeyIdentifier)_obj;
        }
        
        if(_obj instanceof ASN1Sequence)
        {
            return new RecipientKeyIdentifier((ASN1Sequence)_obj);
        }
        
        throw new IllegalArgumentException("Invalid RecipientKeyIdentifier: " + _obj.getClass().getName());
    
public OtherKeyAttributegetOtherKeyAttribute()

        return other;
    
public org.bouncycastle.asn1.ASN1OctetStringgetSubjectKeyIdentifier()

        return subjectKeyIdentifier;
    
public org.bouncycastle.asn1.DERObjecttoASN1Object()
Produce an object suitable for an ASN1OutputStream.
RecipientKeyIdentifier ::= SEQUENCE {
subjectKeyIdentifier SubjectKeyIdentifier,
date GeneralizedTime OPTIONAL,
other OtherKeyAttribute OPTIONAL
}

SubjectKeyIdentifier ::= OCTET STRING

        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(subjectKeyIdentifier);
        
        if (date != null)
        {
            v.add(date);
        }

        if (other != null)
        {
            v.add(other);
        }
        
        return new DERSequence(v);