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

org.spongycastle.asn1.x509.Targets 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.x509;

import org.spongycastle.asn1.ASN1Encodable;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.DERObject;
import org.spongycastle.asn1.DERSequence;

import java.util.Enumeration;

/**
 * Targets structure used in target information extension for attribute
 * certificates from RFC 3281.
 * 
 * 
 *            Targets ::= SEQUENCE OF Target
 *           
 *            Target  ::= CHOICE {
 *              targetName          [0] GeneralName,
 *              targetGroup         [1] GeneralName,
 *              targetCert          [2] TargetCert
 *            }
 *           
 *            TargetCert  ::= SEQUENCE {
 *              targetCertificate    IssuerSerial,
 *              targetName           GeneralName OPTIONAL,
 *              certDigestInfo       ObjectDigestInfo OPTIONAL
 *            }
 * 
* * @see org.spongycastle.asn1.x509.Target * @see org.spongycastle.asn1.x509.TargetInformation */ public class Targets extends ASN1Encodable { private ASN1Sequence targets; /** * Creates an instance of a Targets from the given object. *

* obj can be a Targets or a {@link ASN1Sequence} * * @param obj The object. * @return A Targets instance. * @throws IllegalArgumentException if the given object cannot be * interpreted as Target. */ public static Targets getInstance(Object obj) { if (obj instanceof Targets) { return (Targets)obj; } else if (obj instanceof ASN1Sequence) { return new Targets((ASN1Sequence)obj); } throw new IllegalArgumentException("unknown object in factory: " + obj.getClass()); } /** * Constructor from ASN1Sequence. * * @param targets The ASN.1 SEQUENCE. * @throws IllegalArgumentException if the contents of the sequence are * invalid. */ private Targets(ASN1Sequence targets) { this.targets = targets; } /** * Constructor from given targets. *

* The vector is copied. * * @param targets A Vector of {@link Target}s. * @see Target * @throws IllegalArgumentException if the vector contains not only Targets. */ public Targets(Target[] targets) { this.targets = new DERSequence(targets); } /** * Returns the targets in a Vector. *

* The vector is cloned before it is returned. * * @return Returns the targets. */ public Target[] getTargets() { Target[] targs = new Target[targets.size()]; int count = 0; for (Enumeration e = targets.getObjects(); e.hasMoreElements();) { targs[count++] = Target.getInstance(e.nextElement()); } return targs; } /** * Produce an object suitable for an ASN1OutputStream. * * Returns: * *

     *            Targets ::= SEQUENCE OF Target
     * 
* * @return a DERObject */ public DERObject toASN1Object() { return targets; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy