示例#1
0
        /// <summary>
        /// GetAuthenticationMethods method implmentation
        /// </summary>
        public override List <AvailableAuthenticationMethod> GetAuthenticationMethods(AuthenticationContext ctx)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }

            List <AvailableAuthenticationMethod> result = GetSessionData(this.Kind, ctx);

            if (result != null)
            {
                return(result);
            }
            else
            {
                result = new List <AvailableAuthenticationMethod>();

                AvailableAuthenticationMethod item1 = GetAuthenticationMethodProperties(ctx, AuthenticationResponseKind.Sample1);
                result.Add(item1);
                AvailableAuthenticationMethod item2 = GetAuthenticationMethodProperties(ctx, AuthenticationResponseKind.Sample2Async);
                result.Add(item2);
                SaveSessionData(this.Kind, ctx, result);
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// GetAuthenticationMethods method implementation
        /// </summary>
        public override List <AvailableAuthenticationMethod> GetAuthenticationMethods(AuthenticationContext ctx)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }

            List <AvailableAuthenticationMethod> result = GetSessionData(this.Kind, ctx);

            if (result != null)
            {
                return(result);
            }
            else
            {
                result = new List <AvailableAuthenticationMethod>();
                AvailableAuthenticationMethod item = new AvailableAuthenticationMethod
                {
                    IsDefault          = true,
                    IsRemote           = true,
                    IsTwoWay           = true,
                    IsSendBack         = false,
                    RequiredEmail      = false,
                    RequiredPhone      = false,
                    RequiredCode       = false,
                    Method             = AuthenticationResponseKind.Biometrics,
                    RequiredPin        = false,
                    RequiredBiometrics = true
                };
                result.Add(item);
                SaveSessionData(this.Kind, ctx, result);
            }
            return(result);
        }
        /// <summary>
        /// GetUIChoiceLabel method implementation
        /// </summary>
        public override string GetUIChoiceLabel(AuthenticationContext ctx, AvailableAuthenticationMethod method)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }

            GetAuthenticationContext(ctx);
            AuthenticationResponseKind mk = ctx.SelectedMethod;

            if (method != null)
            {
                mk = method.Method;
            }
            html_strings.Culture = new CultureInfo(ctx.Lcid);
            switch (mk)
            {
            case AuthenticationResponseKind.SmsOTP:
            case AuthenticationResponseKind.SmsOneWayOTP:
                return(html_strings.SMSUIChoiceLabel);

            case AuthenticationResponseKind.SmsTwoWayOTP:
                return(html_strings.SMSUIChoiceLabel2);

            default:
                return(html_strings.SMSUIChoiceLabel);
            }
        }
        /// <summary>
        /// GetUIChoiceLabel method implementation
        /// </summary>
        public override string GetUIChoiceLabel(AuthenticationContext ctx, AvailableAuthenticationMethod method)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }

            GetAuthenticationContext(ctx);
            AuthenticationResponseKind mk = ctx.SelectedMethod;

            if (method != null)
            {
                mk = method.Method;
            }
            ResourcesLocale Resources = new ResourcesLocale(ctx.Lcid);

            switch (mk)
            {
            case AuthenticationResponseKind.SmsOTP:
            case AuthenticationResponseKind.SmsOneWayOTP:
                return(Resources.GetString(ResourcesLocaleKind.Html, "SMSUIChoiceLabel"));

            case AuthenticationResponseKind.SmsTwoWayOTP:
                return(Resources.GetString(ResourcesLocaleKind.Html, "SMSUIChoiceLabel2"));

            default:
                return(Resources.GetString(ResourcesLocaleKind.Html, "SMSUIChoiceLabel"));
            }
        }
        /// <summary>
        /// GetAuthenticationMethods method implmentation
        /// </summary>
        public override List <AvailableAuthenticationMethod> GetAuthenticationMethods(AuthenticationContext ctx)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }

            List <AvailableAuthenticationMethod> result = GetSessionData(this.Kind, ctx);

            if (result != null)
            {
                return(result);
            }
            else
            {
                result = new List <AvailableAuthenticationMethod>();
                GetAvailableAuthenticationMethodsResponse authMethods = GetAzureAvailableAuthenticationMethods(ctx);

                foreach (AuthenticationMethod current in authMethods.AuthenticationMethods)
                {
                    AvailableAuthenticationMethod item = GetAuthenticationMethodProperties(current);
                    if (item.Method != AuthenticationResponseKind.Error)
                    {
                        item.IsDefault = current.IsDefault;
                        result.Add(item);
                    }
                }
                if (result.Count > 0)
                {
                    SaveSessionData(this.Kind, ctx, result);
                }
            }
            return(result);
        }
        /// <summary>
        /// GetAuthenticationMethods method implmentation
        /// </summary>
        public override List <AvailableAuthenticationMethod> GetAuthenticationMethods(AuthenticationContext ctx)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }

            List <AvailableAuthenticationMethod> result = GetSessionData(this.Kind, ctx);

            if (result != null)
            {
                return(result);
            }
            else
            {
                result = new List <AvailableAuthenticationMethod>();
#if !azuretest
                GetAvailableAuthenticationMethodsResponse authMethods = GetAzureAvailableAuthenticationMethods(ctx);
                foreach (AuthenticationMethod current in authMethods.AuthenticationMethods)
                {
                    AvailableAuthenticationMethod item = GetAuthenticationMethodProperties(current);
                    if (item.Method != AuthenticationResponseKind.Error)
                    {
                        item.IsDefault = current.IsDefault;
                        result.Add(item);
                    }
                }
#else
                AuthenticationMethod current1 = new AuthenticationMethod()
                {
                    Id = "OneWaySMS", IsDefault = true
                };
                current1.Properties.Add("MobilePhone", "+33 123123456");
                AuthenticationMethod current2 = new AuthenticationMethod()
                {
                    Id = "TwoWaySMS", IsDefault = false
                };
                current2.Properties.Add("MobilePhone", "+33 123123456");
                AvailableAuthenticationMethod item1 = GetAuthenticationMethodProperties(current1);
                item1.IsDefault = current1.IsDefault;
                result.Add(item1);
                AvailableAuthenticationMethod item2 = GetAuthenticationMethodProperties(current2);
                item2.IsDefault = current2.IsDefault;
                result.Add(item2);
#endif
                if (result.Count > 0)
                {
                    SaveSessionData(this.Kind, ctx, result);
                }
            }
            return(result);
        }
        /// <summary>
        /// GetAuthenticationMethods method implmentation
        /// </summary>
        public override List <AvailableAuthenticationMethod> GetAuthenticationMethods(AuthenticationContext ctx)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }

            html_strings.Culture  = new CultureInfo(ctx.Lcid);
            azure_strings.Culture = new CultureInfo(ctx.Lcid);
            List <AvailableAuthenticationMethod> result = GetSessionData(this.Kind, ctx);

            if (result != null)
            {
                return(result);
            }
            else
            {
                result = new List <AvailableAuthenticationMethod>();
                AvailableAuthenticationMethod item1 = new AvailableAuthenticationMethod();
                item1.IsDefault     = !this.Data.IsTwoWay;
                item1.IsRemote      = true;
                item1.IsTwoWay      = false;
                item1.IsSendBack    = false;
                item1.RequiredPin   = false;
                item1.RequiredEmail = false;
                item1.RequiredPhone = true;
                item1.RequiredCode  = true;
                item1.ExtraInfos    = ctx.PhoneNumber;
                item1.Method        = AuthenticationResponseKind.SmsOneWayOTP;
                result.Add(item1);

                if (this.Data.IsTwoWay)
                {
                    AvailableAuthenticationMethod item2 = new AvailableAuthenticationMethod();
                    item2.IsDefault     = this.Data.IsTwoWay;
                    item2.IsRemote      = true;
                    item2.IsTwoWay      = true;
                    item2.IsSendBack    = false;
                    item2.RequiredPin   = false;
                    item2.RequiredEmail = false;
                    item2.RequiredPhone = true;
                    item2.RequiredCode  = false;
                    item2.ExtraInfos    = ctx.PhoneNumber;
                    item2.Method        = AuthenticationResponseKind.SmsTwoWayOTP;
                    result.Add(item2);
                }
                SaveSessionData(this.Kind, ctx, result);
            }
            return(result);
        }
示例#8
0
        /// <summary>
        /// GetUIChoiceLabel method ipmplmentation
        ///
        /// Label displayed in the comboxbox used for selection of the Default Authentication method (registration, Do not have the code)
        /// </summary>
        public override string GetUIChoiceLabel(AuthenticationContext ctx, AvailableAuthenticationMethod method = null)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }

            GetAuthenticationContext(ctx);
            AuthenticationResponseKind mk = ctx.SelectedMethod;

            if (method != null)
            {
                mk = method.Method;
            }
            switch (mk)
            {
            case AuthenticationResponseKind.Sample1:
                switch (ctx.Lcid)
                {
                case 1033:
                    return("How old is Barak Obama");

                case 1036:
                    return("Quel est l'age de Paul Bismuth");

                case 1034:
                case 3082:
                    return("¿ Qué edad tiene Raphael Nadal");
                }
                break;

            case AuthenticationResponseKind.Sample2Async:
                switch (ctx.Lcid)
                {
                case 1033:
                    return("Sing Queen's \"Don't stop me now !\"");

                case 1036:
                    return("Chanter \"Nougayork\" de Claude Nougaro");

                case 1034:
                case 3082:
                    return("Canta \"Waka Waka\" de Shakira");
                }
                break;
            }
            return(string.Empty);
        }
        /// <summary>
        /// GetAuthenticationContext method implementation
        /// </summary>
        public override void GetAuthenticationContext(AuthenticationContext ctx)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }
            ResourcesLocale Resources            = new ResourcesLocale(ctx.Lcid);
            AvailableAuthenticationMethod result = GetSelectedAuthenticationMethod(ctx);

            ctx.PinRequired     = result.RequiredPin;
            ctx.IsRemote        = result.IsRemote;
            ctx.IsTwoWay        = result.IsTwoWay;
            ctx.IsSendBack      = result.IsSendBack;
            ctx.PreferredMethod = ctx.PreferredMethod;
            ctx.SelectedMethod  = result.Method;
            ctx.ExtraInfos      = result.ExtraInfos;
        }
        /// <summary>
        /// GetUIChoiceLabel method implementation
        /// </summary>
        public override string GetUIChoiceLabel(AuthenticationContext ctx, AvailableAuthenticationMethod method = null)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }

            GetAuthenticationContext(ctx);
            AuthenticationResponseKind mk = ctx.SelectedMethod;

            if (method != null)
            {
                mk = method.Method;
            }
            ResourcesLocale Resources = new ResourcesLocale(ctx.Lcid);

            switch (mk)
            {
            case AuthenticationResponseKind.PhoneAppNotification:
                return(Resources.GetString(ResourcesLocaleKind.Html, "NOTIFChoiceLabel"));

            case AuthenticationResponseKind.PhoneAppOTP:
                return(Resources.GetString(ResourcesLocaleKind.Html, "OTPChoiceLabel"));

            case AuthenticationResponseKind.SmsOneWayOTPplusPin:
            case AuthenticationResponseKind.SmsOneWayOTP:
            case AuthenticationResponseKind.SmsTwoWayOTPplusPin:
            case AuthenticationResponseKind.SmsTwoWayOTP:
                return(Resources.GetString(ResourcesLocaleKind.Html, "SMSChoiceLabel"));

            case AuthenticationResponseKind.VoiceTwoWayMobilePlusPin:
            case AuthenticationResponseKind.VoiceTwoWayMobile:
                return(Resources.GetString(ResourcesLocaleKind.Html, "VOICE1ChoiceLabel"));

            case AuthenticationResponseKind.VoiceTwoWayAlternateMobilePlusPin:
            case AuthenticationResponseKind.VoiceTwoWayAlternateMobile:
                return(Resources.GetString(ResourcesLocaleKind.Html, "VOICE2ChoiceLabel"));

            case AuthenticationResponseKind.VoiceTwoWayOfficePlusPin:
            case AuthenticationResponseKind.VoiceTwoWayOffice:
                return(Resources.GetString(ResourcesLocaleKind.Html, "VOICE3ChoiceLabel"));

            default:
                return(string.Empty);
            }
        }
示例#11
0
        /// <summary>
        /// GetAuthenticationMethod method implementation
        /// </summary>
        private AvailableAuthenticationMethod GetAuthenticationMethodProperties(AuthenticationContext ctx, AuthenticationResponseKind method)
        {
            AvailableAuthenticationMethod result = new AvailableAuthenticationMethod();

            switch (method)
            {
            case AuthenticationResponseKind.Sample1:
                result.IsDefault     = !IsAsync;
                result.RequiredPin   = false;
                result.IsRemote      = false;
                result.IsTwoWay      = false;
                result.IsSendBack    = false;
                result.RequiredEmail = false;
                result.RequiredPhone = false;
                result.RequiredCode  = true;
                result.Method        = MultiFactor.AuthenticationResponseKind.Sample1;
                break;

            case AuthenticationResponseKind.Sample2Async:
                result.IsDefault     = IsAsync;
                result.RequiredPin   = false;
                result.IsRemote      = true;
                result.IsTwoWay      = true;
                result.IsSendBack    = false;
                result.RequiredEmail = false;
                result.RequiredPhone = false;
                result.RequiredCode  = false;
                result.Method        = MultiFactor.AuthenticationResponseKind.Sample2Async;
                break;

            default:
                result.Method = AuthenticationResponseKind.Error;
                break;
            }
            return(result);
        }
示例#12
0
        /// <summary>
        /// GetUIChoiceLabel method implementation
        /// </summary>
        public override string GetUIChoiceLabel(AuthenticationContext ctx, AvailableAuthenticationMethod method = null)
        {
            ResourcesLocale Resources = new ResourcesLocale(ctx.Lcid);

            return(Resources.GetString(ResourcesLocaleKind.Html, "BIOUIChoiceLabel"));
        }
        /// <summary>
        /// GetAuthenticationMethod method implementation
        /// </summary>
        private AvailableAuthenticationMethod GetAuthenticationMethodProperties(AuthenticationMethod method)
        {
            AvailableAuthenticationMethod result = new AvailableAuthenticationMethod();

            result.IsDefault     = false;
            result.RequiredPin   = false;
            result.IsRemote      = true;
            result.IsTwoWay      = false;
            result.IsSendBack    = true;
            result.RequiredEmail = false;
            result.RequiredPhone = false;
            result.RequiredCode  = false;
            if (method.Id == "PhoneAppNotification")
            {
                result.IsTwoWay      = true;
                result.RequiredEmail = false;
                result.RequiredPhone = false;
                result.RequiredCode  = false;
                result.Method        = AuthenticationResponseKind.PhoneAppNotification;
            }
            else if (method.Id == "PhoneAppOTP")
            {
                result.RequiredEmail = false;
                result.RequiredPhone = false;
                result.RequiredCode  = true;
                result.Method        = AuthenticationResponseKind.PhoneAppOTP;
            }
            else if (method.Id == "OneWaySMS")
            {
                result.RequiredEmail = false;
                result.RequiredPhone = false;
                result.RequiredCode  = true;
                if (method.Properties.ContainsKey("MobilePhone"))
                {
                    result.ExtraInfos = method.Properties["MobilePhone"];
                }
                if (method.Properties.ContainsKey("PinEnabled"))
                {
                    result.RequiredPin = true;
                    result.Method      = AuthenticationResponseKind.SmsOneWayOTPplusPin;
                }
                else
                {
                    result.Method = AuthenticationResponseKind.SmsOneWayOTP;
                }
            }
            else if (method.Id == "TwoWaySMS")
            {
                result.RequiredEmail = false;
                result.RequiredPhone = false;
                result.RequiredCode  = false;
                result.IsTwoWay      = true;
                if (method.Properties.ContainsKey("MobilePhone"))
                {
                    result.ExtraInfos = method.Properties["MobilePhone"];
                }
                if (method.Properties.ContainsKey("PinEnabled"))
                {
                    result.RequiredPin = true;
                    result.Method      = AuthenticationResponseKind.SmsTwoWayOTPplusPin;
                }
                else
                {
                    result.Method = AuthenticationResponseKind.SmsTwoWayOTP;
                }
            }
            else if (method.Id == "TwoWayVoiceMobile")
            {
                result.RequiredEmail = false;
                result.RequiredPhone = false;
                result.RequiredCode  = false;
                result.IsTwoWay      = true;
                if (method.Properties.ContainsKey("MobilePhone"))
                {
                    result.ExtraInfos = method.Properties["MobilePhone"];
                }
                if (method.Properties.ContainsKey("PinEnabled"))
                {
                    result.RequiredPin = true;
                    result.Method      = AuthenticationResponseKind.VoiceTwoWayMobilePlusPin;
                }
                else
                {
                    result.Method = AuthenticationResponseKind.VoiceTwoWayMobile;
                }
            }
            else if (method.Id == "TwoWayVoiceOffice")
            {
                result.RequiredEmail = false;
                result.RequiredPhone = false;
                result.RequiredCode  = false;
                result.IsTwoWay      = true;
                if (method.Properties.ContainsKey("PhoneNumber"))
                {
                    result.ExtraInfos = method.Properties["PhoneNumber"];
                }
                if (method.Properties.ContainsKey("PhoneNumber"))
                {
                    result.RequiredPin = true;
                    result.Method      = AuthenticationResponseKind.VoiceTwoWayOfficePlusPin;
                }
                else
                {
                    result.Method = AuthenticationResponseKind.VoiceTwoWayOffice;
                }
            }
            else if (method.Id == "TwoWayVoiceAlternateMobile")
            {
                result.RequiredEmail = false;
                result.RequiredPhone = false;
                result.RequiredCode  = false;
                result.IsTwoWay      = true;
                if (method.Properties.ContainsKey("AlternateMobilePhone"))
                {
                    result.ExtraInfos = method.Properties["AlternateMobilePhone"];
                }
                if (method.Properties.ContainsKey("PinEnabled"))
                {
                    result.RequiredPin = true;
                    result.Method      = AuthenticationResponseKind.VoiceTwoWayAlternateMobilePlusPin;
                }
                else
                {
                    result.Method = AuthenticationResponseKind.VoiceTwoWayAlternateMobile;
                }
            }
            else
            {
                result.Method = AuthenticationResponseKind.Error;
            }
            return(result);
        }