示例#1
0
        public OperationResult Synchronize(string tokenInternalID, string firstPwd, string secondPwd)
        {
            TokenCryptoData _tkCryptoData = new TokensDAO().loadTokenCryptoData(tokenInternalID);
            OperationResult result;

            if (_tkCryptoData.ID == null)
            {
                result = OperationResult.Error;
            }
            else
            {
                if (_tkCryptoData.TokenBaseParams.MovingFactorType != TokenMovingFactorType.EventBase && _tkCryptoData.TokenBaseParams.SeedType == TokenSeedType.ActivactionKey)
                {
                    throw new Exception("Function not implemented for this type of token!!");
                }
                long _MovingFactor;
                if (OperationResult.Success == HOTPPwdValidator.Synchronize(_tkCryptoData, new byte[0], this._masterKey, firstPwd, secondPwd, out _MovingFactor))
                {
                    _tkCryptoData.ResetMovingFactor(_MovingFactor);
                    if (new TokensDAO().updateMovingFactor(_tkCryptoData) != OperationResult.Success)
                    {
                        result = OperationResult.Success;
                        return(result);
                    }
                }
                result = OperationResult.Error;
            }
            return(result);
        }
示例#2
0
        public AutenticationStatus Autenticate(string tokenInternalID, string password, string dataEntropy, out string newChallenge)
        {
            newChallenge = null;
            TokenCryptoData     _tkCryptoData = new TokensDAO().loadTokenCryptoData(tokenInternalID);
            AutenticationStatus result;

            if (_tkCryptoData.ID == null)
            {
                result = AutenticationStatus.ErrorCheckTokenStatus;
            }
            else
            {
                if (_tkCryptoData.TokenBaseParams.MovingFactorType != TokenMovingFactorType.EventBase && _tkCryptoData.TokenBaseParams.SeedType == TokenSeedType.ActivactionKey)
                {
                    throw new Exception("Function not implemented for this type of token!!");
                }
                long _MovingFactor;
                AutenticationStatus _authStatus = HOTPPwdValidator.Validate(_tkCryptoData, (dataEntropy == null) ? new byte[0] : BaseFunctions.convertStringToByteArray(dataEntropy), this._masterKey, password, out _MovingFactor);
                if (_authStatus == AutenticationStatus.Success || _authStatus == AutenticationStatus.SuccessButSynchronized)
                {
                    _tkCryptoData.ResetMovingFactor(_MovingFactor);
                    if (new TokensDAO().updateMovingFactor(_tkCryptoData) != OperationResult.Success)
                    {
                        result = AutenticationStatus.TokenOrPasswordInvalid;
                        return(result);
                    }
                }
                result = _authStatus;
            }
            return(result);
        }