Esempio n. 1
0
        public Authenticator Decode(Asn1Element asn1Element)
        {
            Asn1Element childNode = asn1Element[0];

            for (var i = 0; i < childNode.Count; i++)
            {
                var node = childNode[i];

                switch (node.ContextSpecificTag)
                {
                case 0:
                    VersionNumber = node[0].AsLong();
                    break;

                case 1:
                    Realm = node[0].AsString();
                    break;

                case 2:
                    CName = new PrincipalName().Decode(node[0], Realm);
                    break;

                case 3:
                    Checksum = node[0].Value;
                    break;

                case 4:
                    CuSec = node[0].AsLong();
                    break;

                case 5:
                    CTime = node[0].AsDateTimeOffset();
                    break;

                case 6:
                    SubSessionKey = new EncryptionKey().Decode(node[0]);
                    break;

                case 7:
                    SequenceNumber = node[0].AsLong();
                    break;

                case 8:
                    var parent = node[0];

                    for (var p = 0; p < parent.Count; p++)
                    {
                        var azElements = AuthorizationDataElement.ParseElements(parent[p]);

                        Authorizations.AddRange(azElements);
                    }
                    break;
                }
            }

            return(this);
        }
Esempio n. 2
0
        public EncTicketPart Decode(Asn1Element asn1Element)
        {
            var childNode = asn1Element[0];

            if (childNode == null)
            {
                return(null);
            }

            for (var i = 0; i < childNode.Count; i++)
            {
                var node = childNode[i];

                switch (node.ContextSpecificTag)
                {
                case 0:
                    TicketFlags = (TicketFlags)node[0].AsLong();
                    break;

                case 1:
                    Key = new EncryptionKey().Decode(node[0]);
                    break;

                case 2:
                    CRealm = node[0].AsString();
                    break;

                case 3:
                    CName = new PrincipalName().Decode(node[0], CRealm);
                    break;

                case 4:
                    for (int l = 0; l < node.Count; l++)
                    {
                        Transited.Add(new TransitedEncoding().Decode(node[l]));
                    }
                    break;

                case 5:
                    AuthTime = node[0].AsDateTimeOffset();
                    break;

                case 6:
                    StartTime = node[0].AsDateTimeOffset();
                    break;

                case 7:
                    EndTime = node[0].AsDateTimeOffset();
                    break;

                case 8:
                    RenewTill = node[0].AsDateTimeOffset();
                    break;

                case 9:
                    HostAddresses = node[0].AsLong();
                    break;

                case 10:
                    var parent = node[0];

                    var authorizations = new List <AuthorizationData>();

                    for (var p = 0; p < parent.Count; p++)
                    {
                        var azElements = AuthorizationDataElement.ParseElements(parent[p]);

                        authorizations.AddRange(azElements);
                    }

                    AuthorizationData = authorizations;
                    break;
                }
            }

            return(this);
        }