Example #1
0
        /// <summary>
        /// Build the part of request where contains the option to requere the FIDO2 to ask for confirmation
        /// Or for to select the type of key, Platform (Figerprint, PIN) or Cross-platform (NFC, USB, Yubikey)
        /// </summary>
        public static AuthenticatorSelectionCriteria ParseSelection(Fido2AuthenticatorSelection data)
        {
            if (data == null)
            {
                return(null);
            }

            AuthenticatorSelectionCriteria.Builder builder = new AuthenticatorSelectionCriteria.Builder();

            if (data.AuthenticatorAttachment != null && data.AuthenticatorAttachment.Length > 0)
            {
                // Selected option, Platform (Figerprint, PIN) or Cross-platform (NFC, USB, Yubikey)
                builder.SetAttachment(Attachment.FromString(data.AuthenticatorAttachment));
            }
            if (data.UserVerification != null && data.UserVerification.Length > 0)
            {
                // Require that user has to verify before using FIDO2
                //skip
            }
            if (data.RequireResidentKey != null && data.RequireResidentKey.Length > 0)
            {
                // Require the private key to be saved in exemple in the yubikey internal memory
                //skip
            }

            return(builder.Build());
        }
        /// <summary>
        /// Build the part of request where contains the option to requere the FIDO2 to ask for confirmation
        /// Or for to select the type of key, Platform (Figerprint, PIN) or Cross-platform (NFC, USB, Yubikey)
        /// </summary>
        public static AuthenticatorSelectionCriteria ParseSelection(Dictionary <string, string> data)
        {
            AuthenticatorSelectionCriteria.Builder builder = new AuthenticatorSelectionCriteria.Builder();
            foreach (KeyValuePair <string, string> entry in data)
            {
                switch (entry.Key)
                {
                case "authenticatorAttachment":     // Selected option, Platform (Figerprint, PIN) or Cross-platform (NFC, USB, Yubikey)
                    builder.SetAttachment(Attachment.FromString(entry.Value));
                    break;

                case "userVerification":     // Require that user has to verify before using FIDO2
                    //skip
                    break;

                case "requireResidentKey":     // Require the private key to be saved in exemple in the yubikey internal memory
                    //skip
                    break;
                }
            }
            return(builder.Build());
        }