init commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Asn1.X500;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.IsisMtt.X509;
|
||||
|
||||
public class AdditionalInformationSyntax : Asn1Encodable
|
||||
{
|
||||
private readonly DirectoryString information;
|
||||
|
||||
public virtual DirectoryString Information => information;
|
||||
|
||||
public static AdditionalInformationSyntax GetInstance(object obj)
|
||||
{
|
||||
if (obj is AdditionalInformationSyntax)
|
||||
{
|
||||
return (AdditionalInformationSyntax)obj;
|
||||
}
|
||||
if (obj is IAsn1String)
|
||||
{
|
||||
return new AdditionalInformationSyntax(DirectoryString.GetInstance(obj));
|
||||
}
|
||||
throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private AdditionalInformationSyntax(DirectoryString information)
|
||||
{
|
||||
this.information = information;
|
||||
}
|
||||
|
||||
public AdditionalInformationSyntax(string information)
|
||||
{
|
||||
this.information = new DirectoryString(information);
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return information.ToAsn1Object();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.IsisMtt.X509;
|
||||
|
||||
public class AdmissionSyntax : Asn1Encodable
|
||||
{
|
||||
private readonly GeneralName admissionAuthority;
|
||||
|
||||
private readonly Asn1Sequence contentsOfAdmissions;
|
||||
|
||||
public virtual GeneralName AdmissionAuthority => admissionAuthority;
|
||||
|
||||
public static AdmissionSyntax GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is AdmissionSyntax)
|
||||
{
|
||||
return (AdmissionSyntax)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new AdmissionSyntax((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private AdmissionSyntax(Asn1Sequence seq)
|
||||
{
|
||||
switch (seq.Count)
|
||||
{
|
||||
case 1:
|
||||
contentsOfAdmissions = Asn1Sequence.GetInstance(seq[0]);
|
||||
break;
|
||||
case 2:
|
||||
admissionAuthority = GeneralName.GetInstance(seq[0]);
|
||||
contentsOfAdmissions = Asn1Sequence.GetInstance(seq[1]);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count);
|
||||
}
|
||||
}
|
||||
|
||||
public AdmissionSyntax(GeneralName admissionAuthority, Asn1Sequence contentsOfAdmissions)
|
||||
{
|
||||
this.admissionAuthority = admissionAuthority;
|
||||
this.contentsOfAdmissions = contentsOfAdmissions;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
|
||||
if (admissionAuthority != null)
|
||||
{
|
||||
asn1EncodableVector.Add(admissionAuthority);
|
||||
}
|
||||
asn1EncodableVector.Add(contentsOfAdmissions);
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
|
||||
public virtual Admissions[] GetContentsOfAdmissions()
|
||||
{
|
||||
Admissions[] array = new Admissions[contentsOfAdmissions.Count];
|
||||
for (int i = 0; i < contentsOfAdmissions.Count; i++)
|
||||
{
|
||||
array[i] = Admissions.GetInstance(contentsOfAdmissions[i]);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.IsisMtt.X509;
|
||||
|
||||
public class Admissions : Asn1Encodable
|
||||
{
|
||||
private readonly GeneralName admissionAuthority;
|
||||
|
||||
private readonly NamingAuthority namingAuthority;
|
||||
|
||||
private readonly Asn1Sequence professionInfos;
|
||||
|
||||
public virtual GeneralName AdmissionAuthority => admissionAuthority;
|
||||
|
||||
public virtual NamingAuthority NamingAuthority => namingAuthority;
|
||||
|
||||
public static Admissions GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is Admissions)
|
||||
{
|
||||
return (Admissions)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new Admissions((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private Admissions(Asn1Sequence seq)
|
||||
{
|
||||
if (seq.Count > 3)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count);
|
||||
}
|
||||
IEnumerator enumerator = seq.GetEnumerator();
|
||||
enumerator.MoveNext();
|
||||
Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.Current;
|
||||
if (asn1Encodable is Asn1TaggedObject)
|
||||
{
|
||||
switch (((Asn1TaggedObject)asn1Encodable).TagNo)
|
||||
{
|
||||
case 0:
|
||||
admissionAuthority = GeneralName.GetInstance((Asn1TaggedObject)asn1Encodable, explicitly: true);
|
||||
break;
|
||||
case 1:
|
||||
namingAuthority = NamingAuthority.GetInstance((Asn1TaggedObject)asn1Encodable, isExplicit: true);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Bad tag number: " + ((Asn1TaggedObject)asn1Encodable).TagNo);
|
||||
}
|
||||
enumerator.MoveNext();
|
||||
asn1Encodable = (Asn1Encodable)enumerator.Current;
|
||||
}
|
||||
if (asn1Encodable is Asn1TaggedObject)
|
||||
{
|
||||
int tagNo = ((Asn1TaggedObject)asn1Encodable).TagNo;
|
||||
if (tagNo != 1)
|
||||
{
|
||||
throw new ArgumentException("Bad tag number: " + ((Asn1TaggedObject)asn1Encodable).TagNo);
|
||||
}
|
||||
namingAuthority = NamingAuthority.GetInstance((Asn1TaggedObject)asn1Encodable, isExplicit: true);
|
||||
enumerator.MoveNext();
|
||||
asn1Encodable = (Asn1Encodable)enumerator.Current;
|
||||
}
|
||||
professionInfos = Asn1Sequence.GetInstance(asn1Encodable);
|
||||
if (enumerator.MoveNext())
|
||||
{
|
||||
throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(enumerator.Current));
|
||||
}
|
||||
}
|
||||
|
||||
public Admissions(GeneralName admissionAuthority, NamingAuthority namingAuthority, ProfessionInfo[] professionInfos)
|
||||
{
|
||||
this.admissionAuthority = admissionAuthority;
|
||||
this.namingAuthority = namingAuthority;
|
||||
this.professionInfos = new DerSequence(professionInfos);
|
||||
}
|
||||
|
||||
public ProfessionInfo[] GetProfessionInfos()
|
||||
{
|
||||
ProfessionInfo[] array = new ProfessionInfo[professionInfos.Count];
|
||||
int num = 0;
|
||||
foreach (Asn1Encodable professionInfo in professionInfos)
|
||||
{
|
||||
array[num++] = ProfessionInfo.GetInstance(professionInfo);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
|
||||
if (admissionAuthority != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 0, admissionAuthority));
|
||||
}
|
||||
if (namingAuthority != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 1, namingAuthority));
|
||||
}
|
||||
asn1EncodableVector.Add(professionInfos);
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.IsisMtt.X509;
|
||||
|
||||
public class DeclarationOfMajority : Asn1Encodable, IAsn1Choice
|
||||
{
|
||||
public enum Choice
|
||||
{
|
||||
NotYoungerThan,
|
||||
FullAgeAtCountry,
|
||||
DateOfBirth
|
||||
}
|
||||
|
||||
private readonly Asn1TaggedObject declaration;
|
||||
|
||||
public Choice Type => (Choice)declaration.TagNo;
|
||||
|
||||
public virtual int NotYoungerThan
|
||||
{
|
||||
get
|
||||
{
|
||||
if (declaration.TagNo == 0)
|
||||
{
|
||||
return DerInteger.GetInstance(declaration, isExplicit: false).Value.IntValue;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Asn1Sequence FullAgeAtCountry
|
||||
{
|
||||
get
|
||||
{
|
||||
Choice tagNo = (Choice)declaration.TagNo;
|
||||
if (tagNo == Choice.FullAgeAtCountry)
|
||||
{
|
||||
return Asn1Sequence.GetInstance(declaration, explicitly: false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual DerGeneralizedTime DateOfBirth
|
||||
{
|
||||
get
|
||||
{
|
||||
Choice tagNo = (Choice)declaration.TagNo;
|
||||
if (tagNo == Choice.DateOfBirth)
|
||||
{
|
||||
return DerGeneralizedTime.GetInstance(declaration, isExplicit: false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public DeclarationOfMajority(int notYoungerThan)
|
||||
{
|
||||
declaration = new DerTaggedObject(explicitly: false, 0, new DerInteger(notYoungerThan));
|
||||
}
|
||||
|
||||
public DeclarationOfMajority(bool fullAge, string country)
|
||||
{
|
||||
if (country.Length > 2)
|
||||
{
|
||||
throw new ArgumentException("country can only be 2 characters");
|
||||
}
|
||||
DerPrintableString derPrintableString = new DerPrintableString(country, validate: true);
|
||||
declaration = new DerTaggedObject(explicitly: false, 1, (!fullAge) ? new DerSequence(DerBoolean.False, derPrintableString) : new DerSequence(derPrintableString));
|
||||
}
|
||||
|
||||
public DeclarationOfMajority(DerGeneralizedTime dateOfBirth)
|
||||
{
|
||||
declaration = new DerTaggedObject(explicitly: false, 2, dateOfBirth);
|
||||
}
|
||||
|
||||
public static DeclarationOfMajority GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is DeclarationOfMajority)
|
||||
{
|
||||
return (DeclarationOfMajority)obj;
|
||||
}
|
||||
if (obj is Asn1TaggedObject)
|
||||
{
|
||||
return new DeclarationOfMajority((Asn1TaggedObject)obj);
|
||||
}
|
||||
throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private DeclarationOfMajority(Asn1TaggedObject o)
|
||||
{
|
||||
if (o.TagNo > 2)
|
||||
{
|
||||
throw new ArgumentException("Bad tag number: " + o.TagNo);
|
||||
}
|
||||
declaration = o;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return declaration;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Math;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.IsisMtt.X509;
|
||||
|
||||
public class MonetaryLimit : Asn1Encodable
|
||||
{
|
||||
private readonly DerPrintableString currency;
|
||||
|
||||
private readonly DerInteger amount;
|
||||
|
||||
private readonly DerInteger exponent;
|
||||
|
||||
public virtual string Currency => currency.GetString();
|
||||
|
||||
public virtual BigInteger Amount => amount.Value;
|
||||
|
||||
public virtual BigInteger Exponent => exponent.Value;
|
||||
|
||||
public static MonetaryLimit GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is MonetaryLimit)
|
||||
{
|
||||
return (MonetaryLimit)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new MonetaryLimit(Asn1Sequence.GetInstance(obj));
|
||||
}
|
||||
throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private MonetaryLimit(Asn1Sequence seq)
|
||||
{
|
||||
if (seq.Count != 3)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count);
|
||||
}
|
||||
currency = DerPrintableString.GetInstance(seq[0]);
|
||||
amount = DerInteger.GetInstance(seq[1]);
|
||||
exponent = DerInteger.GetInstance(seq[2]);
|
||||
}
|
||||
|
||||
public MonetaryLimit(string currency, int amount, int exponent)
|
||||
{
|
||||
this.currency = new DerPrintableString(currency, validate: true);
|
||||
this.amount = new DerInteger(amount);
|
||||
this.exponent = new DerInteger(exponent);
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return new DerSequence(currency, amount, exponent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Asn1.X500;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.IsisMtt.X509;
|
||||
|
||||
public class NamingAuthority : Asn1Encodable
|
||||
{
|
||||
public static readonly DerObjectIdentifier IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern = new DerObjectIdentifier(string.Concat(IsisMttObjectIdentifiers.IdIsisMttATNamingAuthorities, ".1"));
|
||||
|
||||
private readonly DerObjectIdentifier namingAuthorityID;
|
||||
|
||||
private readonly string namingAuthorityUrl;
|
||||
|
||||
private readonly DirectoryString namingAuthorityText;
|
||||
|
||||
public virtual DerObjectIdentifier NamingAuthorityID => namingAuthorityID;
|
||||
|
||||
public virtual DirectoryString NamingAuthorityText => namingAuthorityText;
|
||||
|
||||
public virtual string NamingAuthorityUrl => namingAuthorityUrl;
|
||||
|
||||
public static NamingAuthority GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is NamingAuthority)
|
||||
{
|
||||
return (NamingAuthority)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new NamingAuthority((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
public static NamingAuthority GetInstance(Asn1TaggedObject obj, bool isExplicit)
|
||||
{
|
||||
return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
|
||||
}
|
||||
|
||||
private NamingAuthority(Asn1Sequence seq)
|
||||
{
|
||||
if (seq.Count > 3)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count);
|
||||
}
|
||||
IEnumerator enumerator = seq.GetEnumerator();
|
||||
if (enumerator.MoveNext())
|
||||
{
|
||||
Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.Current;
|
||||
if (asn1Encodable is DerObjectIdentifier)
|
||||
{
|
||||
namingAuthorityID = (DerObjectIdentifier)asn1Encodable;
|
||||
}
|
||||
else if (asn1Encodable is DerIA5String)
|
||||
{
|
||||
namingAuthorityUrl = DerIA5String.GetInstance(asn1Encodable).GetString();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(asn1Encodable is IAsn1String))
|
||||
{
|
||||
throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable));
|
||||
}
|
||||
namingAuthorityText = DirectoryString.GetInstance(asn1Encodable);
|
||||
}
|
||||
}
|
||||
if (enumerator.MoveNext())
|
||||
{
|
||||
Asn1Encodable asn1Encodable2 = (Asn1Encodable)enumerator.Current;
|
||||
if (asn1Encodable2 is DerIA5String)
|
||||
{
|
||||
namingAuthorityUrl = DerIA5String.GetInstance(asn1Encodable2).GetString();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(asn1Encodable2 is IAsn1String))
|
||||
{
|
||||
throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable2));
|
||||
}
|
||||
namingAuthorityText = DirectoryString.GetInstance(asn1Encodable2);
|
||||
}
|
||||
}
|
||||
if (enumerator.MoveNext())
|
||||
{
|
||||
Asn1Encodable asn1Encodable3 = (Asn1Encodable)enumerator.Current;
|
||||
if (!(asn1Encodable3 is IAsn1String))
|
||||
{
|
||||
throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable3));
|
||||
}
|
||||
namingAuthorityText = DirectoryString.GetInstance(asn1Encodable3);
|
||||
}
|
||||
}
|
||||
|
||||
public NamingAuthority(DerObjectIdentifier namingAuthorityID, string namingAuthorityUrl, DirectoryString namingAuthorityText)
|
||||
{
|
||||
this.namingAuthorityID = namingAuthorityID;
|
||||
this.namingAuthorityUrl = namingAuthorityUrl;
|
||||
this.namingAuthorityText = namingAuthorityText;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
|
||||
if (namingAuthorityID != null)
|
||||
{
|
||||
asn1EncodableVector.Add(namingAuthorityID);
|
||||
}
|
||||
if (namingAuthorityUrl != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerIA5String(namingAuthorityUrl, validate: true));
|
||||
}
|
||||
if (namingAuthorityText != null)
|
||||
{
|
||||
asn1EncodableVector.Add(namingAuthorityText);
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Asn1.X500;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.IsisMtt.X509;
|
||||
|
||||
public class ProcurationSyntax : Asn1Encodable
|
||||
{
|
||||
private readonly string country;
|
||||
|
||||
private readonly DirectoryString typeOfSubstitution;
|
||||
|
||||
private readonly GeneralName thirdPerson;
|
||||
|
||||
private readonly IssuerSerial certRef;
|
||||
|
||||
public virtual string Country => country;
|
||||
|
||||
public virtual DirectoryString TypeOfSubstitution => typeOfSubstitution;
|
||||
|
||||
public virtual GeneralName ThirdPerson => thirdPerson;
|
||||
|
||||
public virtual IssuerSerial CertRef => certRef;
|
||||
|
||||
public static ProcurationSyntax GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is ProcurationSyntax)
|
||||
{
|
||||
return (ProcurationSyntax)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new ProcurationSyntax((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private ProcurationSyntax(Asn1Sequence seq)
|
||||
{
|
||||
if (seq.Count < 1 || seq.Count > 3)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count);
|
||||
}
|
||||
IEnumerator enumerator = seq.GetEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
Asn1TaggedObject instance = Asn1TaggedObject.GetInstance(enumerator.Current);
|
||||
switch (instance.TagNo)
|
||||
{
|
||||
case 1:
|
||||
country = DerPrintableString.GetInstance(instance, isExplicit: true).GetString();
|
||||
break;
|
||||
case 2:
|
||||
typeOfSubstitution = DirectoryString.GetInstance(instance, isExplicit: true);
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
Asn1Object asn1Object = instance.GetObject();
|
||||
if (asn1Object is Asn1TaggedObject)
|
||||
{
|
||||
thirdPerson = GeneralName.GetInstance(asn1Object);
|
||||
}
|
||||
else
|
||||
{
|
||||
certRef = IssuerSerial.GetInstance(asn1Object);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new ArgumentException("Bad tag number: " + instance.TagNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ProcurationSyntax(string country, DirectoryString typeOfSubstitution, IssuerSerial certRef)
|
||||
{
|
||||
this.country = country;
|
||||
this.typeOfSubstitution = typeOfSubstitution;
|
||||
thirdPerson = null;
|
||||
this.certRef = certRef;
|
||||
}
|
||||
|
||||
public ProcurationSyntax(string country, DirectoryString typeOfSubstitution, GeneralName thirdPerson)
|
||||
{
|
||||
this.country = country;
|
||||
this.typeOfSubstitution = typeOfSubstitution;
|
||||
this.thirdPerson = thirdPerson;
|
||||
certRef = null;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
|
||||
if (country != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 1, new DerPrintableString(country, validate: true)));
|
||||
}
|
||||
if (typeOfSubstitution != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 2, typeOfSubstitution));
|
||||
}
|
||||
if (thirdPerson != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 3, thirdPerson));
|
||||
}
|
||||
else
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 3, certRef));
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Org.BouncyCastle.Asn1.X500;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.IsisMtt.X509;
|
||||
|
||||
public class ProfessionInfo : Asn1Encodable
|
||||
{
|
||||
public static readonly DerObjectIdentifier Rechtsanwltin = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".1"));
|
||||
|
||||
public static readonly DerObjectIdentifier Rechtsanwalt = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".2"));
|
||||
|
||||
public static readonly DerObjectIdentifier Rechtsbeistand = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".3"));
|
||||
|
||||
public static readonly DerObjectIdentifier Steuerberaterin = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".4"));
|
||||
|
||||
public static readonly DerObjectIdentifier Steuerberater = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".5"));
|
||||
|
||||
public static readonly DerObjectIdentifier Steuerbevollmchtigte = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".6"));
|
||||
|
||||
public static readonly DerObjectIdentifier Steuerbevollmchtigter = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".7"));
|
||||
|
||||
public static readonly DerObjectIdentifier Notarin = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".8"));
|
||||
|
||||
public static readonly DerObjectIdentifier Notar = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".9"));
|
||||
|
||||
public static readonly DerObjectIdentifier Notarvertreterin = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".10"));
|
||||
|
||||
public static readonly DerObjectIdentifier Notarvertreter = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".11"));
|
||||
|
||||
public static readonly DerObjectIdentifier Notariatsverwalterin = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".12"));
|
||||
|
||||
public static readonly DerObjectIdentifier Notariatsverwalter = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".13"));
|
||||
|
||||
public static readonly DerObjectIdentifier Wirtschaftsprferin = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".14"));
|
||||
|
||||
public static readonly DerObjectIdentifier Wirtschaftsprfer = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".15"));
|
||||
|
||||
public static readonly DerObjectIdentifier VereidigteBuchprferin = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".16"));
|
||||
|
||||
public static readonly DerObjectIdentifier VereidigterBuchprfer = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".17"));
|
||||
|
||||
public static readonly DerObjectIdentifier Patentanwltin = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".18"));
|
||||
|
||||
public static readonly DerObjectIdentifier Patentanwalt = new DerObjectIdentifier(string.Concat(NamingAuthority.IdIsisMttATNamingAuthoritiesRechtWirtschaftSteuern, ".19"));
|
||||
|
||||
private readonly NamingAuthority namingAuthority;
|
||||
|
||||
private readonly Asn1Sequence professionItems;
|
||||
|
||||
private readonly Asn1Sequence professionOids;
|
||||
|
||||
private readonly string registrationNumber;
|
||||
|
||||
private readonly Asn1OctetString addProfessionInfo;
|
||||
|
||||
public virtual Asn1OctetString AddProfessionInfo => addProfessionInfo;
|
||||
|
||||
public virtual NamingAuthority NamingAuthority => namingAuthority;
|
||||
|
||||
public virtual string RegistrationNumber => registrationNumber;
|
||||
|
||||
public static ProfessionInfo GetInstance(object obj)
|
||||
{
|
||||
if (obj == null || obj is ProfessionInfo)
|
||||
{
|
||||
return (ProfessionInfo)obj;
|
||||
}
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new ProfessionInfo((Asn1Sequence)obj);
|
||||
}
|
||||
throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private ProfessionInfo(Asn1Sequence seq)
|
||||
{
|
||||
if (seq.Count > 5)
|
||||
{
|
||||
throw new ArgumentException("Bad sequence size: " + seq.Count);
|
||||
}
|
||||
IEnumerator enumerator = seq.GetEnumerator();
|
||||
enumerator.MoveNext();
|
||||
Asn1Encodable asn1Encodable = (Asn1Encodable)enumerator.Current;
|
||||
if (asn1Encodable is Asn1TaggedObject)
|
||||
{
|
||||
Asn1TaggedObject asn1TaggedObject = (Asn1TaggedObject)asn1Encodable;
|
||||
if (asn1TaggedObject.TagNo != 0)
|
||||
{
|
||||
throw new ArgumentException("Bad tag number: " + asn1TaggedObject.TagNo);
|
||||
}
|
||||
namingAuthority = NamingAuthority.GetInstance(asn1TaggedObject, isExplicit: true);
|
||||
enumerator.MoveNext();
|
||||
asn1Encodable = (Asn1Encodable)enumerator.Current;
|
||||
}
|
||||
professionItems = Asn1Sequence.GetInstance(asn1Encodable);
|
||||
if (enumerator.MoveNext())
|
||||
{
|
||||
asn1Encodable = (Asn1Encodable)enumerator.Current;
|
||||
if (asn1Encodable is Asn1Sequence)
|
||||
{
|
||||
professionOids = Asn1Sequence.GetInstance(asn1Encodable);
|
||||
}
|
||||
else if (asn1Encodable is DerPrintableString)
|
||||
{
|
||||
registrationNumber = DerPrintableString.GetInstance(asn1Encodable).GetString();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(asn1Encodable is Asn1OctetString))
|
||||
{
|
||||
throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable));
|
||||
}
|
||||
addProfessionInfo = Asn1OctetString.GetInstance(asn1Encodable);
|
||||
}
|
||||
}
|
||||
if (enumerator.MoveNext())
|
||||
{
|
||||
asn1Encodable = (Asn1Encodable)enumerator.Current;
|
||||
if (asn1Encodable is DerPrintableString)
|
||||
{
|
||||
registrationNumber = DerPrintableString.GetInstance(asn1Encodable).GetString();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(asn1Encodable is DerOctetString))
|
||||
{
|
||||
throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable));
|
||||
}
|
||||
addProfessionInfo = (DerOctetString)asn1Encodable;
|
||||
}
|
||||
}
|
||||
if (enumerator.MoveNext())
|
||||
{
|
||||
asn1Encodable = (Asn1Encodable)enumerator.Current;
|
||||
if (!(asn1Encodable is DerOctetString))
|
||||
{
|
||||
throw new ArgumentException("Bad object encountered: " + Platform.GetTypeName(asn1Encodable));
|
||||
}
|
||||
addProfessionInfo = (DerOctetString)asn1Encodable;
|
||||
}
|
||||
}
|
||||
|
||||
public ProfessionInfo(NamingAuthority namingAuthority, DirectoryString[] professionItems, DerObjectIdentifier[] professionOids, string registrationNumber, Asn1OctetString addProfessionInfo)
|
||||
{
|
||||
this.namingAuthority = namingAuthority;
|
||||
this.professionItems = new DerSequence(professionItems);
|
||||
if (professionOids != null)
|
||||
{
|
||||
this.professionOids = new DerSequence(professionOids);
|
||||
}
|
||||
this.registrationNumber = registrationNumber;
|
||||
this.addProfessionInfo = addProfessionInfo;
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector asn1EncodableVector = new Asn1EncodableVector();
|
||||
if (namingAuthority != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerTaggedObject(explicitly: true, 0, namingAuthority));
|
||||
}
|
||||
asn1EncodableVector.Add(professionItems);
|
||||
if (professionOids != null)
|
||||
{
|
||||
asn1EncodableVector.Add(professionOids);
|
||||
}
|
||||
if (registrationNumber != null)
|
||||
{
|
||||
asn1EncodableVector.Add(new DerPrintableString(registrationNumber, validate: true));
|
||||
}
|
||||
if (addProfessionInfo != null)
|
||||
{
|
||||
asn1EncodableVector.Add(addProfessionInfo);
|
||||
}
|
||||
return new DerSequence(asn1EncodableVector);
|
||||
}
|
||||
|
||||
public virtual DirectoryString[] GetProfessionItems()
|
||||
{
|
||||
DirectoryString[] array = new DirectoryString[professionItems.Count];
|
||||
for (int i = 0; i < professionItems.Count; i++)
|
||||
{
|
||||
array[i] = DirectoryString.GetInstance(professionItems[i]);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public virtual DerObjectIdentifier[] GetProfessionOids()
|
||||
{
|
||||
if (professionOids == null)
|
||||
{
|
||||
return new DerObjectIdentifier[0];
|
||||
}
|
||||
DerObjectIdentifier[] array = new DerObjectIdentifier[professionOids.Count];
|
||||
for (int i = 0; i < professionOids.Count; i++)
|
||||
{
|
||||
array[i] = DerObjectIdentifier.GetInstance(professionOids[i]);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using Org.BouncyCastle.Asn1.X500;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.IsisMtt.X509;
|
||||
|
||||
public class Restriction : Asn1Encodable
|
||||
{
|
||||
private readonly DirectoryString restriction;
|
||||
|
||||
public virtual DirectoryString RestrictionString => restriction;
|
||||
|
||||
public static Restriction GetInstance(object obj)
|
||||
{
|
||||
if (obj is Restriction)
|
||||
{
|
||||
return (Restriction)obj;
|
||||
}
|
||||
if (obj is IAsn1String)
|
||||
{
|
||||
return new Restriction(DirectoryString.GetInstance(obj));
|
||||
}
|
||||
throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
private Restriction(DirectoryString restriction)
|
||||
{
|
||||
this.restriction = restriction;
|
||||
}
|
||||
|
||||
public Restriction(string restriction)
|
||||
{
|
||||
this.restriction = new DirectoryString(restriction);
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return restriction.ToAsn1Object();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user