Exemplo n.º 1
0
        /// <summary>
        /// When overridden in a descendant class, serializes the object into XML according to Aadhaar API specification.
        /// </summary>
        /// <param name="elementName">The name of the element.</param>
        /// <returns>An instance of <see cref="XElement"/>.</returns>
        protected override XElement SerializeXml(string elementName)
        {
            ValidateNull(Uses, nameof(Uses));
            ValidateNull(DeviceInfo, nameof(DeviceInfo));
            ValidateNull(KeyInfo, nameof(KeyInfo));
            ValidateNull(Data, nameof(Data));
            ValidateEmptyString(AadhaarNumber, nameof(AadhaarNumber));
            ValidateEmptyString(Hmac, nameof(Hmac));

            var authRequest = base.SerializeXml(elementName);

            authRequest.Add(new XAttribute("uid", AadhaarNumber),
                            new XAttribute("ver", AuthVersion),
                            Uses.ToXml("Uses"),
                            DeviceInfo.ToXml("Meta"),
                            KeyInfo.ToXml("Skey"),
                            Data.ToXml("Data"),
                            new XElement("Hmac", Hmac));
            if (Token != null)
            {
                authRequest.Add(Token.ToXml("Tkn"));
            }

            Signer?.ComputeSignature(authRequest);

            return(authRequest);
        }
Exemplo n.º 2
0
        /// <summary>
        /// When overridden in a descendant class, serializes the object into XML according to Aadhaar API specification.
        /// </summary>
        /// <param name="elementName">The name of the element.</param>
        /// <returns>An instance of <see cref="XElement"/>.</returns>
        protected override XElement SerializeXml(string elementName)
        {
            ValidateNull(Uses, nameof(Uses));

            var authContext = base.SerializeXml(elementName);

            authContext.Add(Uses.ToXml("Uses"));
            if (Info != null)
            {
                authContext.Add(new XAttribute("info", Info.InfoValue));
            }
            if (Token != null)
            {
                authContext.Add(Token.ToXml("Tkn"));
            }

            return(authContext);
        }
Exemplo n.º 3
0
        /// <summary>
        /// When overridden in a descendant class, serializes the object into XML according to Aadhaar API specification.
        /// </summary>
        /// <param name="name">The name of the element.</param>
        /// <returns>An instance of <see cref="XElement"/>.</returns>
        /// <exception cref="ArgumentNullException"><see cref="Uses"/> is null.</exception>
        protected override XElement SerializeXml(XName name)
        {
            ValidateNull(Uses, nameof(Uses));

            var authContext = base.SerializeXml(name);

            authContext.Add(new XAttribute("rc", AadhaarHelper.YesUpper),
                            Uses.ToXml("Uses"));

            if (AuthInfo != null)
            {
                authContext.Add(new XAttribute("info", AuthInfo.Encode()));
            }
            if (Token != null)
            {
                authContext.Add(Token.ToXml("Tkn"));
            }

            return(authContext);
        }