diff options
Diffstat (limited to 'core/src/main/java/org/bouncycastle/asn1/isismtt/x509')
9 files changed, 0 insertions, 1768 deletions
diff --git a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/AdditionalInformationSyntax.java b/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/AdditionalInformationSyntax.java deleted file mode 100644 index 55c7d43f..00000000 --- a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/AdditionalInformationSyntax.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.bouncycastle.asn1.isismtt.x509; - -import org.bouncycastle.asn1.ASN1Object; -import org.bouncycastle.asn1.ASN1Primitive; -import org.bouncycastle.asn1.x500.DirectoryString; - -/** - * Some other information of non-restrictive nature regarding the usage of this - * certificate. - * - * <pre> - * AdditionalInformationSyntax ::= DirectoryString (SIZE(1..2048)) - * </pre> - */ -public class AdditionalInformationSyntax - extends ASN1Object -{ - private DirectoryString information; - - public static AdditionalInformationSyntax getInstance(Object obj) - { - if (obj instanceof AdditionalInformationSyntax) - { - return (AdditionalInformationSyntax)obj; - } - - if (obj != null) - { - return new AdditionalInformationSyntax(DirectoryString.getInstance(obj)); - } - - return null; - } - - private AdditionalInformationSyntax(DirectoryString information) - { - this.information = information; - } - - /** - * Constructor from a given details. - * - * @param information The describtion of the information. - */ - public AdditionalInformationSyntax(String information) - { - this(new DirectoryString(information)); - } - - public DirectoryString getInformation() - { - return information; - } - - /** - * Produce an object suitable for an ASN1OutputStream. - * <p> - * Returns: - * <pre> - * AdditionalInformationSyntax ::= DirectoryString (SIZE(1..2048)) - * </pre> - * - * @return a DERObject - */ - public ASN1Primitive toASN1Primitive() - { - return information.toASN1Primitive(); - } -} diff --git a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/AdmissionSyntax.java b/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/AdmissionSyntax.java deleted file mode 100644 index 88bb7411..00000000 --- a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/AdmissionSyntax.java +++ /dev/null @@ -1,276 +0,0 @@ -package org.bouncycastle.asn1.isismtt.x509; - -import java.util.Enumeration; - -import org.bouncycastle.asn1.ASN1EncodableVector; -import org.bouncycastle.asn1.ASN1Object; -import org.bouncycastle.asn1.ASN1Primitive; -import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.DERSequence; -import org.bouncycastle.asn1.x509.GeneralName; - -/** - * Attribute to indicate admissions to certain professions. - * - * <pre> - * AdmissionSyntax ::= SEQUENCE - * { - * admissionAuthority GeneralName OPTIONAL, - * contentsOfAdmissions SEQUENCE OF Admissions - * } - * - * Admissions ::= SEQUENCE - * { - * admissionAuthority [0] EXPLICIT GeneralName OPTIONAL - * namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL - * professionInfos SEQUENCE OF ProfessionInfo - * } - * - * NamingAuthority ::= SEQUENCE - * { - * namingAuthorityId OBJECT IDENTIFIER OPTIONAL, - * namingAuthorityUrl IA5String OPTIONAL, - * namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL - * } - * - * ProfessionInfo ::= SEQUENCE - * { - * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, - * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), - * professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, - * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, - * addProfessionInfo OCTET STRING OPTIONAL - * } - * </pre> - * <p> - * ISIS-MTT PROFILE: The relatively complex structure of AdmissionSyntax - * supports the following concepts and requirements: - * <ul> - * <li> External institutions (e.g. professional associations, chambers, unions, - * administrative bodies, companies, etc.), which are responsible for granting - * and verifying professional admissions, are indicated by means of the data - * field admissionAuthority. An admission authority is indicated by a - * GeneralName object. Here an X.501 directory name (distinguished name) can be - * indicated in the field directoryName, a URL address can be indicated in the - * field uniformResourceIdentifier, and an object identifier can be indicated in - * the field registeredId. - * <li> The names of authorities which are responsible for the administration of - * title registers are indicated in the data field namingAuthority. The name of - * the authority can be identified by an object identifier in the field - * namingAuthorityId, by means of a text string in the field - * namingAuthorityText, by means of a URL address in the field - * namingAuthorityUrl, or by a combination of them. For example, the text string - * can contain the name of the authority, the country and the name of the title - * register. The URL-option refers to a web page which contains lists with - * �officially� registered professions (text and possibly OID) as well as - * further information on these professions. Object identifiers for the - * component namingAuthorityId are grouped under the OID-branch - * id-isis-at-namingAuthorities and must be applied for. - * <li>See - * http://www.teletrust.de/anwend.asp?Id=30200&Sprache=E_&HomePG=0 for - * an application form and http://www.teletrust.de/links.asp?id=30220,11 - * for an overview of registered naming authorities. - * <li> By means of the data type ProfessionInfo certain professions, - * specializations, disciplines, fields of activity, etc. are identified. A - * profession is represented by one or more text strings, resp. profession OIDs - * in the fields professionItems and professionOIDs and by a registration number - * in the field registrationNumber. An indication in text form must always be - * present, whereas the other indications are optional. The component - * addProfessionInfo may contain additional applicationspecific information in - * DER-encoded form. - * </ul> - * <p> - * By means of different namingAuthority-OIDs or profession OIDs hierarchies of - * professions, specializations, disciplines, fields of activity, etc. can be - * expressed. The issuing admission authority should always be indicated (field - * admissionAuthority), whenever a registration number is presented. Still, - * information on admissions can be given without indicating an admission or a - * naming authority by the exclusive use of the component professionItems. In - * this case the certification authority is responsible for the verification of - * the admission information. - * <p> - * This attribute is single-valued. Still, several admissions can be captured in - * the sequence structure of the component contentsOfAdmissions of - * AdmissionSyntax or in the component professionInfos of Admissions. The - * component admissionAuthority of AdmissionSyntax serves as default value for - * the component admissionAuthority of Admissions. Within the latter component - * the default value can be overwritten, in case that another authority is - * responsible. The component namingAuthority of Admissions serves as a default - * value for the component namingAuthority of ProfessionInfo. Within the latter - * component the default value can be overwritten, in case that another naming - * authority needs to be recorded. - * <p> - * The length of the string objects is limited to 128 characters. It is - * recommended to indicate a namingAuthorityURL in all issued attribute - * certificates. If a namingAuthorityURL is indicated, the field professionItems - * of ProfessionInfo should contain only registered titles. If the field - * professionOIDs exists, it has to contain the OIDs of the professions listed - * in professionItems in the same order. In general, the field professionInfos - * should contain only one entry, unless the admissions that are to be listed - * are logically connected (e.g. they have been issued under the same admission - * number). - * - * @see org.bouncycastle.asn1.isismtt.x509.Admissions - * @see org.bouncycastle.asn1.isismtt.x509.ProfessionInfo - * @see org.bouncycastle.asn1.isismtt.x509.NamingAuthority - */ -public class AdmissionSyntax - extends ASN1Object -{ - - private GeneralName admissionAuthority; - - private ASN1Sequence contentsOfAdmissions; - - public static AdmissionSyntax getInstance(Object obj) - { - if (obj == null || obj instanceof AdmissionSyntax) - { - return (AdmissionSyntax)obj; - } - - if (obj instanceof ASN1Sequence) - { - return new AdmissionSyntax((ASN1Sequence)obj); - } - - throw new IllegalArgumentException("illegal object in getInstance: " - + obj.getClass().getName()); - } - - /** - * Constructor from ASN1Sequence. - * <p/> - * The sequence is of type ProcurationSyntax: - * <p/> - * <pre> - * AdmissionSyntax ::= SEQUENCE - * { - * admissionAuthority GeneralName OPTIONAL, - * contentsOfAdmissions SEQUENCE OF Admissions - * } - * <p/> - * Admissions ::= SEQUENCE - * { - * admissionAuthority [0] EXPLICIT GeneralName OPTIONAL - * namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL - * professionInfos SEQUENCE OF ProfessionInfo - * } - * <p/> - * NamingAuthority ::= SEQUENCE - * { - * namingAuthorityId OBJECT IDENTIFIER OPTIONAL, - * namingAuthorityUrl IA5String OPTIONAL, - * namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL - * } - * <p/> - * ProfessionInfo ::= SEQUENCE - * { - * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, - * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), - * professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, - * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, - * addProfessionInfo OCTET STRING OPTIONAL - * } - * </pre> - * - * @param seq The ASN.1 sequence. - */ - private AdmissionSyntax(ASN1Sequence seq) - { - switch (seq.size()) - { - case 1: - contentsOfAdmissions = DERSequence.getInstance(seq.getObjectAt(0)); - break; - case 2: - admissionAuthority = GeneralName.getInstance(seq.getObjectAt(0)); - contentsOfAdmissions = DERSequence.getInstance(seq.getObjectAt(1)); - break; - default: - throw new IllegalArgumentException("Bad sequence size: " + seq.size()); - } - } - - /** - * Constructor from given details. - * - * @param admissionAuthority The admission authority. - * @param contentsOfAdmissions The admissions. - */ - public AdmissionSyntax(GeneralName admissionAuthority, ASN1Sequence contentsOfAdmissions) - { - this.admissionAuthority = admissionAuthority; - this.contentsOfAdmissions = contentsOfAdmissions; - } - - /** - * Produce an object suitable for an ASN1OutputStream. - * <p> - * Returns: - * <pre> - * AdmissionSyntax ::= SEQUENCE - * { - * admissionAuthority GeneralName OPTIONAL, - * contentsOfAdmissions SEQUENCE OF Admissions - * } - * - * Admissions ::= SEQUENCE - * { - * admissionAuthority [0] EXPLICIT GeneralName OPTIONAL - * namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL - * professionInfos SEQUENCE OF ProfessionInfo - * } - * - * NamingAuthority ::= SEQUENCE - * { - * namingAuthorityId OBJECT IDENTIFIER OPTIONAL, - * namingAuthorityUrl IA5String OPTIONAL, - * namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL - * } - * - * ProfessionInfo ::= SEQUENCE - * { - * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, - * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), - * professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, - * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, - * addProfessionInfo OCTET STRING OPTIONAL - * } - * </pre> - * - * @return a DERObject - */ - public ASN1Primitive toASN1Primitive() - { - ASN1EncodableVector vec = new ASN1EncodableVector(); - if (admissionAuthority != null) - { - vec.add(admissionAuthority); - } - vec.add(contentsOfAdmissions); - return new DERSequence(vec); - } - - /** - * @return Returns the admissionAuthority if present, null otherwise. - */ - public GeneralName getAdmissionAuthority() - { - return admissionAuthority; - } - - /** - * @return Returns the contentsOfAdmissions. - */ - public Admissions[] getContentsOfAdmissions() - { - Admissions[] admissions = new Admissions[contentsOfAdmissions.size()]; - int count = 0; - for (Enumeration e = contentsOfAdmissions.getObjects(); e.hasMoreElements();) - { - admissions[count++] = Admissions.getInstance(e.nextElement()); - } - return admissions; - } -} diff --git a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/Admissions.java b/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/Admissions.java deleted file mode 100644 index 48a3e470..00000000 --- a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/Admissions.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.bouncycastle.asn1.isismtt.x509; - -import java.util.Enumeration; - -import org.bouncycastle.asn1.ASN1Encodable; -import org.bouncycastle.asn1.ASN1EncodableVector; -import org.bouncycastle.asn1.ASN1Object; -import org.bouncycastle.asn1.ASN1Primitive; -import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.ASN1TaggedObject; -import org.bouncycastle.asn1.DERSequence; -import org.bouncycastle.asn1.DERTaggedObject; -import org.bouncycastle.asn1.x509.GeneralName; - -/** - * An Admissions structure. - * <pre> - * Admissions ::= SEQUENCE - * { - * admissionAuthority [0] EXPLICIT GeneralName OPTIONAL - * namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL - * professionInfos SEQUENCE OF ProfessionInfo - * } - * </pre> - * - * @see org.bouncycastle.asn1.isismtt.x509.AdmissionSyntax - * @see org.bouncycastle.asn1.isismtt.x509.ProfessionInfo - * @see org.bouncycastle.asn1.isismtt.x509.NamingAuthority - */ -public class Admissions - extends ASN1Object -{ - - private GeneralName admissionAuthority; - - private NamingAuthority namingAuthority; - - private ASN1Sequence professionInfos; - - public static Admissions getInstance(Object obj) - { - if (obj == null || obj instanceof Admissions) - { - return (Admissions)obj; - } - - if (obj instanceof ASN1Sequence) - { - return new Admissions((ASN1Sequence)obj); - } - - throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName()); - } - - /** - * Constructor from ASN1Sequence. - * <p/> - * The sequence is of type ProcurationSyntax: - * <p/> - * <pre> - * Admissions ::= SEQUENCE - * { - * admissionAuthority [0] EXPLICIT GeneralName OPTIONAL - * namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL - * professionInfos SEQUENCE OF ProfessionInfo - * } - * </pre> - * - * @param seq The ASN.1 sequence. - */ - private Admissions(ASN1Sequence seq) - { - if (seq.size() > 3) - { - throw new IllegalArgumentException("Bad sequence size: " - + seq.size()); - } - Enumeration e = seq.getObjects(); - - ASN1Encodable o = (ASN1Encodable)e.nextElement(); - if (o instanceof ASN1TaggedObject) - { - switch (((ASN1TaggedObject)o).getTagNo()) - { - case 0: - admissionAuthority = GeneralName.getInstance((ASN1TaggedObject)o, true); - break; - case 1: - namingAuthority = NamingAuthority.getInstance((ASN1TaggedObject)o, true); - break; - default: - throw new IllegalArgumentException("Bad tag number: " + ((ASN1TaggedObject)o).getTagNo()); - } - o = (ASN1Encodable)e.nextElement(); - } - if (o instanceof ASN1TaggedObject) - { - switch (((ASN1TaggedObject)o).getTagNo()) - { - case 1: - namingAuthority = NamingAuthority.getInstance((ASN1TaggedObject)o, true); - break; - default: - throw new IllegalArgumentException("Bad tag number: " + ((ASN1TaggedObject)o).getTagNo()); - } - o = (ASN1Encodable)e.nextElement(); - } - professionInfos = ASN1Sequence.getInstance(o); - if (e.hasMoreElements()) - { - throw new IllegalArgumentException("Bad object encountered: " - + e.nextElement().getClass()); - } - } - - /** - * Constructor from a given details. - * <p> - * Parameter <code>professionInfos</code> is mandatory. - * - * @param admissionAuthority The admission authority. - * @param namingAuthority The naming authority. - * @param professionInfos The profession infos. - */ - public Admissions(GeneralName admissionAuthority, - NamingAuthority namingAuthority, ProfessionInfo[] professionInfos) - { - this.admissionAuthority = admissionAuthority; - this.namingAuthority = namingAuthority; - this.professionInfos = new DERSequence(professionInfos); - } - - public GeneralName getAdmissionAuthority() - { - return admissionAuthority; - } - - public NamingAuthority getNamingAuthority() - { - return namingAuthority; - } - - public ProfessionInfo[] getProfessionInfos() - { - ProfessionInfo[] infos = new ProfessionInfo[professionInfos.size()]; - int count = 0; - for (Enumeration e = professionInfos.getObjects(); e.hasMoreElements();) - { - infos[count++] = ProfessionInfo.getInstance(e.nextElement()); - } - return infos; - } - - /** - * Produce an object suitable for an ASN1OutputStream. - * <p> - * Returns: - * <pre> - * Admissions ::= SEQUENCE - * { - * admissionAuthority [0] EXPLICIT GeneralName OPTIONAL - * namingAuthority [1] EXPLICIT NamingAuthority OPTIONAL - * professionInfos SEQUENCE OF ProfessionInfo - * } - * </pre> - * - * @return an ASN1Primitive - */ - public ASN1Primitive toASN1Primitive() - { - ASN1EncodableVector vec = new ASN1EncodableVector(); - - if (admissionAuthority != null) - { - vec.add(new DERTaggedObject(true, 0, admissionAuthority)); - } - if (namingAuthority != null) - { - vec.add(new DERTaggedObject(true, 1, namingAuthority)); - } - vec.add(professionInfos); - - return new DERSequence(vec); - } -} diff --git a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/DeclarationOfMajority.java b/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/DeclarationOfMajority.java deleted file mode 100644 index 987c5907..00000000 --- a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/DeclarationOfMajority.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.bouncycastle.asn1.isismtt.x509; - -import org.bouncycastle.asn1.ASN1Boolean; -import org.bouncycastle.asn1.ASN1Choice; -import org.bouncycastle.asn1.ASN1EncodableVector; -import org.bouncycastle.asn1.ASN1GeneralizedTime; -import org.bouncycastle.asn1.ASN1Integer; -import org.bouncycastle.asn1.ASN1Object; -import org.bouncycastle.asn1.ASN1Primitive; -import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.ASN1TaggedObject; -import org.bouncycastle.asn1.DERPrintableString; -import org.bouncycastle.asn1.DERSequence; -import org.bouncycastle.asn1.DERTaggedObject; - -/** - * A declaration of majority. - * - * <pre> - * DeclarationOfMajoritySyntax ::= CHOICE - * { - * notYoungerThan [0] IMPLICIT INTEGER, - * fullAgeAtCountry [1] IMPLICIT SEQUENCE - * { - * fullAge BOOLEAN DEFAULT TRUE, - * country PrintableString (SIZE(2)) - * } - * dateOfBirth [2] IMPLICIT GeneralizedTime - * } - * </pre> - * <p> - * 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 declaration; - - public DeclarationOfMajority(int notYoungerThan) - { - declaration = 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) - { - declaration = 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)); - - declaration = new DERTaggedObject(false, 1, new DERSequence(v)); - } - } - - public DeclarationOfMajority(ASN1GeneralizedTime dateOfBirth) - { - declaration = 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()); - } - declaration = o; - } - - /** - * Produce an object suitable for an ASN1OutputStream. - * <p> - * Returns: - * <pre> - * DeclarationOfMajoritySyntax ::= CHOICE - * { - * notYoungerThan [0] IMPLICIT INTEGER, - * fullAgeAtCountry [1] IMPLICIT SEQUENCE - * { - * fullAge BOOLEAN DEFAULT TRUE, - * country PrintableString (SIZE(2)) - * } - * dateOfBirth [2] IMPLICIT GeneralizedTime - * } - * </pre> - * - * @return a DERObject - */ - public ASN1Primitive toASN1Primitive() - { - return declaration; - } - - public int getType() - { - return declaration.getTagNo(); - } - - /** - * @return notYoungerThan if that's what we are, -1 otherwise - */ - public int notYoungerThan() - { - if (declaration.getTagNo() != 0) - { - return -1; - } - - return ASN1Integer.getInstance(declaration, false).getValue().intValue(); - } - - public ASN1Sequence fullAgeAtCountry() - { - if (declaration.getTagNo() != 1) - { - return null; - } - - return ASN1Sequence.getInstance(declaration, false); - } - - public ASN1GeneralizedTime getDateOfBirth() - { - if (declaration.getTagNo() != 2) - { - return null; - } - - return ASN1GeneralizedTime.getInstance(declaration, false); - } -} diff --git a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/MonetaryLimit.java b/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/MonetaryLimit.java deleted file mode 100644 index 7425287e..00000000 --- a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/MonetaryLimit.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.bouncycastle.asn1.isismtt.x509; - -import java.math.BigInteger; -import java.util.Enumeration; - -import org.bouncycastle.asn1.ASN1EncodableVector; -import org.bouncycastle.asn1.ASN1Integer; -import org.bouncycastle.asn1.ASN1Object; -import org.bouncycastle.asn1.ASN1Primitive; -import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.DERPrintableString; -import org.bouncycastle.asn1.DERSequence; - -/** - * Monetary limit for transactions. The QcEuMonetaryLimit QC statement MUST be - * used in new certificates in place of the extension/attribute MonetaryLimit - * since January 1, 2004. For the sake of backward compatibility with - * certificates already in use, components SHOULD support MonetaryLimit (as well - * as QcEuLimitValue). - * <p> - * Indicates a monetary limit within which the certificate holder is authorized - * to act. (This value DOES NOT express a limit on the liability of the - * certification authority). - * <pre> - * MonetaryLimitSyntax ::= SEQUENCE - * { - * currency PrintableString (SIZE(3)), - * amount INTEGER, - * exponent INTEGER - * } - * </pre> - * <p> - * currency must be the ISO code. - * <p> - * value = amount�10*exponent - */ -public class MonetaryLimit - extends ASN1Object -{ - DERPrintableString currency; - ASN1Integer amount; - ASN1Integer exponent; - - public static MonetaryLimit getInstance(Object obj) - { - if (obj == null || obj instanceof MonetaryLimit) - { - return (MonetaryLimit)obj; - } - - if (obj instanceof ASN1Sequence) - { - return new MonetaryLimit(ASN1Sequence.getInstance(obj)); - } - - throw new IllegalArgumentException("unknown object in getInstance"); - } - - private MonetaryLimit(ASN1Sequence seq) - { - if (seq.size() != 3) - { - throw new IllegalArgumentException("Bad sequence size: " - + seq.size()); - } - Enumeration e = seq.getObjects(); - currency = DERPrintableString.getInstance(e.nextElement()); - amount = ASN1Integer.getInstance(e.nextElement()); - exponent = ASN1Integer.getInstance(e.nextElement()); - } - - /** - * Constructor from a given details. - * <p> - * value = amount�10^exponent - * - * @param currency The currency. Must be the ISO code. - * @param amount The amount - * @param exponent The exponent - */ - public MonetaryLimit(String currency, int amount, int exponent) - { - this.currency = new DERPrintableString(currency, true); - this.amount = new ASN1Integer(amount); - this.exponent = new ASN1Integer(exponent); - } - - public String getCurrency() - { - return currency.getString(); - } - - public BigInteger getAmount() - { - return amount.getValue(); - } - - public BigInteger getExponent() - { - return exponent.getValue(); - } - - /** - * Produce an object suitable for an ASN1OutputStream. - * <p> - * Returns: - * <pre> - * MonetaryLimitSyntax ::= SEQUENCE - * { - * currency PrintableString (SIZE(3)), - * amount INTEGER, - * exponent INTEGER - * } - * </pre> - * - * @return a DERObject - */ - public ASN1Primitive toASN1Primitive() - { - ASN1EncodableVector seq = new ASN1EncodableVector(); - seq.add(currency); - seq.add(amount); - seq.add(exponent); - - return new DERSequence(seq); - } - -} diff --git a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/NamingAuthority.java b/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/NamingAuthority.java deleted file mode 100644 index 17162649..00000000 --- a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/NamingAuthority.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.bouncycastle.asn1.isismtt.x509; - -import java.util.Enumeration; - -import org.bouncycastle.asn1.ASN1Encodable; -import org.bouncycastle.asn1.ASN1EncodableVector; -import org.bouncycastle.asn1.ASN1Object; -import org.bouncycastle.asn1.ASN1ObjectIdentifier; -import org.bouncycastle.asn1.ASN1Primitive; -import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.ASN1String; -import org.bouncycastle.asn1.ASN1TaggedObject; -import org.bouncycastle.asn1.DERIA5String; -import org.bouncycastle.asn1.DERSequence; -import org.bouncycastle.asn1.isismtt.ISISMTTObjectIdentifiers; -import org.bouncycastle.asn1.x500.DirectoryString; - -/** - * Names of authorities which are responsible for the administration of title - * registers. - * - * <pre> - * NamingAuthority ::= SEQUENCE - * { - * namingAuthorityId OBJECT IDENTIFIER OPTIONAL, - * namingAuthorityUrl IA5String OPTIONAL, - * namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL - * } - * </pre> - * @see org.bouncycastle.asn1.isismtt.x509.AdmissionSyntax - * - */ -public class NamingAuthority - extends ASN1Object -{ - - /** - * Profession OIDs should always be defined under the OID branch of the - * responsible naming authority. At the time of this writing, the work group - * �Recht, Wirtschaft, Steuern� (�Law, Economy, Taxes�) is registered as the - * first naming authority under the OID id-isismtt-at-namingAuthorities. - */ - public static final ASN1ObjectIdentifier id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern = - new ASN1ObjectIdentifier(ISISMTTObjectIdentifiers.id_isismtt_at_namingAuthorities + ".1"); - - private ASN1ObjectIdentifier namingAuthorityId; - private String namingAuthorityUrl; - private DirectoryString namingAuthorityText; - - public static NamingAuthority getInstance(Object obj) - { - if (obj == null || obj instanceof NamingAuthority) - { - return (NamingAuthority)obj; - } - - if (obj instanceof ASN1Sequence) - { - return new NamingAuthority((ASN1Sequence)obj); - } - - throw new IllegalArgumentException("illegal object in getInstance: " - + obj.getClass().getName()); - } - - public static NamingAuthority getInstance(ASN1TaggedObject obj, boolean explicit) - { - return getInstance(ASN1Sequence.getInstance(obj, explicit)); - } - - /** - * Constructor from ASN1Sequence. - * <p/> - * <p/> - * <pre> - * NamingAuthority ::= SEQUENCE - * { - * namingAuthorityId OBJECT IDENTIFIER OPTIONAL, - * namingAuthorityUrl IA5String OPTIONAL, - * namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL - * } - * </pre> - * - * @param seq The ASN.1 sequence. - */ - private NamingAuthority(ASN1Sequence seq) - { - - if (seq.size() > 3) - { - throw new IllegalArgumentException("Bad sequence size: " - + seq.size()); - } - - Enumeration e = seq.getObjects(); - - if (e.hasMoreElements()) - { - ASN1Encodable o = (ASN1Encodable)e.nextElement(); - if (o instanceof ASN1ObjectIdentifier) - { - namingAuthorityId = (ASN1ObjectIdentifier)o; - } - else if (o instanceof DERIA5String) - { - namingAuthorityUrl = DERIA5String.getInstance(o).getString(); - } - else if (o instanceof ASN1String) - { - namingAuthorityText = DirectoryString.getInstance(o); - } - else - { - throw new IllegalArgumentException("Bad object encountered: " - + o.getClass()); - } - } - if (e.hasMoreElements()) - { - ASN1Encodable o = (ASN1Encodable)e.nextElement(); - if (o instanceof DERIA5String) - { - namingAuthorityUrl = DERIA5String.getInstance(o).getString(); - } - else if (o instanceof ASN1String) - { - namingAuthorityText = DirectoryString.getInstance(o); - } - else - { - throw new IllegalArgumentException("Bad object encountered: " - + o.getClass()); - } - } - if (e.hasMoreElements()) - { - ASN1Encodable o = (ASN1Encodable)e.nextElement(); - if (o instanceof ASN1String) - { - namingAuthorityText = DirectoryString.getInstance(o); - } - else - { - throw new IllegalArgumentException("Bad object encountered: " - + o.getClass()); - } - - } - } - - /** - * @return Returns the namingAuthorityId. - */ - public ASN1ObjectIdentifier getNamingAuthorityId() - { - return namingAuthorityId; - } - - /** - * @return Returns the namingAuthorityText. - */ - public DirectoryString getNamingAuthorityText() - { - return namingAuthorityText; - } - - /** - * @return Returns the namingAuthorityUrl. - */ - public String getNamingAuthorityUrl() - { - return namingAuthorityUrl; - } - - /** - * Constructor from given details. - * <p> - * All parameters can be combined. - * - * @param namingAuthorityId ObjectIdentifier for naming authority. - * @param namingAuthorityUrl URL for naming authority. - * @param namingAuthorityText Textual representation of naming authority. - */ - public NamingAuthority(ASN1ObjectIdentifier namingAuthorityId, - String namingAuthorityUrl, DirectoryString namingAuthorityText) - { - this.namingAuthorityId = namingAuthorityId; - this.namingAuthorityUrl = namingAuthorityUrl; - this.namingAuthorityText = namingAuthorityText; - } - - /** - * Produce an object suitable for an ASN1OutputStream. - * <p> - * Returns: - * <pre> - * NamingAuthority ::= SEQUENCE - * { - * namingAuthorityId OBJECT IDENTIFIER OPTIONAL, - * namingAuthorityUrl IA5String OPTIONAL, - * namingAuthorityText DirectoryString(SIZE(1..128)) OPTIONAL - * } - * </pre> - * - * @return a DERObject - */ - public ASN1Primitive toASN1Primitive() - { - ASN1EncodableVector vec = new ASN1EncodableVector(); - if (namingAuthorityId != null) - { - vec.add(namingAuthorityId); - } - if (namingAuthorityUrl != null) - { - vec.add(new DERIA5String(namingAuthorityUrl, true)); - } - if (namingAuthorityText != null) - { - vec.add(namingAuthorityText); - } - return new DERSequence(vec); - } -} diff --git a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/ProcurationSyntax.java b/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/ProcurationSyntax.java deleted file mode 100644 index b6ab3451..00000000 --- a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/ProcurationSyntax.java +++ /dev/null @@ -1,237 +0,0 @@ -package org.bouncycastle.asn1.isismtt.x509; - -import java.util.Enumeration; - -import org.bouncycastle.asn1.ASN1Encodable; -import org.bouncycastle.asn1.ASN1EncodableVector; -import org.bouncycastle.asn1.ASN1Object; -import org.bouncycastle.asn1.ASN1Primitive; -import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.ASN1TaggedObject; -import org.bouncycastle.asn1.DERPrintableString; -import org.bouncycastle.asn1.DERSequence; -import org.bouncycastle.asn1.DERTaggedObject; -import org.bouncycastle.asn1.x500.DirectoryString; -import org.bouncycastle.asn1.x509.GeneralName; -import org.bouncycastle.asn1.x509.IssuerSerial; - -/** - * Attribute to indicate that the certificate holder may sign in the name of a - * third person. - * <p> - * ISIS-MTT PROFILE: The corresponding ProcurationSyntax contains either the - * name of the person who is represented (subcomponent thirdPerson) or a - * reference to his/her base certificate (in the component signingFor, - * subcomponent certRef), furthermore the optional components country and - * typeSubstitution to indicate the country whose laws apply, and respectively - * the type of procuration (e.g. manager, procuration, custody). - * <p> - * ISIS-MTT PROFILE: The GeneralName MUST be of type directoryName and MAY only - * contain: - RFC3039 attributes, except pseudonym (countryName, commonName, - * surname, givenName, serialNumber, organizationName, organizationalUnitName, - * stateOrProvincename, localityName, postalAddress) and - SubjectDirectoryName - * attributes (title, dateOfBirth, placeOfBirth, gender, countryOfCitizenship, - * countryOfResidence and NameAtBirth). - * - * <pre> - * ProcurationSyntax ::= SEQUENCE { - * country [1] EXPLICIT PrintableString(SIZE(2)) OPTIONAL, - * typeOfSubstitution [2] EXPLICIT DirectoryString (SIZE(1..128)) OPTIONAL, - * signingFor [3] EXPLICIT SigningFor - * } - * - * SigningFor ::= CHOICE - * { - * thirdPerson GeneralName, - * certRef IssuerSerial - * } - * </pre> - * - */ -public class ProcurationSyntax - extends ASN1Object -{ - private String country; - private DirectoryString typeOfSubstitution; - - private GeneralName thirdPerson; - private IssuerSerial certRef; - - public static ProcurationSyntax getInstance(Object obj) - { - if (obj == null || obj instanceof ProcurationSyntax) - { - return (ProcurationSyntax)obj; - } - - if (obj instanceof ASN1Sequence) - { - return new ProcurationSyntax((ASN1Sequence)obj); - } - - throw new IllegalArgumentException("illegal object in getInstance: " - + obj.getClass().getName()); - } - - /** - * Constructor from ASN1Sequence. - * <p/> - * The sequence is of type ProcurationSyntax: - * <p/> - * <pre> - * ProcurationSyntax ::= SEQUENCE { - * country [1] EXPLICIT PrintableString(SIZE(2)) OPTIONAL, - * typeOfSubstitution [2] EXPLICIT DirectoryString (SIZE(1..128)) OPTIONAL, - * signingFor [3] EXPLICIT SigningFor - * } - * <p/> - * SigningFor ::= CHOICE - * { - * thirdPerson GeneralName, - * certRef IssuerSerial - * } - * </pre> - * - * @param seq The ASN.1 sequence. - */ - private ProcurationSyntax(ASN1Sequence seq) - { - if (seq.size() < 1 || seq.size() > 3) - { - throw new IllegalArgumentException("Bad sequence size: " + seq.size()); - } - Enumeration e = seq.getObjects(); - - while (e.hasMoreElements()) - { - ASN1TaggedObject o = ASN1TaggedObject.getInstance(e.nextElement()); - switch (o.getTagNo()) - { - case 1: - country = DERPrintableString.getInstance(o, true).getString(); - break; - case 2: - typeOfSubstitution = DirectoryString.getInstance(o, true); - break; - case 3: - ASN1Encodable signingFor = o.getObject(); - if (signingFor instanceof ASN1TaggedObject) - { - thirdPerson = GeneralName.getInstance(signingFor); - } - else - { - certRef = IssuerSerial.getInstance(signingFor); - } - break; - default: - throw new IllegalArgumentException("Bad tag number: " + o.getTagNo()); - } - } - } - - /** - * Constructor from a given details. - * <p> - * Either <code>generalName</code> or <code>certRef</code> MUST be - * <code>null</code>. - * - * @param country The country code whose laws apply. - * @param typeOfSubstitution The type of procuration. - * @param certRef Reference to certificate of the person who is represented. - */ - public ProcurationSyntax( - String country, - DirectoryString typeOfSubstitution, - IssuerSerial certRef) - { - this.country = country; - this.typeOfSubstitution = typeOfSubstitution; - this.thirdPerson = null; - this.certRef = certRef; - } - - /** - * Constructor from a given details. - * <p> - * Either <code>generalName</code> or <code>certRef</code> MUST be - * <code>null</code>. - * - * @param country The country code whose laws apply. - * @param typeOfSubstitution The type of procuration. - * @param thirdPerson The GeneralName of the person who is represented. - */ - public ProcurationSyntax( - String country, - DirectoryString typeOfSubstitution, - GeneralName thirdPerson) - { - this.country = country; - this.typeOfSubstitution = typeOfSubstitution; - this.thirdPerson = thirdPerson; - this.certRef = null; - } - - public String getCountry() - { - return country; - } - - public DirectoryString getTypeOfSubstitution() - { - return typeOfSubstitution; - } - - public GeneralName getThirdPerson() - { - return thirdPerson; - } - - public IssuerSerial getCertRef() - { - return certRef; - } - - /** - * Produce an object suitable for an ASN1OutputStream. - * <p> - * Returns: - * <pre> - * ProcurationSyntax ::= SEQUENCE { - * country [1] EXPLICIT PrintableString(SIZE(2)) OPTIONAL, - * typeOfSubstitution [2] EXPLICIT DirectoryString (SIZE(1..128)) OPTIONAL, - * signingFor [3] EXPLICIT SigningFor - * } - * - * SigningFor ::= CHOICE - * { - * thirdPerson GeneralName, - * certRef IssuerSerial - * } - * </pre> - * - * @return a DERObject - */ - public ASN1Primitive toASN1Primitive() - { - ASN1EncodableVector vec = new ASN1EncodableVector(); - if (country != null) - { - vec.add(new DERTaggedObject(true, 1, new DERPrintableString(country, true))); - } - if (typeOfSubstitution != null) - { - vec.add(new DERTaggedObject(true, 2, typeOfSubstitution)); - } - if (thirdPerson != null) - { - vec.add(new DERTaggedObject(true, 3, thirdPerson)); - } - else - { - vec.add(new DERTaggedObject(true, 3, certRef)); - } - - return new DERSequence(vec); - } -} diff --git a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/ProfessionInfo.java b/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/ProfessionInfo.java deleted file mode 100644 index 67737f69..00000000 --- a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/ProfessionInfo.java +++ /dev/null @@ -1,407 +0,0 @@ -package org.bouncycastle.asn1.isismtt.x509; - -import java.util.Enumeration; - -import org.bouncycastle.asn1.ASN1Encodable; -import org.bouncycastle.asn1.ASN1EncodableVector; -import org.bouncycastle.asn1.ASN1Object; -import org.bouncycastle.asn1.ASN1ObjectIdentifier; -import org.bouncycastle.asn1.ASN1OctetString; -import org.bouncycastle.asn1.ASN1Primitive; -import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.ASN1TaggedObject; -import org.bouncycastle.asn1.DEROctetString; -import org.bouncycastle.asn1.DERPrintableString; -import org.bouncycastle.asn1.DERSequence; -import org.bouncycastle.asn1.DERTaggedObject; -import org.bouncycastle.asn1.x500.DirectoryString; - -/** - * Professions, specializations, disciplines, fields of activity, etc. - * - * <pre> - * ProfessionInfo ::= SEQUENCE - * { - * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, - * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), - * professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, - * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, - * addProfessionInfo OCTET STRING OPTIONAL - * } - * </pre> - * - * @see org.bouncycastle.asn1.isismtt.x509.AdmissionSyntax - */ -public class ProfessionInfo - extends ASN1Object -{ - - /** - * Rechtsanw�ltin - */ - public static final ASN1ObjectIdentifier Rechtsanwltin = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".1"); - - /** - * Rechtsanwalt - */ - public static final ASN1ObjectIdentifier Rechtsanwalt = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".2"); - - /** - * Rechtsbeistand - */ - public static final ASN1ObjectIdentifier Rechtsbeistand = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".3"); - - /** - * Steuerberaterin - */ - public static final ASN1ObjectIdentifier Steuerberaterin = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".4"); - - /** - * Steuerberater - */ - public static final ASN1ObjectIdentifier Steuerberater = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".5"); - - /** - * Steuerbevollm�chtigte - */ - public static final ASN1ObjectIdentifier Steuerbevollmchtigte = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".6"); - - /** - * Steuerbevollm�chtigter - */ - public static final ASN1ObjectIdentifier Steuerbevollmchtigter = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".7"); - - /** - * Notarin - */ - public static final ASN1ObjectIdentifier Notarin = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".8"); - - /** - * Notar - */ - public static final ASN1ObjectIdentifier Notar = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".9"); - - /** - * Notarvertreterin - */ - public static final ASN1ObjectIdentifier Notarvertreterin = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".10"); - - /** - * Notarvertreter - */ - public static final ASN1ObjectIdentifier Notarvertreter = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".11"); - - /** - * Notariatsverwalterin - */ - public static final ASN1ObjectIdentifier Notariatsverwalterin = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".12"); - - /** - * Notariatsverwalter - */ - public static final ASN1ObjectIdentifier Notariatsverwalter = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".13"); - - /** - * Wirtschaftspr�ferin - */ - public static final ASN1ObjectIdentifier Wirtschaftsprferin = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".14"); - - /** - * Wirtschaftspr�fer - */ - public static final ASN1ObjectIdentifier Wirtschaftsprfer = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".15"); - - /** - * Vereidigte Buchpr�ferin - */ - public static final ASN1ObjectIdentifier VereidigteBuchprferin = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".16"); - - /** - * Vereidigter Buchpr�fer - */ - public static final ASN1ObjectIdentifier VereidigterBuchprfer = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".17"); - - /** - * Patentanw�ltin - */ - public static final ASN1ObjectIdentifier Patentanwltin = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".18"); - - /** - * Patentanwalt - */ - public static final ASN1ObjectIdentifier Patentanwalt = new ASN1ObjectIdentifier( - NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".19"); - - private NamingAuthority namingAuthority; - - private ASN1Sequence professionItems; - - private ASN1Sequence professionOIDs; - - private String registrationNumber; - - private ASN1OctetString addProfessionInfo; - - public static ProfessionInfo getInstance(Object obj) - { - if (obj == null || obj instanceof ProfessionInfo) - { - return (ProfessionInfo)obj; - } - - if (obj instanceof ASN1Sequence) - { - return new ProfessionInfo((ASN1Sequence)obj); - } - - throw new IllegalArgumentException("illegal object in getInstance: " - + obj.getClass().getName()); - } - - /** - * Constructor from ASN1Sequence. - * <p/> - * <p/> - * <pre> - * ProfessionInfo ::= SEQUENCE - * { - * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, - * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), - * professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, - * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, - * addProfessionInfo OCTET STRING OPTIONAL - * } - * </pre> - * - * @param seq The ASN.1 sequence. - */ - private ProfessionInfo(ASN1Sequence seq) - { - if (seq.size() > 5) - { - throw new IllegalArgumentException("Bad sequence size: " - + seq.size()); - } - - Enumeration e = seq.getObjects(); - - ASN1Encodable o = (ASN1Encodable)e.nextElement(); - - if (o instanceof ASN1TaggedObject) - { - if (((ASN1TaggedObject)o).getTagNo() != 0) - { - throw new IllegalArgumentException("Bad tag number: " - + ((ASN1TaggedObject)o).getTagNo()); - } - namingAuthority = NamingAuthority.getInstance((ASN1TaggedObject)o, true); - o = (ASN1Encodable)e.nextElement(); - } - - professionItems = ASN1Sequence.getInstance(o); - - if (e.hasMoreElements()) - { - o = (ASN1Encodable)e.nextElement(); - if (o instanceof ASN1Sequence) - { - professionOIDs = ASN1Sequence.getInstance(o); - } - else if (o instanceof DERPrintableString) - { - registrationNumber = DERPrintableString.getInstance(o).getString(); - } - else if (o instanceof ASN1OctetString) - { - addProfessionInfo = ASN1OctetString.getInstance(o); - } - else - { - throw new IllegalArgumentException("Bad object encountered: " - + o.getClass()); - } - } - if (e.hasMoreElements()) - { - o = (ASN1Encodable)e.nextElement(); - if (o instanceof DERPrintableString) - { - registrationNumber = DERPrintableString.getInstance(o).getString(); - } - else if (o instanceof DEROctetString) - { - addProfessionInfo = (DEROctetString)o; - } - else - { - throw new IllegalArgumentException("Bad object encountered: " - + o.getClass()); - } - } - if (e.hasMoreElements()) - { - o = (ASN1Encodable)e.nextElement(); - if (o instanceof DEROctetString) - { - addProfessionInfo = (DEROctetString)o; - } - else - { - throw new IllegalArgumentException("Bad object encountered: " - + o.getClass()); - } - } - - } - - /** - * Constructor from given details. - * <p> - * <code>professionItems</code> is mandatory, all other parameters are - * optional. - * - * @param namingAuthority The naming authority. - * @param professionItems Directory strings of the profession. - * @param professionOIDs DERObjectIdentfier objects for the - * profession. - * @param registrationNumber Registration number. - * @param addProfessionInfo Additional infos in encoded form. - */ - public ProfessionInfo(NamingAuthority namingAuthority, - DirectoryString[] professionItems, ASN1ObjectIdentifier[] professionOIDs, - String registrationNumber, ASN1OctetString addProfessionInfo) - { - this.namingAuthority = namingAuthority; - ASN1EncodableVector v = new ASN1EncodableVector(); - for (int i = 0; i != professionItems.length; i++) - { - v.add(professionItems[i]); - } - this.professionItems = new DERSequence(v); - if (professionOIDs != null) - { - v = new ASN1EncodableVector(); - for (int i = 0; i != professionOIDs.length; i++) - { - v.add(professionOIDs[i]); - } - this.professionOIDs = new DERSequence(v); - } - this.registrationNumber = registrationNumber; - this.addProfessionInfo = addProfessionInfo; - } - - /** - * Produce an object suitable for an ASN1OutputStream. - * <p> - * Returns: - * <pre> - * ProfessionInfo ::= SEQUENCE - * { - * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, - * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), - * professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, - * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, - * addProfessionInfo OCTET STRING OPTIONAL - * } - * </pre> - * - * @return a DERObject - */ - public ASN1Primitive toASN1Primitive() - { - ASN1EncodableVector vec = new ASN1EncodableVector(); - if (namingAuthority != null) - { - vec.add(new DERTaggedObject(true, 0, namingAuthority)); - } - vec.add(professionItems); - if (professionOIDs != null) - { - vec.add(professionOIDs); - } - if (registrationNumber != null) - { - vec.add(new DERPrintableString(registrationNumber, true)); - } - if (addProfessionInfo != null) - { - vec.add(addProfessionInfo); - } - return new DERSequence(vec); - } - - /** - * @return Returns the addProfessionInfo. - */ - public ASN1OctetString getAddProfessionInfo() - { - return addProfessionInfo; - } - - /** - * @return Returns the namingAuthority. - */ - public NamingAuthority getNamingAuthority() - { - return namingAuthority; - } - - /** - * @return Returns the professionItems. - */ - public DirectoryString[] getProfessionItems() - { - DirectoryString[] items = new DirectoryString[professionItems.size()]; - int count = 0; - for (Enumeration e = professionItems.getObjects(); e.hasMoreElements();) - { - items[count++] = DirectoryString.getInstance(e.nextElement()); - } - return items; - } - - /** - * @return Returns the professionOIDs. - */ - public ASN1ObjectIdentifier[] getProfessionOIDs() - { - if (professionOIDs == null) - { - return new ASN1ObjectIdentifier[0]; - } - ASN1ObjectIdentifier[] oids = new ASN1ObjectIdentifier[professionOIDs.size()]; - int count = 0; - for (Enumeration e = professionOIDs.getObjects(); e.hasMoreElements();) - { - oids[count++] = ASN1ObjectIdentifier.getInstance(e.nextElement()); - } - return oids; - } - - /** - * @return Returns the registrationNumber. - */ - public String getRegistrationNumber() - { - return registrationNumber; - } -} diff --git a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/Restriction.java b/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/Restriction.java deleted file mode 100644 index 3d06e77b..00000000 --- a/core/src/main/java/org/bouncycastle/asn1/isismtt/x509/Restriction.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.bouncycastle.asn1.isismtt.x509; - -import org.bouncycastle.asn1.ASN1Object; -import org.bouncycastle.asn1.ASN1Primitive; -import org.bouncycastle.asn1.x500.DirectoryString; - -/** - * Some other restriction regarding the usage of this certificate. - * - * <pre> - * RestrictionSyntax ::= DirectoryString (SIZE(1..1024)) - * </pre> - */ -public class Restriction - extends ASN1Object -{ - private DirectoryString restriction; - - public static Restriction getInstance(Object obj) - { - if (obj instanceof Restriction) - { - return (Restriction)obj; - } - - if (obj != null) - { - return new Restriction(DirectoryString.getInstance(obj)); - } - - return null; - } - - /** - * Constructor from DirectoryString. - * <p/> - * The DirectoryString is of type RestrictionSyntax: - * <p/> - * <pre> - * RestrictionSyntax ::= DirectoryString (SIZE(1..1024)) - * </pre> - * - * @param restriction A DirectoryString. - */ - private Restriction(DirectoryString restriction) - { - this.restriction = restriction; - } - - /** - * Constructor from a given details. - * - * @param restriction The describtion of the restriction. - */ - public Restriction(String restriction) - { - this.restriction = new DirectoryString(restriction); - } - - public DirectoryString getRestriction() - { - return restriction; - } - - /** - * Produce an object suitable for an ASN1OutputStream. - * <p> - * Returns: - * <pre> - * RestrictionSyntax ::= DirectoryString (SIZE(1..1024)) - * </pre> - * - * @return a DERObject - */ - public ASN1Primitive toASN1Primitive() - { - return restriction.toASN1Primitive(); - } -} |