public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _type = (AuthenticatorType)Arguments.GetInt("type", 0); _counter = Arguments.GetLong("counter", 0); }
public static bool IsValidSecret(string secret, AuthenticatorType type) { if (String.IsNullOrEmpty(secret)) { return(false); } if (type.IsHmacBased()) { try { var output = Base32.Rfc4648.Decode(secret); return(output.Length > 0); } catch { return(false); } } if (type == AuthenticatorType.MobileOtp) { return(secret.Length >= MobileOtp.SecretMinLength); } throw new ArgumentOutOfRangeException(nameof(type)); }
public static bool IsValidSecret(string secret, AuthenticatorType type) { if (String.IsNullOrEmpty(secret)) { return(false); } if (type.IsHmacBased()) { try { return(Base32Encoding.ToBytes(secret).Length > 0); } catch (ArgumentException) { return(false); } } if (type == AuthenticatorType.MobileOtp) { return(secret.Length >= MobileOtp.SecretMinLength); } throw new ArgumentOutOfRangeException(nameof(type)); }
public OAuth2Authenticator GetAuthenticator(AuthenticatorType type, Action <string> tokenCallBack) { var authenticator = AuthenticatorService.GetAuthenticator(type, (acct) => { if (acct != null) { Console.WriteLine($"**************************** {acct.Properties["access_token"]} *****************************"); tokenCallBack?.Invoke(acct.Properties["access_token"]); } else { Console.WriteLine($"**************************** Account was NULL *****************************"); tokenCallBack?.Invoke("Token was null"); } if (Xamarin.Forms.Device.RuntimePlatform == "iOS") { DependencyService.Get <IViewStack>().DismissTopView(); } }, (error) => { Log.LogException(error); tokenCallBack?.Invoke(error.Message); }); AuthenticationState.Authenticator = authenticator; return(authenticator); }
public WearAuthenticatorResponse(AuthenticatorType type, string icon, string issuer, string username, int period, int digits) { Type = type; Icon = icon; Issuer = issuer; Username = username; Period = period; Digits = digits; }
private void AuthenticateUser(AuthenticatorType type) { var authenticator = OAuthBLL.GetAuthenticator(type, (token) => { AccessToken = token; }); PresentUILoginScreen(authenticator); }
public static GenerationMethod GetGenerationMethod(this AuthenticatorType type) { return(type switch { AuthenticatorType.Hotp => GenerationMethod.Counter, AuthenticatorType.Totp => GenerationMethod.Time, AuthenticatorType.MobileOtp => GenerationMethod.Time, AuthenticatorType.SteamOtp => GenerationMethod.Time, _ => throw new ArgumentOutOfRangeException(nameof(type)) });
public WearAuthenticator(AuthenticatorType type, string secret, string icon, string issuer, string username, int period, int digits, OtpHashMode algorithm, List <string> categoryIds) { Type = type; Secret = secret; Icon = icon; Issuer = issuer; Username = username; Period = period; Digits = digits; Algorithm = algorithm; CategoryIds = categoryIds; }
public static string CleanSecret(string input, AuthenticatorType type) { if (type.IsHmacBased()) { input = input.ToUpper(); } input = input.Replace(" ", ""); input = input.Replace("-", ""); return(input); }
public WearAuthenticator(AuthenticatorType type, string secret, string icon, string issuer, string username, int period, int digits, HashAlgorithm algorithm, int ranking, List <WearAuthenticatorCategory> categories) { Type = type; Secret = secret; Icon = icon; Issuer = issuer; Username = username; Period = period; Digits = digits; Algorithm = algorithm; Ranking = ranking; Categories = categories; }
public OAuth2Authenticator GetAuthenticator(AuthenticatorType type, Action <Account> completed, Action <Exception> error) { OAuth2Authenticator authenticator = null; switch (type) { case AuthenticatorType.Google: authenticator = GetGoogleAuthenticator(completed, error); break; case AuthenticatorType.Facebook: authenticator = GetFaceBookAuthenticator(completed, error); break; } return(authenticator); }
public static string ToIdxKeyString(this AuthenticatorType authenticatorTypeEnum) { switch (authenticatorTypeEnum) { case AuthenticatorType.Email: return("okta_email"); case AuthenticatorType.Phone: return("phone_number"); case AuthenticatorType.Password: return("okta_password"); default: return(string.Empty); } }
public void DoAuthentication(AuthenticatorType authenticatorType) { Creator creator = null; switch (authenticatorType) { case AuthenticatorType.Google: creator = new GoogleCreator(); break; case AuthenticatorType.Facebook: creator = new FacebookCreator(); break; } Authenticator authenticator = creator.CreateInstance(); authenticator.DoAuthentication(); }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.activityCode); _progressBar = FindViewById <ProgressBar>(Resource.Id.progressBar); _codeTextView = FindViewById <TextView>(Resource.Id.textCode); var usernameText = FindViewById <TextView>(Resource.Id.textUsername); usernameText.Text = Intent.Extras.GetString("username"); var iconView = FindViewById <ImageView>(Resource.Id.imageIcon); iconView.SetImageResource(Icon.GetService(Intent.Extras.GetString("icon"), true)); _nodeId = Intent.Extras.GetString("nodeId"); _position = Intent.Extras.GetInt("position"); _period = Intent.Extras.GetInt("period"); _digits = Intent.Extras.GetInt("digits"); _type = (AuthenticatorType)Intent.Extras.GetInt("type"); _timer = new Timer { Interval = 1000, AutoReset = true }; switch (_type) { case AuthenticatorType.Totp: _timer.Enabled = true; _timer.Elapsed += Tick; break; case AuthenticatorType.Hotp: _progressBar.Visibility = ViewStates.Invisible; break; } await WearableClass.GetMessageClient(this).AddListenerAsync(this); }
protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.activityCode); _progressBar = FindViewById <ProgressBar>(Resource.Id.progressBar); _codeTextView = FindViewById <TextView>(Resource.Id.textCode); var usernameText = FindViewById <TextView>(Resource.Id.textUsername); usernameText.Text = Intent.Extras.GetString("username"); var iconView = FindViewById <ImageView>(Resource.Id.imageIcon); var hasCustomIcon = Intent.Extras.GetBoolean("hasCustomIcon"); if (hasCustomIcon) { var bitmap = (Bitmap)Intent.Extras.GetParcelable("icon"); if (bitmap != null) { iconView.SetImageBitmap(bitmap); } else { iconView.SetImageResource(Icon.GetService(Icon.Default, true)); } } else { iconView.SetImageResource(Icon.GetService(Intent.Extras.GetString("icon"), true)); } _nodeId = Intent.Extras.GetString("nodeId"); _position = Intent.Extras.GetInt("position"); _period = Intent.Extras.GetInt("period"); _digits = Intent.Extras.GetInt("digits"); _type = (AuthenticatorType)Intent.Extras.GetInt("type"); _timer = new Timer { Interval = 1000, AutoReset = true }; switch (_type) { case AuthenticatorType.Totp: _timer.Enabled = true; _timer.Elapsed += Tick; break; case AuthenticatorType.Hotp: _progressBar.Visibility = ViewStates.Invisible; break; } var placeholderCode = FormatCode(null, _digits); placeholderCode = placeholderCode.Replace("-", "- ").TrimEnd(); _codeTextView.Text = placeholderCode; await WearableClass.GetMessageClient(this).AddListenerAsync(this); await Refresh(); }
public EditMenuBottomSheet(AuthenticatorType type, long counter) { RetainInstance = true; _type = type; _counter = counter; }
private ProxyAuthenticator(SoapHttpClientAuthenticator authenticator, AuthenticatorType authenticatorType) { this.authenticator = authenticator; this.AuthenticatorType = authenticatorType; }