Example #1
0
        public bool Encrypt(Security.EncryptionProvider.EncryptionType encType, string userPassword)
        {
            if (!this.IsDecrypted)
            {
                return(false);
            }

            if (encType == Security.EncryptionProvider.EncryptionType.None)
            {
                _token = (byte[])_decryptedToken.Clone();
            }

            byte[] encryptedToken = Security.EncryptionProvider.Encrypt((byte[])_decryptedToken.Clone(), encType, userPassword);

            if (encryptedToken == null)
            {
                return(false);
            }

            this.EncryptionType = encType;
            _token = encryptedToken;

            return(true);
        }
Example #2
0
        private void Initialize(string name, string serial, byte[] token, bool?supportsRestore, Security.EncryptionProvider.EncryptionType encryptionType)
        {
            if (!IsValidSerial(serial))
            {
                throw new InvalidOperationException("Serial is invalid");
            }

            this.Name   = name;
            this.Serial = serial;
            this.Token  = (byte[])token.Clone();

            this.EncryptionType = encryptionType;

            if (supportsRestore.HasValue == false)
            {
                try
                {
                    Authenticator auth = BlizzardAPI.RestoreAuthenticator(this.Serial, this.RestoreCode);

                    this.IsRestoreSupported = !(auth == null);
                }
                catch (Exception)
                {
                    this.IsRestoreSupported = false;
                }
            }
            else
            {
                this.IsRestoreSupported = (bool)supportsRestore;
            }
        }
Example #3
0
 public Authenticator(string name, string serial, byte[] token, bool?supportsRestore, Security.EncryptionProvider.EncryptionType encryptionType)
 {
     Initialize(name, serial, token, supportsRestore, encryptionType);
 }