/// <summary>
        /// Initializes a new instance of the <see cref="KycRequest"/> class with a specified KYC data along with other details.
        /// </summary>
        /// <param name="kycContext">The authentication data received from device.</param>
        /// <exception cref="ArgumentNullException"><paramref name="kycContext"/> is null.</exception>
        public KycRequest(KycContext kycContext) : base(kycContext)
        {
            ValidateNull(kycContext, nameof(kycContext));

            AccessILInfo         = kycContext.AccessILInfo;
            AccessMobileAndEmail = kycContext.AccessMobileAndEmail;
            Timestamp            = kycContext.Timestamp;
            Transaction.Prefix   = "UKC:";
        }
        public void EncryptTest()
        {
            var kycContext   = new KycContext();
            var personalInfo = Data.PersonalInfo;
            var sessionKey   = Data.SessionKey;

            // Test 1: HasResidentConsent = true.
            Assert.Throws <ArgumentException>(nameof(KycContext.HasResidentConsent), () => kycContext.Encrypt(personalInfo, sessionKey));

            // Test 2: Biometric or OTP is mandatory
            kycContext.HasResidentConsent = true;
            personalInfo.Biometrics.Clear();
            kycContext.Encrypt(personalInfo, sessionKey);

            personalInfo.PinValue.Otp = null;
            Assert.Throws <ArgumentException>(nameof(PersonalInfo.Uses), () => kycContext.Encrypt(personalInfo, sessionKey));
        }
Beispiel #3
0
        public static async Task KnowYourCustomerAsync()
        {
            // A workaround to support version 1.0. Can be removed once v1.0 becomes obsolete.
            KycRequest.KycVersion = "1.0";

            #region Device Level

            // Generate OTP
            await Otp.GenerateOtpAsync("999999990019");

            // Set Personal Info
            Console.Write("Enter OTP sent to mobile: ");
            var personalInfo = new PersonalInfo
            {
                AadhaarNumber = "999999990019",
                PinValue      = new PinValue {
                    Otp = Console.ReadLine()
                }
            };

            // Set Device Info
            var kycContext = new KycContext
            {
                DeviceInfo = Configuration.DeviceInfo.Create()
            };

            // Ask for Resident Consent
            Console.Write("Access personal information? (y/n)\t\t");
            kycContext.HasResidentConsent = Console.ReadLine() == "y";

            Console.Write("Access information in Indian language? (y/n)\t");
            kycContext.AccessILInfo = Console.ReadLine() == "y";

            Console.Write("Access mobile and email information? (y/n)\t");
            kycContext.AccessMobileAndEmail = Console.ReadLine() == "y";

            // Encrypt Data
            using (var sessionKey = new SessionKey(Configuration.UidaiEncryptionKeyPath, true))
                await kycContext.EncryptAsync(personalInfo, sessionKey);

            #endregion

            #region Device To Agency
            // TODO: Wrap DeviceContext{T} into AUA specific protocol and send it to AUA.
            // On Device Side:
            // var deviceXml = deviceContext.ToXml();
            // var wrapped = WrapIntoAuaProtocol(deviceXml);

            // On Agency Side:
            // var auaXml = UnwrapFromAuaProtocol(wrapped);
            // var auaContext = new KycContext();
            // auaContext.FromXml(auaXml);
            #endregion

            #region Agency Level

            // Perform e-Know Your Customer
            var apiClient = new KycClient
            {
                AgencyInfo = Configuration.AgencyInfo,
                Request    = new KycRequest(kycContext)
                {
                    Signer = Signer
                },
                Response = new KycResponse {
                    Decryptor = Decryptor, Verifier = Verifier
                }
            };
            await apiClient.GetResponseAsync();

            Console.WriteLine(string.IsNullOrEmpty(apiClient.Response.ErrorCode)
                ? $"Customer Name: {apiClient.Response.Resident.Demographic.Identity.Name}"
                : $"Error Code: {apiClient.Response.ErrorCode}");

            #endregion

            #region Agency To Device
            // TODO: Wrap KycResponse into AUA specific protocol and send it to device.
            #endregion
        }
Beispiel #4
0
        public static async Task KnowYourCustomerAsync()
        {
            #region Device Level

            // Set Personal Info
            Console.Write("Enter OTP sent to mobile: ");
            var otp          = Console.ReadLine();
            var personalInfo = new PersonalInfo
            {
                AadhaarNumber = "999999990019",
                PinValue      = new PinValue {
                    Otp = otp
                }
            };

            // Set Device Info
            var kycContext = new KycContext
            {
                DeviceInfo         = Configuration.Current.DeviceInfo.Create(),
                HasResidentConsent = true
            };

            // Ask for Resident Consent
            Console.Write("Does user have consent to access personal data? (y/n)\t");
            kycContext.HasResidentConsent = Console.ReadLine() == "y";

            // Encrypt Data
            var sessionKey = new SessionKey(Configuration.Current.UidaiEncryption, false);
            await kycContext.EncryptAsync(personalInfo, sessionKey);

            #endregion

            #region Device To Agency
            // TODO: Wrap DeviceContext{T} into AUA specific protocol and send it to AUA.
            // On Device Side:
            // var deviceXml = deviceContext.ToXml();
            // var wrapped = WrapIntoAuaProtocol(deviceXml);

            // On Agency Side:
            // var auaXml = UnwrapFromAuaProtocol(wrapped);
            // var auaContext = new KycContext();
            // auaContext.FromXml(auaXml);
            #endregion

            #region Agency Level

            // Perform e-Know Your Customer
            var kycClient = new KycClient
            {
                AgencyInfo = Configuration.Current.AgencyInfo,
                Request    = new KycRequest(kycContext)
                {
                    Signer = XmlSignature
                },
                Response = new KycResponse {
                    Verifier = XmlSignature
                },
                Decrypter = new KycDecrypter {
                    AuaKey = Configuration.Current.AuaKey
                }
            };
            await kycClient.GetResponseAsync();

            Console.WriteLine(string.IsNullOrEmpty(kycClient.Response.ErrorCode)
                ? $"Is the user authentic: {kycClient.Response.Resident.Demographic.Identity.Name}"
                : $"Error Code: {kycClient.Response.ErrorCode}");

            #endregion

            #region Agency To Device
            // TODO: Wrap KycResponse into AUA specific protocol and send it to device.
            #endregion
        }
Beispiel #5
0
        public static async Task KnowYourCustomerAsync()
        {
            #region Device Level

            // Generate OTP 999999990019
            await Otp.GenerateOtpAsync("999999990019");

            // Set Personal Info
            Console.Write("Enter OTP sent to mobile: ");
            var personalInfo = new PersonalInfo
            {
                AadhaarNumber = "999999990019",
                PinValue      = new PinValue {
                    Otp = Console.ReadLine()
                }
            };

            // Set Device Info
            var kycContext = new KycContext
            {
                DeviceInfo = Options.DeviceInfo.Create(),

                // Should not be hardcoded in production environment.
                HasResidentConsent   = true,
                AccessILInfo         = true,
                AccessMobileAndEmail = true,
            };

            // Encrypt Data
            using (var sessionKey = new SessionKey(Options.UidaiEncryptionKeyPath, true))
                await kycContext.EncryptAsync(personalInfo, sessionKey);

            #endregion

            #region Device To Agency
            // TODO: Wrap DeviceContext{T} into AUA specific protocol and send it to AUA.
            // On Device Side:
            // var deviceXml = deviceContext.ToXml();
            // var wrapped = WrapIntoAuaProtocol(deviceXml);

            // On Agency Side:
            // var auaXml = UnwrapFromAuaProtocol(wrapped);
            // var auaContext = new KycContext();
            // auaContext.FromXml(auaXml);
            #endregion

            #region Agency Level

            // Perform e-Know Your Customer
            var apiClient = new KycClient
            {
                AgencyInfo = Options.AgencyInfo,
                Request    = new KycRequest(kycContext)
                {
                    Signer = Signer
                },
                Response = new KycResponse {
                    Decryptor = Decryptor, Verifier = Verifier
                }
            };
            await apiClient.GetResponseAsync(null, b =>
            {
                return(b);
            });

            Console.WriteLine(string.IsNullOrEmpty(apiClient.Response.ErrorCode)
                ? $"Customer Name: {apiClient.Response.Resident.Demographic.Identity.Name}"
                : $"Error Code: {apiClient.Response.ErrorCode}");

            #endregion

            #region Agency To Device
            // TODO: Wrap KycResponse into AUA specific protocol and send it to device.
            #endregion
        }