コード例 #1
0
        /// <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"));
            }
        }
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
        /// <summary>
        /// SetAuthenticationResult method implmentation
        /// </summary>
        public override int SetAuthenticationResult(AuthenticationContext ctx, string secret)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }

            if (ctx.SelectedMethod == AuthenticationResponseKind.Error)
            {
                GetAuthenticationContext(ctx);
            }
            AuthenticationResponseKind stat = EndAzureAuthentication(ctx, secret);

            return((int)stat);
        }
コード例 #4
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);
        }
コード例 #5
0
        /// <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);
            }
        }
コード例 #6
0
        /// <summary>
        /// AuthenticationMethodToString method implementation
        /// </summary>
        private string AuthenticationMethodToString(AuthenticationResponseKind method)
        {
            switch (method)
            {
            case AuthenticationResponseKind.PhoneAppNotification:
                return("PhoneAppNotification");

            case AuthenticationResponseKind.PhoneAppOTP:
                return("PhoneAppOTP");

            case AuthenticationResponseKind.SmsOneWayOTPplusPin:
                return("OneWaySMS");

            case AuthenticationResponseKind.SmsOneWayOTP:
                return("OneWaySMS");

            case AuthenticationResponseKind.SmsTwoWayOTPplusPin:
                return("TwoWaySMS");

            case AuthenticationResponseKind.SmsTwoWayOTP:
                return("TwoWaySMS");

            case AuthenticationResponseKind.VoiceTwoWayMobilePlusPin:
                return("TwoWayVoiceMobile");

            case AuthenticationResponseKind.VoiceTwoWayMobile:
                return("TwoWayVoiceMobile");

            case AuthenticationResponseKind.VoiceTwoWayOfficePlusPin:
                return("TwoWayVoiceOffice");

            case AuthenticationResponseKind.VoiceTwoWayOffice:
                return("TwoWayVoiceOffice");

            case AuthenticationResponseKind.VoiceTwoWayAlternateMobilePlusPin:
                return("TwoWayVoiceAlternateMobile");

            case AuthenticationResponseKind.VoiceTwoWayAlternateMobile:
                return("TwoWayVoiceAlternateMobile");

            default:
                return(string.Empty);
            }
        }
コード例 #7
0
        /// <summary>
        /// PostAutnenticationRequest method implmentation
        /// </summary>
        public override int PostAuthenticationRequest(AuthenticationContext ctx)
        {
            if (!IsInitialized)
            {
                throw new Exception("Provider not initialized !");
            }

            if (ctx.SelectedMethod == AuthenticationResponseKind.Error)
            {
                GetAuthenticationContext(ctx);
            }

            AuthenticationResponseKind stat = BeginAzureAuthentication(ctx);

            ctx.Notification = (int)stat;
            // ctx.SessionId = Guid.NewGuid().ToString(); // Provided by Microsoft
            ctx.SessionDate = DateTime.Now;
            return((int)stat);
        }
コード例 #8
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);
        }