Пример #1
0
        public static OperationResult Import(TokenCryptoData tokenCryptoData, string tokenCreationLotID, DateTime tokenExpirationDate)
        {
            OperationResult result;

            try
            {
                if (tokenCryptoData.CryptoData.MovingFactor == 0L || tokenCryptoData.CryptoData.InternalSerialNumber == null || tokenCryptoData.CryptoData.CryptoKey == null)
                {
                    result = OperationResult.Error;
                }
                else
                {
                    string tkID;
                    result = new TokensDAO().createToken(tokenCryptoData.TokenBaseParams.TokenTypeBaseParamsID, tokenCryptoData.CryptoData.MovingFactor, tokenExpirationDate, tokenCryptoData.CryptoData.CryptoKey, tokenCryptoData.SupplierSerialNumber, tokenCryptoData.CryptoData.InternalSerialNumber, tokenCreationLotID, tokenCryptoData.CryptoData.SupportCryptoData, out tkID);
                }
            }
            catch (Exception ex)
            {
                SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
                {
                    "http://sfexpand.SAFCore.PREProcessorTokens.softfinanca.com/",
                    Assembly.GetExecutingAssembly().FullName.ToString(),
                    ex.ToString()
                });
                result = OperationResult.Error;
            }
            return(result);
        }
		public static OperationResult Import(TokenCryptoData tokenCryptoData, string tokenCreationLotID, DateTime tokenExpirationDate)
		{
			OperationResult result;
			try
			{
				if (tokenCryptoData.CryptoData.MovingFactor == 0L || tokenCryptoData.CryptoData.InternalSerialNumber == null || tokenCryptoData.CryptoData.CryptoKey == null)
				{
					result = OperationResult.Error;
				}
				else
				{
					string tkID;
					result = new TokensDAO().createToken(tokenCryptoData.TokenBaseParams.TokenTypeBaseParamsID, tokenCryptoData.CryptoData.MovingFactor, tokenExpirationDate, tokenCryptoData.CryptoData.CryptoKey, tokenCryptoData.SupplierSerialNumber, tokenCryptoData.CryptoData.InternalSerialNumber, tokenCreationLotID, tokenCryptoData.CryptoData.SupportCryptoData, out tkID);
				}
			}
			catch (Exception ex)
			{
				SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[]
				{
					"http://sfexpand.SAFCore.PREProcessorTokens.softfinanca.com/",
					Assembly.GetExecutingAssembly().FullName.ToString(),
					ex.ToString()
				});
				result = OperationResult.Error;
			}
			return result;
		}
		public OperationResult Create(string tokenVendorID, DateTime expirationDate, string supplierSerialNumber, string creationLotID, string pin, out TokenInfoCore tokenInfoCore)
		{
			string _tokenBlob = null;
			OperationResult result;
			if (pin == null || (pin ?? "").Length < 2)
			{
				tokenInfoCore = new TokenInfoCore();
				result = OperationResult.Error;
			}
			else
			{
				OperationResult _hResult = new TokensDAO().newTokenFromPreInsertedSeed(tokenVendorID, TokenStatus.ReadyToDeploy, out tokenInfoCore);
				if (_hResult == OperationResult.Success)
				{
					IBLOBData _blobProcessor = BLOBDataFactory.LoadAssembly("SF.Expand.SAF.Blobs.BLOBStructInfSrv, SF.Expand.SAF.Blobs");
					if (_blobProcessor.Export(pin, "J1", null, new TokensDAO().loadTokenCryptoData(tokenInfoCore.InternalID.ToString()), out _tokenBlob))
					{
						if (OperationResult.Success != new TokensDAO().updateCryptoData(tokenInfoCore.InternalID.ToString(), _tokenBlob))
						{
							this.UndoCreate(tokenInfoCore.InternalID.ToString());
							_hResult = OperationResult.Error;
						}
					}
				}
				result = _hResult;
			}
			return result;
		}
		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;
		}
		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;
		}
		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.TokenNotFoundOrCanceled;
			}
			else
			{
				if (_tkCryptoData.TokenBaseParams.MovingFactorType != TokenMovingFactorType.TransactionAuthenticationNumber)
				{
					throw new Exception("Function not implemented for this type of token!!");
				}
				string currentChallenge = (string)new TokensChallengeRequestDAO().loadChallengeRequest(tokenInternalID);
				if (currentChallenge == null)
				{
					result = AutenticationStatus.InvalidDataOnPasswordValidation;
				}
				else
				{
					int iRequest = int.Parse(SAFConfiguration.readParameterExternal("TANRequestPositions"));
					int iDigitsByPos = int.Parse(SAFConfiguration.readParameterExternal("TANDigitsByPosition"));
					int iFixPosOnFaill = int.Parse(SAFConfiguration.readParameterExternal("TANFixedPosOnFail"));
					string _otp = string.Empty;
					byte[] _tkSeedOpen = _tkCryptoData.GetTokenSeed("");
					byte[] _dataEntropy = (dataEntropy == null || dataEntropy.Length < 1) ? new byte[0] : BaseFunctions.convertStringToByteArray(dataEntropy);
					string[] _arrayPosValid = currentChallenge.Split(new char[]
					{
						'|'
					});
					string[] _arrayChallenge = BaseFunctions.DecodeFrom64(_tkCryptoData.CryptoData.SupportCryptoData.Trim()).Split(new char[]
					{
						';'
					});
					for (int idx = 0; idx < _arrayPosValid.Length; idx++)
					{
						string[] _temp = _arrayPosValid[idx].Trim().Split(new char[]
						{
							';'
						});
						_tkCryptoData.ResetMovingFactor(long.Parse(_arrayChallenge[(int)checked((IntPtr)long.Parse(_temp[0]))]));
						_otp += HOTPPwdGenerator.generate(_tkCryptoData, _tkSeedOpen, _dataEntropy).Substring(int.Parse(_temp[1]), 1);
					}
					if (password.Trim() == _otp)
					{
						if (OperationResult.Success == new TokensChallengeRequestDAO().resetChallengeRequest(tokenInternalID))
						{
							result = AutenticationStatus.Success;
							return result;
						}
					}
					result = AutenticationStatus.TokenOrPasswordInvalid;
				}
			}
			return result;
		}
		public static OperationResult Import(TokenCryptoData tokenCryptoData, string tokenCreationLotID, DateTime tokenExpirationDate)
		{
			OperationResult result;
			try
			{
				if (tokenCryptoData.CryptoData.MovingFactor == 0L || tokenCryptoData.CryptoData.InternalSerialNumber == null || tokenCryptoData.CryptoData.CryptoKey == null)
				{
					result = OperationResult.Error;
				}
				else
				{
					string text;
					result = new TokensDAO().createToken(tokenCryptoData.TokenBaseParams.TokenTypeBaseParamsID, tokenCryptoData.CryptoData.MovingFactor, tokenExpirationDate, tokenCryptoData.CryptoData.CryptoKey, tokenCryptoData.SupplierSerialNumber, tokenCryptoData.CryptoData.InternalSerialNumber, tokenCreationLotID, tokenCryptoData.CryptoData.SupportCryptoData, out text);
				}
			}
			catch
			{
				result = OperationResult.Error;
			}
			return result;
		}
Пример #8
0
        public OperationResult ResetChallengeRequest(string tokenInternalID)
        {
            OperationResult result;

            try
            {
                TokenCryptoData tokenCryptoData = new TokensDAO().loadTokenCryptoData(tokenInternalID);
                if (tokenCryptoData.ID == null)
                {
                    result = OperationResult.Error;
                }
                else
                {
                    result = new TokensChallengeRequestDAO().resetChallengeRequest(tokenCryptoData.ID);
                }
            }
            catch
            {
                result = OperationResult.Error;
            }
            return(result);
        }
        public static OperationResult Import(TokenCryptoData tokenCryptoData, string tokenCreationLotID, DateTime tokenExpirationDate)
        {
            OperationResult result;

            try
            {
                if (tokenCryptoData.CryptoData.MovingFactor == 0L || tokenCryptoData.CryptoData.InternalSerialNumber == null || tokenCryptoData.CryptoData.CryptoKey == null)
                {
                    result = OperationResult.Error;
                }
                else
                {
                    string text;
                    result = new TokensDAO().createToken(tokenCryptoData.TokenBaseParams.TokenTypeBaseParamsID, tokenCryptoData.CryptoData.MovingFactor, tokenExpirationDate, tokenCryptoData.CryptoData.CryptoKey, tokenCryptoData.SupplierSerialNumber, tokenCryptoData.CryptoData.InternalSerialNumber, tokenCreationLotID, tokenCryptoData.CryptoData.SupportCryptoData, out text);
                }
            }
            catch
            {
                result = OperationResult.Error;
            }
            return(result);
        }
Пример #10
0
        public OperationResult ResetMovingFactor(string tokenInternalID, long movingFactorValue)
        {
            OperationResult result;

            try
            {
                TokenCryptoData tkCryptoData = new TokensDAO().loadTokenCryptoData(tokenInternalID);
                if (tkCryptoData.ID == null)
                {
                    result = OperationResult.Error;
                }
                else
                {
                    tkCryptoData.ResetMovingFactor(movingFactorValue);
                    result = new TokensDAO().updateMovingFactor(tkCryptoData);
                }
            }
            catch
            {
                result = OperationResult.Error;
            }
            return(result);
        }
		public OperationResult StartServerAuthentication(string tokenInternalID, long movingFactorDrift, string dataEntropy, out string newPwd)
		{
			TokenCryptoData _tkCryptoData = new TokensDAO().loadTokenCryptoData(tokenInternalID);
			OperationResult result;
			if (_tkCryptoData.ID == null)
			{
				newPwd = 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!!");
				}
				if (movingFactorDrift > 0L)
				{
					_tkCryptoData.ResetMovingFactor(movingFactorDrift);
				}
				newPwd = HOTPPwdGenerator.generate(_tkCryptoData, this._masterKey, (dataEntropy == null) ? new byte[0] : BaseFunctions.convertStringToByteArray(dataEntropy));
				result = OperationResult.Success;
			}
			return result;
		}
		public OperationResult ResetMovingFactor(string tokenInternalID, long movingFactorValue)
		{
			OperationResult result;
			try
			{
				TokenCryptoData tkCryptoData = new TokensDAO().loadTokenCryptoData(tokenInternalID);
				if (tkCryptoData.ID == null)
				{
					result = OperationResult.Error;
				}
				else
				{
					tkCryptoData.ResetMovingFactor(movingFactorValue);
					result = new TokensDAO().updateMovingFactor(tkCryptoData);
				}
			}
			catch
			{
				result = OperationResult.Error;
			}
			return result;
		}
Пример #13
0
		public static AutenticationStatus tokenPasswordValidation(string applicationUser, string tokenPassword, string dataEntropy, string baseNotifyMessage, out string newChallenge)
		{
			newChallenge = null;
			int _totRows = 0;
			long tokenEventID = 0L;
			bool _pwdValidStat = false;
			AutenticationStatus _autenticationStatus = AutenticationStatus.AutenticationProcessFail;
			ITokenRules _TKRules = TokenRulesFactory.LoadAssembly(SAFConfiguration.readParameterExternal("SAFClientBusinessRules"));
			AutenticationStatus result;
			try
			{
				TokenInfo[] _arrayTkInfo = new TokenBusinessDAO().loadActiveTokensByUser(applicationUser, "1", 9999, 1, out _totRows);
				if (_arrayTkInfo.Length < 1)
				{
					new TokensBusinessEventsDAO().insertTokenEvent("0", 205, 204, applicationUser, out tokenEventID);
					_autenticationStatus = (result = AutenticationStatus.TokenNotFoundOrCanceled);
				}
				else
				{
					for (int i = 0; i < _arrayTkInfo.Length; i++)
					{
						TokenCryptoData _tkCryptoData = new TokensDAO().loadTokenCryptoData(_arrayTkInfo[i].tokenInfoCore.InternalID.ToString());
						if (_TKRules != null)
						{
							if (AutenticationStatus.Success != (_autenticationStatus = _TKRules.BeforeAutenticate(applicationUser, _arrayTkInfo[i].tokenInfoCore.InternalID.ToString(), baseNotifyMessage, true, _tkCryptoData.TokenBaseParams.MovingFactorType, _tkCryptoData.TokenBaseParams.SeedType)))
							{
								new TokensBusinessEventsDAO().insertTokenEvent(_arrayTkInfo[i].tokenInfoCore.InternalID.ToString(), 102, (int)_autenticationStatus, applicationUser, out tokenEventID);
								result = _autenticationStatus;
								return result;
							}
						}
						_autenticationStatus = SAFBaseFunctions._tokenPasswordValidation(_arrayTkInfo[i].ApplicationUser, _arrayTkInfo[i].tokenInfoCore.InternalID.ToString(), tokenPassword, dataEntropy, out newChallenge);
						if (_autenticationStatus == AutenticationStatus.Success || _autenticationStatus == AutenticationStatus.SuccessButSynchronized)
						{
							_pwdValidStat = true;
							new TokensBusinessEventsDAO().insertTokenEvent(_arrayTkInfo[i].tokenInfoCore.InternalID.ToString(), 102, (int)_autenticationStatus, applicationUser, out tokenEventID);
							if (_TKRules != null)
							{
								_autenticationStatus = _TKRules.AfterAutenticate(applicationUser, _arrayTkInfo[i].tokenInfoCore.InternalID.ToString(), baseNotifyMessage, true, newChallenge, _tkCryptoData.TokenBaseParams.MovingFactorType, _tkCryptoData.TokenBaseParams.SeedType);
							}
							break;
						}
					}
					if (!_pwdValidStat)
					{
						new TokensBusinessEventsDAO().insertTokenEvent("0", 205, -1, applicationUser, out tokenEventID);
					}
					result = _autenticationStatus;
				}
			}
			catch (Exception ex)
			{
				SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[]
				{
					"http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/",
					Assembly.GetExecutingAssembly().FullName.ToString(),
					ex.ToString()
				});
				_autenticationStatus = (result = AutenticationStatus.AutenticationProcessFail);
			}
			finally
			{
				APPEVENTSDeff arg_295_0 = APPEVENTSDeff.OPERATIONS_EXECUTED;
				int arg_295_1 = 102;
				string arg_295_2 = "SAFBUSINESS";
				string[] array = new string[2];
				array[0] = TokenEventOperation.cTOKEN_REQUEST_VALIDATION.ToString();
				string[] arg_292_0 = array;
				int arg_292_1 = 1;
				int num = (int)_autenticationStatus;
				arg_292_0[arg_292_1] = num.ToString();
				SAFInternalEvents.Export(arg_295_0, arg_295_1, arg_295_2, array);
			}
			return result;
		}
		public static string processRequest(string httpParamters)
		{
			string appBase64Data = null;
			string appContentType = null;
			string _deployProcessorTypeName = null;
			long requestDeployEventID = 0L;
			string[] _inParams = httpParamters.Split(new char[]
			{
				'|'
			});
			string result;
			if (_inParams.Length % 2 != 0 || _inParams.Length < 4)
			{
				result = null;
			}
			else
			{
				DataTable _dTableEvent;
				if (OperationResult.Error == new TokensBusinessEventsDAO().loadDeployEventInfo(_inParams[1], out _dTableEvent))
				{
					result = null;
				}
				else
				{
					if (_dTableEvent.Rows.Count != 1)
					{
						result = null;
					}
					else
					{
						TokenCryptoData _tokenCryptoData = new TokensDAO().loadTokenCryptoData(_dTableEvent.Rows[0][0].ToString());
						if (_tokenCryptoData.ID == null)
						{
							result = null;
						}
						else
						{
							if (OperationResult.Success != HttpDeployProcessor._processTokenEvents(_dTableEvent.Rows[0][0].ToString(), _dTableEvent.Rows[0][2].ToString(), httpParamters, out requestDeployEventID))
							{
								result = null;
							}
							else
							{
								new DeployTokenDAO().loadDeployProcessor(_dTableEvent.Rows[0][1].ToString(), _inParams[3].Trim(), out _deployProcessorTypeName);
								if (_deployProcessorTypeName == null)
								{
									new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), 1);
									result = null;
								}
								else
								{
									try
									{
										IDeployToken _deployProcessor = DeployTokenFactory.LoadAssembly(_deployProcessorTypeName);
										if (OperationResult.Success == _deployProcessor.AssembleTokenApplication(BaseFunctions.HexDecoder(_tokenCryptoData.CryptoData.SupportCryptoData), out appContentType, out appBase64Data))
										{
											if (OperationResult.Success == SAFBaseFunctions.tokenEnable(_dTableEvent.Rows[0][2].ToString(), _dTableEvent.Rows[0][0].ToString(), null))
											{
												result = appContentType + "|" + appBase64Data;
												return result;
											}
										}
										new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), 1);
										result = null;
									}
									catch (Exception ex)
									{
										SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESSDEPLOY", new string[]
										{
											"http://sfexpand.SAFDeploy.DEPLOYJ1JAVAINFOSRV.softfinanca.com/",
											Assembly.GetExecutingAssembly().FullName.ToString(),
											ex.ToString()
										});
										new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), 1);
										result = null;
									}
									finally
									{
									}
								}
							}
						}
					}
				}
			}
			return result;
		}
		public OperationResult ChallengeRequest(string tokenInternalID, string dataEntropy, out string newChallenge)
		{
			TokenCryptoData _tkCryptoData = new TokensDAO().loadTokenCryptoData(tokenInternalID);
			OperationResult result;
			if (_tkCryptoData.ID == null)
			{
				newChallenge = null;
				result = OperationResult.Error;
			}
			else
			{
				if (_tkCryptoData.TokenBaseParams.MovingFactorType != TokenMovingFactorType.TransactionAuthenticationNumber && _tkCryptoData.TokenBaseParams.MovingFactorType != TokenMovingFactorType.EventBase && _tkCryptoData.TokenBaseParams.SeedType == TokenSeedType.ActivactionKey)
				{
					throw new Exception("Function not implemented for this type of token!!");
				}
				string currentChallenge = (string)new TokensChallengeRequestDAO().loadChallengeRequest(tokenInternalID);
				if (currentChallenge != null)
				{
					newChallenge = this.formatChallenge(currentChallenge.Trim());
					result = OperationResult.Success;
				}
				else
				{
					int _idx = 0;
					int iRequest = int.Parse(SAFConfiguration.readParameterExternal("TANRequestPositions"));
					int iDigitsByPos = int.Parse(SAFConfiguration.readParameterExternal("TANDigitsByPosition"));
					int[] _array = new int[iRequest];
					string _lastRequest = string.Empty;
					DateTime _lastRequestValidThru = (_tkCryptoData.TokenBaseParams.ChallengeRequestValidUntil > 0) ? DateTime.Now.AddSeconds((double)_tkCryptoData.TokenBaseParams.ChallengeRequestValidUntil) : DateTime.MaxValue;
					while (_idx != iRequest)
					{
						bool _flag;
						do
						{
							_flag = false;
							Random rndArray = new Random();
							_array[_idx] = rndArray.Next(0, _tkCryptoData.TokenBaseParams.OTPValidationWindow);
							for (int _idx2 = 0; _idx2 < _idx; _idx2++)
							{
								if (_array[_idx] == _array[_idx2])
								{
									_flag = true;
									break;
								}
							}
						}
						while (_flag);
						Random rndPos = new Random();
						string text = _lastRequest;
						_lastRequest = string.Concat(new string[]
						{
							text,
							_array[_idx].ToString().Trim(),
							";",
							rndPos.Next(0, _tkCryptoData.TokenBaseParams.OTPTotalDigits).ToString().Trim(),
							"|"
						});
						_idx++;
					}
					newChallenge = this.formatChallenge(_lastRequest.Substring(0, _lastRequest.Length - 1).Trim());
					result = new TokensChallengeRequestDAO().persistChallengeRequest(tokenInternalID, _lastRequest.Substring(0, _lastRequest.Length - 1).Trim(), _lastRequestValidThru);
				}
			}
			return result;
		}
Пример #16
0
        public static OperationResult loadTokenKeyInformation(string tokenID, out string tokenKey)
        {
            OperationResult result = OperationResult.Error;
            tokenKey = null;
            TokenCryptoData tokenCryptoData2 = new TokensDAO().loadTokenCryptoData(tokenID);

            string masterKey = SF.Expand.SAF.Configuration.SAFConfiguration.readMasterKey();
            byte[] tokenSeed = tokenCryptoData2.GetTokenSeed(masterKey);
            if (tokenSeed != null)
            {
                Base32Encoder enc = new Base32Encoder();
                tokenKey = enc.Encode(tokenSeed);
                result = OperationResult.Success;
            }

            return result;
        }
		public OperationResult ResetChallengeRequest(string tokenInternalID)
		{
			OperationResult result;
			try
			{
				TokenCryptoData tokenCryptoData = new TokensDAO().loadTokenCryptoData(tokenInternalID);
				if (tokenCryptoData.ID == null)
				{
					result = OperationResult.Error;
				}
				else
				{
					result = new TokensChallengeRequestDAO().resetChallengeRequest(tokenCryptoData.ID);
				}
			}
			catch
			{
				result = OperationResult.Error;
			}
			return result;
		}
        /// <summary>
        /// </summary>
        /// <param name="httpParamters"></param>
        /// <returns></returns>
        public static string processRequest(string httpParamters)
        {
            string appBase64Data = null;
            string appContentType = null;
            string _deployProcessorTypeName = null;
            long requestDeployEventID = 0;

            DataTable _dTableEvent;
            IDeployToken _deployProcessor = null;

            string[] _inParams = httpParamters.Split(new char[] { '|' });
            if (_inParams.Length % 2 != 0 || _inParams.Length < 4)
            {
                return null;
            }

            if (OperationResult.Error == new TokensBusinessEventsDAO().loadDeployEventInfo(_inParams[1], out _dTableEvent))
            {
                return null;
            }
            if (_dTableEvent.Rows.Count != 1)
            {
                return null;
            }
            TokenCryptoData _tokenCryptoData = new TokensDAO().loadTokenCryptoData(_dTableEvent.Rows[0][0].ToString());
            if (_tokenCryptoData.ID == null)
            {
                return null;
            }
            if (OperationResult.Success != _processTokenEvents(_dTableEvent.Rows[0][0].ToString(), _dTableEvent.Rows[0][2].ToString(), httpParamters, out requestDeployEventID))
            {
                return null;
            }
            new DeployTokenDAO().loadDeployProcessor(_dTableEvent.Rows[0][1].ToString(), _inParams[3].Trim(), out _deployProcessorTypeName);
            if (_deployProcessorTypeName == null)
            {
                new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), (byte)1);
                return null;
            }
            try
            {
                _deployProcessor = DeployTokenFactory.LoadAssembly(_deployProcessorTypeName);
                if (OperationResult.Success == _deployProcessor.AssembleTokenApplication(BaseFunctions.HexDecoder(_tokenCryptoData.CryptoData.SupportCryptoData), out appContentType, out appBase64Data))
                {
                    if (OperationResult.Success == SAFBaseFunctions.tokenEnable(_dTableEvent.Rows[0][2].ToString(), _dTableEvent.Rows[0][0].ToString(), null))
                    {
                        return appContentType + "|" + appBase64Data;
                    }
                }

                new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), (byte)1);
                return null;
            }
            catch
            {
                new TokensBusinessEventsDAO().updateEventStatus(requestDeployEventID.ToString(), (byte)1);
                return null;
            }
            finally
            {
                _deployProcessor = null;
            }
        }
Пример #19
0
		public static OperationResult tokenStartServerAuthentication(string applicationUser, string tokenID, string dataEntropy, string baseNotifyMessage, out string requestedPassword)
		{
			requestedPassword = null;
			long tokenEventID = 0L;
			OperationResult _hResult = OperationResult.Error;
			TokenCryptoData _tkCryptoData = default(TokenCryptoData);
			ITokenRules _TKRules = TokenRulesFactory.LoadAssembly(SAFConfiguration.readParameterExternal("SAFClientBusinessRules"));
			OperationResult result;
			try
			{
				TokenStatus _oldCoreStatus;
				if (!SAFBaseFunctions._checkStatusConsistency(tokenID, applicationUser, out _oldCoreStatus))
				{
					new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 103, 83, applicationUser, out tokenEventID);
					_hResult = (result = OperationResult.WrongStatusForRequestedOperation);
				}
				else
				{
					if (_oldCoreStatus != TokenStatus.Enabled)
					{
						new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 103, 83, applicationUser, out tokenEventID);
						_hResult = (result = OperationResult.WrongStatusForRequestedOperation);
					}
					else
					{
						if (_TKRules != null)
						{
							_tkCryptoData = new TokensDAO().loadTokenCryptoData(tokenID);
							if (OperationResult.Success != (_hResult = _TKRules.BeforeStartServerAuthentication(applicationUser, tokenID, baseNotifyMessage, _tkCryptoData.TokenBaseParams.MovingFactorType, _tkCryptoData.TokenBaseParams.SeedType)))
							{
								new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 103, (int)_hResult, applicationUser, out tokenEventID);
								result = _hResult;
								return result;
							}
						}
						_hResult = new PREProcessorTokens().StartServerAuthentication(tokenID, dataEntropy, out requestedPassword);
						new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 103, (int)_hResult, applicationUser, out tokenEventID);
						if (_hResult == OperationResult.Success)
						{
							if (_TKRules != null)
							{
								_hResult = _TKRules.AfterStartServerAuthentication(applicationUser, tokenID, baseNotifyMessage + "|" + requestedPassword, requestedPassword, _tkCryptoData.TokenBaseParams.MovingFactorType, _tkCryptoData.TokenBaseParams.SeedType);
							}
						}
						if (_hResult != OperationResult.Success)
						{
							new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 103, (int)_hResult, applicationUser, out tokenEventID);
						}
						result = _hResult;
					}
				}
			}
			catch (Exception ex)
			{
				SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[]
				{
					"http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/",
					Assembly.GetExecutingAssembly().FullName.ToString(),
					ex.ToString()
				});
				_hResult = (result = OperationResult.Error);
			}
			finally
			{
				APPEVENTSDeff arg_1FA_0 = APPEVENTSDeff.OPERATIONS_EXECUTED;
				int arg_1FA_1 = 103;
				string arg_1FA_2 = "SAFBUSINESS";
				string[] array = new string[2];
				array[0] = TokenEventOperation.cTOKEN_START_SERVER_AUTHENTICATION.ToString();
				string[] arg_1F7_0 = array;
				int arg_1F7_1 = 1;
				int num = (int)_hResult;
				arg_1F7_0[arg_1F7_1] = num.ToString();
				SAFInternalEvents.Export(arg_1FA_0, arg_1FA_1, arg_1FA_2, array);
			}
			return result;
		}
Пример #20
0
		public static AutenticationStatus tokenPasswordValidation(string applicationUser, string tokenID, string tokenPassword, string dataEntropy, string baseNotifyMessage, out string newChallenge)
		{
			newChallenge = null;
			long tokenEventID = 0L;
			TokenCryptoData _tkCryptoData = default(TokenCryptoData);
			AutenticationStatus _autenticationStatus = AutenticationStatus.AutenticationProcessFail;
			ITokenRules _TKRules = TokenRulesFactory.LoadAssembly(SAFConfiguration.readParameterExternal("SAFClientBusinessRules"));
			AutenticationStatus result;
			try
			{
				if (_TKRules != null)
				{
					_tkCryptoData = new TokensDAO().loadTokenCryptoData(tokenID);
					if (AutenticationStatus.Success != (_autenticationStatus = _TKRules.BeforeAutenticate(applicationUser, tokenID, baseNotifyMessage, false, _tkCryptoData.TokenBaseParams.MovingFactorType, _tkCryptoData.TokenBaseParams.SeedType)))
					{
						new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 102, (int)_autenticationStatus, applicationUser, out tokenEventID);
						result = _autenticationStatus;
						return result;
					}
				}
				_autenticationStatus = SAFBaseFunctions._tokenPasswordValidation(applicationUser, tokenID, tokenPassword, dataEntropy, out newChallenge);
				new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 102, (int)_autenticationStatus, applicationUser, out tokenEventID);
				if (_autenticationStatus == AutenticationStatus.Success || _autenticationStatus == AutenticationStatus.SuccessButSynchronized)
				{
					if (_TKRules != null)
					{
						_autenticationStatus = _TKRules.AfterAutenticate(applicationUser, tokenID, baseNotifyMessage, false, newChallenge, _tkCryptoData.TokenBaseParams.MovingFactorType, _tkCryptoData.TokenBaseParams.SeedType);
					}
				}
				result = _autenticationStatus;
			}
			catch (Exception ex)
			{
				SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[]
				{
					"http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/",
					Assembly.GetExecutingAssembly().FullName.ToString(),
					ex.ToString()
				});
				_autenticationStatus = (result = AutenticationStatus.AutenticationProcessFail);
			}
			finally
			{
				APPEVENTSDeff arg_17E_0 = APPEVENTSDeff.OPERATIONS_EXECUTED;
				int arg_17E_1 = 102;
				string arg_17E_2 = "SAFBUSINESS";
				string[] array = new string[2];
				array[0] = TokenEventOperation.cTOKEN_REQUEST_VALIDATION.ToString();
				string[] arg_17B_0 = array;
				int arg_17B_1 = 1;
				int num = (int)_autenticationStatus;
				arg_17B_0[arg_17B_1] = num.ToString();
				SAFInternalEvents.Export(arg_17E_0, arg_17E_1, arg_17E_2, array);
			}
			return result;
		}