Beispiel #1
0
        public new static Asn1NumericString Parse(XElement xNode)
        {
            var res = new Asn1NumericString();

            res.Value = xNode.Value.Trim(); //todo should it be trimmed?
            return(res);
        }
Beispiel #2
0
        public static Asn1Node Parse(XElement xNode)
        {
            switch (xNode.Name.LocalName)
            {
            case Asn1Sequence.NODE_NAME:
                return(Asn1Sequence.Parse(xNode));

            case Asn1Set.NODE_NAME:
                return(Asn1Set.Parse(xNode));

            case Asn1Integer.NODE_NAME:
                return(Asn1Integer.Parse(xNode));

            case Asn1ObjectIdentifier.NODE_NAME:
                return(Asn1ObjectIdentifier.Parse(xNode));

            case Asn1NumericString.NODE_NAME:
                return(Asn1NumericString.Parse(xNode));

            case Asn1PrintableString.NODE_NAME:
                return(Asn1PrintableString.Parse(xNode));

            case Asn1T61String.NODE_NAME:
                return(Asn1T61String.Parse(xNode));

            case Asn1Ia5String.NODE_NAME:
                return(Asn1Ia5String.Parse(xNode));

            case Asn1Utf8String.NODE_NAME:
                return(Asn1Utf8String.Parse(xNode));

            case Asn1Null.NODE_NAME:
                return(Asn1Null.Parse(xNode));

            case Asn1BitString.NODE_NAME:
                return(Asn1BitString.Parse(xNode));

            case Asn1CustomNode.NODE_NAME:
                return(Asn1CustomNode.Parse(xNode));

            default:
                throw new Exception("Invalid Node " + xNode.Name.LocalName);
            }
        }
Beispiel #3
0
        private static Asn1Node ReadUniversalNode(Asn1UniversalNodeType type, Asn1TagForm tagForm, Stream stream)
        {
            switch (type)
            {
            case Asn1UniversalNodeType.Boolean: return(Asn1Boolean.ReadFrom(stream));

            case Asn1UniversalNodeType.Integer: return(Asn1Integer.ReadFrom(stream));

            case Asn1UniversalNodeType.BitString: return(Asn1BitString.ReadFrom(stream));

            case Asn1UniversalNodeType.OctetString: return(Asn1OctetString.ReadFrom(stream));

            case Asn1UniversalNodeType.Null: return(Asn1Null.ReadFrom(stream));

            case Asn1UniversalNodeType.ObjectId: return(Asn1ObjectIdentifier.ReadFrom(stream));

            case Asn1UniversalNodeType.Utf8String: return(Asn1Utf8String.ReadFrom(stream));

            case Asn1UniversalNodeType.NumericString: return(Asn1NumericString.ReadFrom(stream));

            case Asn1UniversalNodeType.PrintableString: return(Asn1PrintableString.ReadFrom(stream));

            case Asn1UniversalNodeType.T61String: return(Asn1T61String.ReadFrom(stream));

            case Asn1UniversalNodeType.Ia5String: return(Asn1Ia5String.ReadFrom(stream));

            case Asn1UniversalNodeType.UtcTime: return(Asn1UtcTime.ReadFrom(stream));

            case Asn1UniversalNodeType.Sequence: return(Asn1Sequence.ReadFrom(stream));

            case Asn1UniversalNodeType.Set: return(Asn1Set.ReadFrom(stream));

            default:
                throw new NotSupportedException($"unsupported universal type {type}");
            }
        }