All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.spongycastle.asn1.ess.ContentHints Maven / Gradle / Ivy

Go to download

Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle intended for Android. Android ships with a stripped-down version of Bouncy Castle - this causes classloader collisions if you try to add an alternative (updated/complete) Bouncy Castle jar. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5.

There is a newer version: 1.46.99.3-UNOFFICIAL-ROBERTO-RELEASE
Show newest version
package org.spongycastle.asn1.ess;

import org.spongycastle.asn1.ASN1Encodable;
import org.spongycastle.asn1.ASN1EncodableVector;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.DEREncodable;
import org.spongycastle.asn1.DERObject;
import org.spongycastle.asn1.DERObjectIdentifier;
import org.spongycastle.asn1.DERSequence;
import org.spongycastle.asn1.DERUTF8String;

public class ContentHints
    extends ASN1Encodable
{
    private DERUTF8String contentDescription;
    private DERObjectIdentifier contentType;

    public static ContentHints getInstance(Object o)
    {
        if (o == null || o instanceof ContentHints)
        {
            return (ContentHints)o;
        }
        else if (o instanceof ASN1Sequence)
        {
            return new ContentHints((ASN1Sequence)o);
        }

        throw new IllegalArgumentException(
                "unknown object in 'ContentHints' factory : "
                        + o.getClass().getName() + ".");
    }

    /**
     * constructor
     */
    private ContentHints(ASN1Sequence seq)
    {
        DEREncodable field = seq.getObjectAt(0);
        if (field.getDERObject() instanceof DERUTF8String)
        {
            contentDescription = DERUTF8String.getInstance(field);
            contentType = DERObjectIdentifier.getInstance(seq.getObjectAt(1));
        }
        else
        {
            contentType = DERObjectIdentifier.getInstance(seq.getObjectAt(0));
        }
    }

    public ContentHints(
        DERObjectIdentifier contentType)
    {
        this.contentType = contentType;
        this.contentDescription = null;
    }

    public ContentHints(
        DERObjectIdentifier contentType,
        DERUTF8String contentDescription)
    {
        this.contentType = contentType;
        this.contentDescription = contentDescription;
    }

    public DERObjectIdentifier getContentType()
    {
        return contentType;
    }

    public DERUTF8String getContentDescription()
    {
        return contentDescription;
    }

    /**
     * 
     * ContentHints ::= SEQUENCE {
     *   contentDescription UTF8String (SIZE (1..MAX)) OPTIONAL,
     *   contentType ContentType }
     * 
*/ public DERObject toASN1Object() { ASN1EncodableVector v = new ASN1EncodableVector(); if (contentDescription != null) { v.add(contentDescription); } v.add(contentType); return new DERSequence(v); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy