diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-06-25 21:18:38 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-06-25 21:18:38 +0700 |
commit | 499bafdd45b0f8c14f74023b38b29fc3ebb5611d (patch) | |
tree | 87153088006b67c2ef36d743c361d1bf22da3675 /crypto/src/asn1/isismtt/x509/Restriction.cs | |
parent | RSA: Use input range check from fips (diff) | |
download | BouncyCastle.NET-ed25519-499bafdd45b0f8c14f74023b38b29fc3ebb5611d.tar.xz |
Refactoring in Asn1.IsisMtt
Diffstat (limited to 'crypto/src/asn1/isismtt/x509/Restriction.cs')
-rw-r--r-- | crypto/src/asn1/isismtt/x509/Restriction.cs | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/crypto/src/asn1/isismtt/x509/Restriction.cs b/crypto/src/asn1/isismtt/x509/Restriction.cs index 4334d331d..eceffaf96 100644 --- a/crypto/src/asn1/isismtt/x509/Restriction.cs +++ b/crypto/src/asn1/isismtt/x509/Restriction.cs @@ -1,34 +1,35 @@ -using System; - using Org.BouncyCastle.Asn1.X500; -using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Asn1.IsisMtt.X509 { - /** + /** * Some other restriction regarding the usage of this certificate. * <p/> * <pre> * RestrictionSyntax ::= DirectoryString (SIZE(1..1024)) * </pre> */ - public class Restriction + public class Restriction : Asn1Encodable { - private readonly DirectoryString restriction; + public static Restriction GetInstance(object obj) + { + if (obj == null) + return null; + if (obj is Restriction restriction) + return restriction; + return new Restriction(DirectoryString.GetInstance(obj)); + } - public static Restriction GetInstance(object obj) - { - if (obj is Restriction) - return (Restriction) obj; + public static Restriction GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) => + new Restriction(DirectoryString.GetInstance(taggedObject, declaredExplicit)); - if (obj is IAsn1String) - return new Restriction(DirectoryString.GetInstance(obj)); + public static Restriction GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit) => + new Restriction(DirectoryString.GetTagged(taggedObject, declaredExplicit)); - throw new ArgumentException("Unknown object in GetInstance: " + Platform.GetTypeName(obj), "obj"); - } + private readonly DirectoryString m_restriction; - /** + /** * Constructor from DirectoryString. * <p/> * The DirectoryString is of type RestrictionSyntax: @@ -39,9 +40,9 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509 * * @param restriction A IAsn1String. */ - private Restriction(DirectoryString restriction) + private Restriction(DirectoryString restriction) { - this.restriction = restriction; + m_restriction = restriction; } /** @@ -51,13 +52,10 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509 */ public Restriction(string restriction) { - this.restriction = new DirectoryString(restriction); + m_restriction = new DirectoryString(restriction); } - public virtual DirectoryString RestrictionString - { - get { return restriction; } - } + public virtual DirectoryString RestrictionString => m_restriction; /** * Produce an object suitable for an Asn1OutputStream. @@ -71,9 +69,6 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509 * * @return an Asn1Object */ - public override Asn1Object ToAsn1Object() - { - return restriction.ToAsn1Object(); - } + public override Asn1Object ToAsn1Object() => m_restriction.ToAsn1Object(); } } |