Exemple #1
0
        public Packet(Code code, byte identifier, string sharedKey)
        {
            this.code       = code;
            this.identifier = identifier;
            this.sharedKey  = sharedKey;

            this.authenticator = new byte[16];

            this.avp = new AVP();

            //Access-Requests use a random authentication code
            if (this.code == Code.Access_Request)
            {
                //Generate secure bytes for authenticator
                RNGCryptoServiceProvider rngCsp = new RNGCryptoServiceProvider();
                rngCsp.GetBytes(this.authenticator);
            }
        }
Exemple #2
0
        public Packet(Code code, byte identifier, string sharedKey)
        {
            this.code = code;
            this.identifier = identifier;
            this.sharedKey = sharedKey;

            this.authenticator = new byte[16];

            this.avp = new AVP();

            //Access-Requests use a random authentication code
            if (this.code == Code.Access_Request)
            {   
                //Generate secure bytes for authenticator
                RNGCryptoServiceProvider rngCsp = new RNGCryptoServiceProvider();
                rngCsp.GetBytes(this.authenticator);
            }
        }
Exemple #3
0
        private static void Main(string[] args)
        {
            IApprover rajiv         = new TeamLeader();
            IApprover arunChaudhary = new ProjectManager();
            IApprover sanjeevDhawan = new ReportingManger();
            IApprover aviragJain    = new AVP();

            rajiv.Next         = arunChaudhary;
            arunChaudhary.Next = sanjeevDhawan;
            sanjeevDhawan.Next = aviragJain;

            Decimal          expenseReportAmount = 50000;
            ApprovalResponse response            = rajiv.Approve(expenseReportAmount);

            Console.WriteLine("The request was {0}", response);

            Console.Read();
        }
Exemple #4
0
        public Packet(byte[] data)
        {
            this.avp = new AVP();

            code = (Code)data[0];
            identifier = data[1];
            //length = BitConverter.ToInt16(data, 2);
            authenticator = new byte[16];
            System.Buffer.BlockCopy(data, 4, authenticator, 0, 16);

            //AVP Values
            int index = 20; //First 20 bytes belong to the header above
            while (index < data.Length)
            {
                AttributeType atype = (AttributeType)data[index++];
                byte length = data[index++]; //length includes the type and length byte
                byte[] value = new byte[length - 2];
                System.Buffer.BlockCopy(data, index, value, 0, value.Length);
                avp.addAttribute(atype, value);
                index += value.Length;
            }
        }
Exemple #5
0
        public Packet(byte[] data)
        {
            this.avp = new AVP();

            code       = (Code)data[0];
            identifier = data[1];
            //length = BitConverter.ToInt16(data, 2);
            authenticator = new byte[16];
            System.Buffer.BlockCopy(data, 4, authenticator, 0, 16);

            //AVP Values
            int index = 20; //First 20 bytes belong to the header above

            while (index < data.Length)
            {
                AttributeType atype  = (AttributeType)data[index++];
                byte          length = data[index++]; //length includes the type and length byte
                byte[]        value  = new byte[length - 2];
                System.Buffer.BlockCopy(data, index, value, 0, value.Length);
                avp.addAttribute(atype, value);
                index += value.Length;
            }
        }