Esempio n. 1
0
			public bool SetAuthenticator(Authenticator au)
			{
				if (ServerTimeDiff != string.Empty)
				{
					long offset;
					if (long.TryParse(ServerTimeDiff, out offset))
					{
						au.ServerTimeDiff = offset;
					}
					else
					{
						au.ServerTimeDiff = 0;
					}
				}
				else
				{
					au.ServerTimeDiff = 0;
				}
				if (SecretData != string.Empty)
					au.SecretData = SecretData;
				else
					return false;
				if (RestoreCodeVerified != string.Empty)
					au.RestoreCodeVerified = (string.Compare(RestoreCodeVerified, bool.TrueString.ToLower()) == 0);
				else
					au.RestoreCodeVerified = false;
				return true;
			}
Esempio n. 2
0
		/// <summary>
		/// Set Authenticator instance to Json stream
		/// </summary>
		public static void SetFromJSonStream(Authenticator au, Stream stream)
		{
			 DataContractJsonSerializer jsSerializer = new DataContractJsonSerializer(typeof(Authenticator));
			 jsSerializer.WriteObject(stream, au);
		}
		public async Task<Authenticator> RestoreAuthenticator()
		{
			if (Serial == String.Empty || RestoreCode == String.Empty)
			{
				newAuthenticator = null;
				throw new Exception("无效的序列号或还原码");
			}
			IsRestoring = true;
			try
			{
				newAuthenticator = new Authenticator(Description);

				await newAuthenticator.Restore(Serial, RestoreCode);
			}
			catch (Exception ex)
			{

				newAuthenticator = null;
				throw ex;
			}
			finally
			{
				IsRestoring = false;
			}
			return newAuthenticator;
		}
Esempio n. 4
0
			public bool GetAuthenticator(Authenticator au)
			{

				this.ServerTimeDiff = au.ServerTimeDiff.ToString();
				this.SecretData = au.SecretData;
				this.RestoreCodeVerified = au.RestoreCodeVerified.ToString();
				return true;
			}
		public async Task<Authenticator> EnrollAuthenticator()
		{
			IsEnrolling = true;
			try
			{
				newAuthenticator = new Authenticator(Description);
				string region = SelectedRegion.Code;
				await newAuthenticator.Enroll(region);
			}
			catch (Exception ex)
			{

				newAuthenticator = null;
				throw ex;
			}
			finally
			{
				IsEnrolling = false;

			}
			return newAuthenticator;
		}