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

com.fitbur.bouncycastle.asn1.isismtt.x509.DeclarationOfMajority Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.fitbur.bouncycastle.asn1.isismtt.x509;

import com.fitbur.bouncycastle.asn1.ASN1Boolean;
import com.fitbur.bouncycastle.asn1.ASN1Choice;
import com.fitbur.bouncycastle.asn1.ASN1EncodableVector;
import com.fitbur.bouncycastle.asn1.ASN1GeneralizedTime;
import com.fitbur.bouncycastle.asn1.ASN1Integer;
import com.fitbur.bouncycastle.asn1.ASN1Object;
import com.fitbur.bouncycastle.asn1.ASN1Primitive;
import com.fitbur.bouncycastle.asn1.ASN1Sequence;
import com.fitbur.bouncycastle.asn1.ASN1TaggedObject;
import com.fitbur.bouncycastle.asn1.DERPrintableString;
import com.fitbur.bouncycastle.asn1.DERSequence;
import com.fitbur.bouncycastle.asn1.DERTaggedObject;

/**
 * A com.fitburclaration of majority.
 *
 * 
 *           DeclarationOfMajoritySyntax ::= CHOICE
 *           {
 *             notYoungerThan [0] IMPLICIT INTEGER,
 *             fullAgeAtCountry [1] IMPLICIT SEQUENCE
 *             {
 *               fullAge BOOLEAN DEFAULT TRUE,
 *               country PrintableString (SIZE(2))
 *             }
 *             dateOfBirth [2] IMPLICIT GeneralizedTime
 *           }
 * 
*

* fullAgeAtCountry indicates the majority of the owner with respect to the laws * of a specific country. */ public class DeclarationOfMajority extends ASN1Object implements ASN1Choice { public static final int notYoungerThan = 0; public static final int fullAgeAtCountry = 1; public static final int dateOfBirth = 2; private ASN1TaggedObject com.fitburclaration; public DeclarationOfMajority(int notYoungerThan) { com.fitburclaration = new DERTaggedObject(false, 0, new ASN1Integer(notYoungerThan)); } public DeclarationOfMajority(boolean fullAge, String country) { if (country.length() > 2) { throw new IllegalArgumentException("country can only be 2 characters"); } if (fullAge) { com.fitburclaration = new DERTaggedObject(false, 1, new DERSequence(new DERPrintableString(country, true))); } else { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(ASN1Boolean.FALSE); v.add(new DERPrintableString(country, true)); com.fitburclaration = new DERTaggedObject(false, 1, new DERSequence(v)); } } public DeclarationOfMajority(ASN1GeneralizedTime dateOfBirth) { com.fitburclaration = new DERTaggedObject(false, 2, dateOfBirth); } public static DeclarationOfMajority getInstance(Object obj) { if (obj == null || obj instanceof DeclarationOfMajority) { return (DeclarationOfMajority)obj; } if (obj instanceof ASN1TaggedObject) { return new DeclarationOfMajority((ASN1TaggedObject)obj); } throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName()); } private DeclarationOfMajority(ASN1TaggedObject o) { if (o.getTagNo() > 2) { throw new IllegalArgumentException("Bad tag number: " + o.getTagNo()); } com.fitburclaration = o; } /** * Produce an object suitable for an ASN1OutputStream. *

* Returns: *

     *           DeclarationOfMajoritySyntax ::= CHOICE
     *           {
     *             notYoungerThan [0] IMPLICIT INTEGER,
     *             fullAgeAtCountry [1] IMPLICIT SEQUENCE
     *             {
     *               fullAge BOOLEAN DEFAULT TRUE,
     *               country PrintableString (SIZE(2))
     *             }
     *             dateOfBirth [2] IMPLICIT GeneralizedTime
     *           }
     * 
* * @return a DERObject */ public ASN1Primitive toASN1Primitive() { return com.fitburclaration; } public int getType() { return com.fitburclaration.getTagNo(); } /** * @return notYoungerThan if that's what we are, -1 otherwise */ public int notYoungerThan() { if (com.fitburclaration.getTagNo() != 0) { return -1; } return ASN1Integer.getInstance(com.fitburclaration, false).getValue().intValue(); } public ASN1Sequence fullAgeAtCountry() { if (com.fitburclaration.getTagNo() != 1) { return null; } return ASN1Sequence.getInstance(com.fitburclaration, false); } public ASN1GeneralizedTime getDateOfBirth() { if (com.fitburclaration.getTagNo() != 2) { return null; } return ASN1GeneralizedTime.getInstance(com.fitburclaration, false); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy