private string _loadFromDB(string value, string sqlExec) { IDbCommand _cmd = null; string result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmd = base.CreateCommand(sqlExec, CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param1", value)); base.Connection.Open(); object res = _cmd.ExecuteScalar(); result = (string)res; } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensValidatorDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = null; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return(result); }
public static AutenticationStatus Validate(TokenCryptoData tokenCryptoData, byte[] entropy, string masterKey, string validatePwd, out long movingFactor) { long _initialMovingFactor = tokenCryptoData.CryptoData.MovingFactor; AutenticationStatus result; for (int i = 0; i < tokenCryptoData.TokenBaseParams.OTPValidationWindow; i++) { try { if (validatePwd.Equals(HOTPPwdGenerator.generate(tokenCryptoData, masterKey, entropy))) { AutenticationStatus authStatus = (tokenCryptoData.CryptoData.MovingFactor > _initialMovingFactor) ? AutenticationStatus.SuccessButSynchronized : AutenticationStatus.Success; movingFactor = tokenCryptoData.CryptoData.MovingFactor + tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift; result = authStatus; return(result); } movingFactor = tokenCryptoData.CryptoData.MovingFactor + tokenCryptoData.TokenBaseParams.HOTPMovingFactorDrift; tokenCryptoData.ResetMovingFactor(movingFactor); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.HOTPPwdValidator.softfinanca.com/", ex.ToString() }); } } tokenCryptoData.ResetMovingFactor(_initialMovingFactor); movingFactor = _initialMovingFactor; result = AutenticationStatus.TokenOrPasswordInvalid; return(result); }
public OperationResult InhibitedUse(string tokenInternalID) { OperationResult result; try { string assemb = new TokensValidatorDAO().DeployAssemblyNameByTokenID(tokenInternalID); ITokens _tokens = TokensFactory.LoadAssembly(assemb); if (_tokens == null) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.ERROR, "SAFCORE", new string[] { "http://sfexpand.SAFCore.PREProcessorTokens.softfinanca.com/", "[ITokens]::" + assemb.Trim(), "Invalid or null typename!" }); result = OperationResult.Error; } else { result = _tokens.InhibitedUse(tokenInternalID); } } 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 resetChallengeRequest(string tokenID) { IDbCommand _cmd = null; OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmd = base.CreateCommand(TokensChallengeRequestDAO.spRESET_CHALLENGE_REQUEST_BY_TOKENID, CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@tkID", tokenID)); base.Connection.Open(); result = ((_cmd.ExecuteNonQuery() == 1) ? OperationResult.Success : OperationResult.Error); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensChallengeRequestDAO.softfinanca.com/", ex.ToString() }); result = OperationResult.Error; } finally { if (_cmd != null) { _cmd.Dispose(); } if (base.Connection != null && base.Connection.State == ConnectionState.Open) { base.Connection.Dispose(); } } return(result); }
public int UpdateParameterBusiness(string parameterName, string parameterValue) { IDbCommand _cmd = null; int result; try { base.ConnectionString = DBConnectionString.ExpandSAFBusinessConfiguration(); _cmd = base.CreateCommand("SAFSetConfigurationParameter", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@UserName", null)); _cmd.Parameters.Add(base.AddParameter("@ParameterName", parameterName)); _cmd.Parameters.Add(base.AddParameter("@ParameterValue", parameterValue)); base.Connection.Open(); result = (int)_cmd.ExecuteScalar(); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusinessConfig.SAFConfigurationDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = -1; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return(result); }
private bool _executeProcess(string fname, string execArgs) { Process _execProc = new Process(); bool result; try { _execProc.StartInfo.UseShellExecute = false; _execProc.StartInfo.RedirectStandardError = true; _execProc.StartInfo.CreateNoWindow = true; _execProc.StartInfo.FileName = fname; _execProc.StartInfo.Arguments = execArgs; _execProc.Start(); result = true; } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESSDEPLOY", new string[] { "http://sfexpand.SAFDeploy.DEPLOYJ1POCKETPCINFOSRV.softfinanca.com/", ex.ToString() }); result = false; } finally { if (_execProc != null) { _execProc.Dispose(); } _execProc = null; } return(result); }
private static string readParameterAppConfigSection(string section, string parameter) { string result; try { result = ((NameValueCollection)ConfigurationManager.GetSection(section)).Get(parameter); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusinessConfig.SAFConfiguration.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), string.Concat(new string[] { "failed::[", section, "/", parameter, "]" }), ex.ToString() }); result = null; } return(result); }
public long clearChallengeRequestOverdue(string tokenID) { IDbCommand _cmd = null; long result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmd = base.CreateCommand(TokensChallengeRequestDAO.spCLEAR_OVERDUE_CHALLENGE_REQUEST, CommandType.StoredProcedure); base.Connection.Open(); result = (long)_cmd.ExecuteNonQuery(); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensChallengeRequestDAO.softfinanca.com/", ex.ToString() }); result = -1L; } finally { if (_cmd != null) { _cmd.Dispose(); } if (base.Connection != null && base.Connection.State == ConnectionState.Open) { base.Connection.Dispose(); } } return(result); }
private void _writeDDFFile(string _tempFolder) { StreamWriter _sWriter = null; try { string _extractPath = _tempFolder + ((!_tempFolder.EndsWith("\\")) ? "\\\\" : ""); string _path2DDFFile = Path.Combine(_extractPath, "setup.ddf"); StreamReader _sReader = File.OpenText(_path2DDFFile); string _fdata = _sReader.ReadToEnd(); _sReader.Close(); File.Delete(_path2DDFFile); _sWriter = File.CreateText(_path2DDFFile); _sWriter.Write(_fdata.Replace("###FileName###", "infotoken.cab").Replace("###ExtractionFolder###", _extractPath).Replace("###Path###", _extractPath)); _sWriter.Flush(); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESSDEPLOY", new string[] { "http://sfexpand.SAFDeploy.DEPLOYJ1POCKETPCINFOSRV.softfinanca.com/", ex.ToString() }); } finally { if (_sWriter != null) { _sWriter.Close(); } } }
public OperationResult tokenStatus(string tokenID, out TokenStatus tokenStatus) { tokenStatus = TokenStatus.Undefined; IDbCommand _cmd = null; OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmd = base.CreateCommand("TokenGetStatus", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@tkID", tokenID)); base.Connection.Open(); tokenStatus = (TokenStatus)((byte)_cmd.ExecuteScalar()); result = OperationResult.Success; } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return(result); }
public OperationResult updateEventStatus(string tokenEventID, byte tokenStatus) { IDbCommand _cmd = null; OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSecureBusiness(); _cmd = base.CreateCommand("TokenEventsUpdateStatus", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@param1", tokenStatus)); _cmd.Parameters.Add(base.AddParameter("@param2", tokenEventID)); base.Connection.Open(); result = ((_cmd.ExecuteNonQuery() != 0) ? OperationResult.Success : OperationResult.Error); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.TokenBusinessDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return(result); }
public OperationResult updateTokenStatus(string tokenID, TokenStatus tokenStatus) { IDbCommand _cmd = null; OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmd = base.CreateCommand("PersistTokenStatus", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param0", (byte)tokenStatus)); _cmd.Parameters.Add(base.AddParameter("@tkID", tokenID)); base.Connection.Open(); int iRes = _cmd.ExecuteNonQuery(); result = ((iRes == 1) ? OperationResult.Success : OperationResult.Error); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return(result); }
public OperationResult createSubLotByTokenVendor(long numberOfTokensInLot, string tokenParamsID, string subLotID, DateTime expirationDate, out long numberOfSeeds) { IDbCommand _cmdInfo = null; IDbCommand _cmdBuild = null; numberOfSeeds = -1L; string _lotNumber = BaseFunctions.GenerateSupplierLotNumber(numberOfTokensInLot.ToString(), null); OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmdInfo = base.CreateCommand("CheckAvailableSeedsByTokenParamsID", CommandType.StoredProcedure); _cmdInfo.Parameters.Add(base.AddParameter("@Param0", tokenParamsID)); base.Connection.Open(); numberOfSeeds = (long)((int)_cmdInfo.ExecuteScalar()); if (numberOfSeeds < numberOfTokensInLot) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.WARNING, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/createSubLotByTokenVendor", OperationResult.TokenVendorSeedNotAvaliable.ToString() }); result = OperationResult.TokenVendorSeedNotAvaliable; } else { _cmdBuild = base.CreateCommand("CreateSupplierSubLot", CommandType.StoredProcedure); _cmdBuild.Parameters.Add(base.AddParameter("@Param0", _lotNumber)); _cmdBuild.Parameters.Add(base.AddParameter("@Param1", expirationDate)); _cmdBuild.Parameters.Add(base.AddParameter("@Param2", tokenParamsID)); _cmdBuild.Parameters.Add(base.AddParameter("@top", (int)numberOfTokensInLot)); numberOfSeeds = (long)_cmdBuild.ExecuteNonQuery(); result = OperationResult.Success; } } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { if (_cmdInfo != null) { _cmdInfo.Dispose(); } if (_cmdBuild != null) { _cmdBuild.Dispose(); } base.CloseConnection(); } 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 tokenSeedsByParamIDWithNoSubLot(string tokenParamsID, out long numberOfSeeds) { numberOfSeeds = -1L; IDbCommand _cmdInfo = null; OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmdInfo = base.CreateCommand("CheckAvailableSeedsByTokenParamsID", CommandType.StoredProcedure); _cmdInfo.Parameters.Add(base.AddParameter("@Param0", tokenParamsID)); base.Connection.Open(); numberOfSeeds = Convert.ToInt64(_cmdInfo.ExecuteScalar()); result = OperationResult.Success; } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { if (_cmdInfo != null) { _cmdInfo.Dispose(); } base.CloseConnection(); } return(result); }
public static string generate(TokenCryptoData tokenCryptoData, byte[] tokenSeed, byte[] entropy) { int num = (entropy != null) ? (entropy.Length + 8) : 8; long _movingFactor = tokenCryptoData.CryptoData.MovingFactor; int[] DIGITS_POWER = new int[] { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 }; byte[] buffer = new byte[num]; byte[] buffer2 = new byte[20]; string result; try { for (int i = num - 1; i >= 0; i--) { if (num - i <= 8) { buffer[i] = (byte)(_movingFactor & 255L); _movingFactor >>= 8; } else { buffer[i] = entropy[i]; } } buffer2 = CryptoEngineHMACSHA1.process(tokenSeed, buffer, SHA1HashFunction.HashSize); int index = (int)(buffer2[buffer2.Length - 1] & 15); if (0 <= tokenCryptoData.TokenBaseParams.OTPOffSet && tokenCryptoData.TokenBaseParams.OTPOffSet < buffer2.Length - 4) { index = tokenCryptoData.TokenBaseParams.OTPOffSet; } int num2 = (int)(buffer2[index] & 127) << 24 | (int)(buffer2[index + 1] & 255) << 16 | (int)(buffer2[index + 2] & 255) << 8 | (int)(buffer2[index + 3] & 255); int num3 = num2 % DIGITS_POWER[tokenCryptoData.TokenBaseParams.OTPTotalDigits]; result = Convert.ToString(num3, 10).PadLeft(tokenCryptoData.TokenBaseParams.OTPTotalDigits, '0'); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.HOTPPwdGenerator.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = null; } finally { } return(result); }
private static string _readParameterBusiness(string parameterFullName, int cacheSecs) { string result; try { SAFConfigurationParametersMap cacheData = SAFConfiguration._CheckCache(cacheSecs); if (cacheData == null || !cacheData.ContainsKey(parameterFullName)) { result = null; } else { result = cacheData[parameterFullName].value; } } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.WARNING, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusinessConfig.SAFConfiguration.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), "failed::[" + parameterFullName + "]", ex.ToString() }); result = null; } return(result); }
public OperationResult loadDeployProcessor(string tokenParamsID, string httpUserAgent, out string deployProcessor) { deployProcessor = null; IDbCommand _cmd = null; IDbCommand _cmdDefault = null; OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSecureDeployTokens(); _cmd = base.CreateCommand("SELECT tokenDeployProcessorTypeName FROM tokensDeployProcessor WITH (NOLOCK) WHERE tokenDeployProcessorID=(SELECT TOP(1) tokenDeployProcessorID FROM tokensDeployProcessorHttpRules WITH (NOLOCK) WHERE tokenParamsID=@param0 AND @param1 LIKE '%' + httpRequestUserAgentLike + '%')", CommandType.Text); _cmd.Parameters.Add(base.AddParameter("@param0", tokenParamsID)); _cmd.Parameters.Add(base.AddParameter("@param1", httpUserAgent)); base.Connection.Open(); object _resp = _cmd.ExecuteScalar(); if (_resp != null) { deployProcessor = _resp.ToString().Trim(); result = OperationResult.Success; } else { _cmdDefault = base.CreateCommand("SELECT TOP(1) tokenDeployProcessorTypeName FROM tokensDeployProcessor WITH (NOLOCK) WHERE tokenParamsID=@param0 AND tokenDeployProcessorDefault=1", CommandType.Text); _cmdDefault.Parameters.Add(base.AddParameter("@param0", tokenParamsID)); _resp = _cmdDefault.ExecuteScalar(); if (_resp != DBNull.Value) { deployProcessor = _resp.ToString().Trim(); result = OperationResult.Success; } else { result = OperationResult.Error; } } } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESSDEPLOY", new string[] { "http://sfexpand.SAFDeploy.DeployTokenDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { if (_cmd != null) { _cmd.Dispose(); } if (_cmdDefault != null) { _cmdDefault.Dispose(); } base.CloseConnection(); } return(result); }
public long tokensSeedsBulkInsert(string pathFileName, TokenStatus tokenStatus, DateTime tokenExpiration) { IDbCommand _cmd = null; long result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmd = base.CreateCommand("TokenBulkInsert", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@PathFileName", pathFileName)); _cmd.Parameters.Add(base.AddParameter("@tkStatus", (int)tokenStatus)); _cmd.Parameters.Add(base.AddParameter("@tkExpirationDate", tokenExpiration)); base.Connection.Open(); result = (long)_cmd.ExecuteNonQuery(); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = -1L; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return(result); }
public bool Export(string pin, string deviceType, string masterKey, TokenCryptoData tokenCryptoData, out string tokenBlob) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.BLOBStrucSOFT01.softfinanca.com/", new NotImplementedException().ToString() }); throw new NotImplementedException(); }
public bool Import(string tokenBlob, string blobCryptoPasswd, out TokenCryptoData tokenCryptoData) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.BLOBStrucSOFT01.softfinanca.com/", new NotImplementedException().ToString() }); throw new NotImplementedException(); }
public static OperationResult tokenTANFetchMatrixValues(LoteType loteType, string lotID, string TokenVendorID) { DataTable _dt = null; TokenTypeBaseParams _tkBaseParams = default(TokenTypeBaseParams); string _masterKey = SAFConfiguration.readMasterKey(); string _exportFilePath = SAFConfiguration.readParameterExternal("ExportFilePath"); SAFLOGGERInMEMORY logger = SAFLOGGERInMEMORY.GetLogString(_exportFilePath + "\\" + lotID.Trim() + ".DAT", false); logger.Clear(); OperationResult result; try { _tkBaseParams = new TokenParamsDAO().loadTokenBaseParams(TokenVendorID); if (_tkBaseParams.TokenTypeBaseParamsID == null || _tkBaseParams.MovingFactorType != TokenMovingFactorType.TransactionAuthenticationNumber) { result = OperationResult.Error; } else { if (OperationResult.Error == new TokensDAO().loadTableWithTokensLot(loteType, lotID, TokenVendorID, TokenMovingFactorType.TransactionAuthenticationNumber, out _dt)) { result = OperationResult.Error; } else { foreach (DataRow row in _dt.Rows) { TokenCryptoData _tkCryptoData = new TokenCryptoData(row[5].ToString(), row[0].ToString(), new CryptoData((long)row[1], row[2].ToString().Trim(), row[3].ToString().Trim(), (row[6] != null) ? row[6].ToString().Trim() : string.Empty), _tkBaseParams); logger.Add(_tkCryptoData.SupplierSerialNumber + ";" + string.Join(";", TokensBaseFunctions.tokenTANMatrixArrayFetch(_tkCryptoData, _masterKey, null))); } logger.Persist(); result = OperationResult.Success; } } } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensBaseFunctions.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { _dt = null; //TokenCryptoData _tkCryptoData = default(TokenCryptoData); _tkBaseParams = default(TokenTypeBaseParams); } return(result); }
public OperationResult insertTokenEventFields(long tokenEventID, string tokenEventFields) { IDbCommand _cmd = null; string[] _arrayEventFields = tokenEventFields.Split(new char[] { '|' }); OperationResult result; if (_arrayEventFields.Length % 2 != 0 || _arrayEventFields.Length < 4) { result = OperationResult.Error; } else { try { base.ConnectionString = DBConnectionString.ExpandSecureBusiness(); _cmd = base.CreateCommand("TokenEventsFieldsInsert", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@param0", tokenEventID)); _cmd.Parameters.Add(base.AddParameter("@param1", null)); _cmd.Parameters.Add(base.AddParameter("@param2", null)); base.Connection.Open(); for (int i = 0; i < _arrayEventFields.Length; i += 2) { ((IDataParameter)_cmd.Parameters["@param1"]).Value = _arrayEventFields[i]; ((IDataParameter)_cmd.Parameters["@param2"]).Value = _arrayEventFields[i + 1]; _cmd.ExecuteNonQuery(); } result = OperationResult.Success; } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.TokenBusinessDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } } return(result); }
public static OperationResult tokenTANFetchSupplierSerialNumber(LoteType loteType, string lotID, string TokenVendorID) { DataTable _dt = null; TokenTypeBaseParams _tkBaseParams = default(TokenTypeBaseParams); string _exportFilePath = SAFConfiguration.readParameterExternal("ExportFilePath"); SAFLOGGERInMEMORY logger = SAFLOGGERInMEMORY.GetLogString(_exportFilePath + "\\" + lotID.Trim() + "SerialNumbers.TXT", false); logger.Clear(); OperationResult result; try { _tkBaseParams = new TokenParamsDAO().loadTokenBaseParams(TokenVendorID); if (_tkBaseParams.TokenTypeBaseParamsID == null || _tkBaseParams.MovingFactorType != TokenMovingFactorType.TransactionAuthenticationNumber) { result = OperationResult.Error; } else { if (OperationResult.Error == new TokensDAO().tokenSupplierSerialNumbersByLot(loteType, lotID, out _dt)) { result = OperationResult.Error; } else { foreach (DataRow row in _dt.Rows) { logger.Add(row[0].ToString().Trim()); } logger.Persist(); result = OperationResult.Success; } } } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensBaseFunctions.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { _dt = null; logger = null; _tkBaseParams = default(TokenTypeBaseParams); } return(result); }
public override void ProcessMessage(SoapMessage message) { try { if (message.Stage == SoapMessageStage.AfterDeserialize) { string _mtd = this._processSoap(message); string _userExecute = string.Format("USERID '{0}' ", "unknown"); foreach (SoapHeader header in message.Headers) { if (header is AuthHeader) { AuthHeader credentials = (AuthHeader)header; try { switch (credentials.CryptoAlgorithm) { case AuthHeader.CryptoAlgorithmEnum.NONE: _userExecute = string.Format("USERID '{0}' ", credentials.AuthKey.Split(new char[] { '|' })[0]); break; case AuthHeader.CryptoAlgorithmEnum.TRIPLEDES: _userExecute = string.Format("USERID '{0}' ", CryptorEngineTripleDES.Decrypt(SAFConfiguration.readConnectionStringCoreEncrypted(), new SecurityInfo(SAFConfiguration.readMasterKey(), SAFConfiguration.readInfoKey(), SAFConfiguration.readInfoIV()), true).Split(new char[] { '|' })[0]); break; } } catch (SoapException ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFAPILOGGER", new string[] { "http://sfexpand.SAFBusiness.AuthExtension.softfinanca.com/", ex.ToString() }); } } } SAFLOGGER.dump(SAFLOGGER.LOGGEREventID.INFORMATION, "SAFAPILOGGER", new string[] { _userExecute + _mtd }); } } catch { } }
public OperationResult newTokenFromGivenSupplierSerialNumber(string tokenParamsID, string SupplierSerialNumber, out TokenInfoCore tokenInfoCore) { IDbCommand _cmd = null; tokenInfoCore = new TokenInfoCore(); OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmd = base.CreateCommand("GivenSupplierSerialNumberUpdateForNewToken", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param0", 1)); _cmd.Parameters.Add(base.AddParameter("@Param1", 99)); _cmd.Parameters.Add(base.AddParameter("@Param2", tokenParamsID)); _cmd.Parameters.Add(base.AddParameter("@Param3", SupplierSerialNumber)); base.Connection.Open(); object _retID = _cmd.ExecuteScalar(); if (_retID == DBNull.Value || (int)_retID == 0) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.WARNING, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/newTokenFromGivenSupplierSerialNumber", OperationResult.TokenVendorSeedNotAvaliable.ToString() }); result = OperationResult.TokenVendorSeedNotAvaliable; } else { tokenInfoCore = this.loadTokenInfoCore(_retID.ToString()); result = OperationResult.Success; } } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return(result); }
public OperationResult createToken(string tokenParamsID, long movingFactor, DateTime expirationDate, string cryptoKey, string supplierSerialNumber, string internalSerialNumber, string creationLotID, string SupportCryptoData, out string tokenID) { tokenID = null; IDbCommand _cmd = null; OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmd = base.CreateCommand("InsertNewToken", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@tkStatus", 0)); _cmd.Parameters.Add(base.AddParameter("@tkParamsID", tokenParamsID)); _cmd.Parameters.Add(base.AddParameter("@tkMovingFactor", movingFactor)); _cmd.Parameters.Add(base.AddParameter("@tkExpirationDate", expirationDate)); _cmd.Parameters.Add(base.AddParameter("@tkCryptoKey", cryptoKey)); _cmd.Parameters.Add(base.AddParameter("@tkCreationLotID", creationLotID)); _cmd.Parameters.Add(base.AddParameter("@tkSupplierSerialNumber", supplierSerialNumber)); _cmd.Parameters.Add(base.AddParameter("@tkInternalSerialNumber", internalSerialNumber)); _cmd.Parameters.Add(base.AddParameter("@tkSupportCriptoData", SupportCryptoData)); _cmd.Parameters.Add(base.AddParameter("@tokenSubLotID", null)); base.Connection.Open(); long _hResult = long.Parse(_cmd.ExecuteScalar().ToString()); if (_hResult == 1L) { tokenID = _hResult.ToString(); result = OperationResult.Success; } else { result = OperationResult.Error; } } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return(result); }
public static OperationResult TokensCreateNew(TokenTypeBaseParams tkTypeBaseParams, string masterKey, string vendorSerialNumber, string dataEntropy, out TokenCryptoData tokenCryptoData) { OperationResult result; try { byte[] tkseed; byte[] tkserial; long tkmovFactor; if (OperationResult.Error == HOTPCryptoData.Generate(masterKey, null, tkTypeBaseParams, out tkseed, out tkserial, out tkmovFactor)) { tokenCryptoData = new TokenCryptoData(null, null, new CryptoData(), new TokenTypeBaseParams()); result = OperationResult.Error; } else { TokenCryptoData _tkCryptoData = new TokenCryptoData(null, vendorSerialNumber, new CryptoData(tkmovFactor, BaseFunctions.HexEncoder(tkseed), BaseFunctions.HexEncoder(tkserial), ""), tkTypeBaseParams); _tkCryptoData.ResetMovingFactor(HOTPCipherInitialize.createSequenceNumber()); if (tkTypeBaseParams.MovingFactorType == TokenMovingFactorType.TransactionAuthenticationNumber) { string supportCryptoData; if (OperationResult.Error == TokensBaseFunctions.tokenTANMatrixIntegrityCheck(_tkCryptoData, _tkCryptoData.GetTokenSeed(masterKey), (dataEntropy == null || dataEntropy.Length < 1) ? new byte[0] : BaseFunctions.convertStringToByteArray(dataEntropy), out supportCryptoData)) { tokenCryptoData = new TokenCryptoData(null, null, new CryptoData(), new TokenTypeBaseParams()); result = OperationResult.Error; return(result); } _tkCryptoData.ResetSupportCryptoData(supportCryptoData); } tokenCryptoData = _tkCryptoData; result = OperationResult.Success; } } catch (Exception ex) { tokenCryptoData = new TokenCryptoData(null, null, default(CryptoData), default(TokenTypeBaseParams)); SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.TokensBaseFunctions.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = OperationResult.Error; } finally { // byte[] tkseed = null; // byte[] tkserial = null; } return(result); }
public SAFConfigurationParametersMap GetAllParametersFromDB() { IDbCommand _cmd = null; IDataReader _rd = null; SAFConfigurationParametersMap cacheData = new SAFConfigurationParametersMap(); SAFConfigurationParametersMap result; try { base.ConnectionString = DBConnectionString.ExpandSAFBusinessConfiguration(); _cmd = base.CreateCommand("SAFGetConfiguration", CommandType.StoredProcedure); base.Connection.Open(); _rd = _cmd.ExecuteReader(CommandBehavior.CloseConnection); while (_rd.Read()) { SAFConfigurationParameter par = new SAFConfigurationParameter(); par.section = _rd.GetString(0); par.name = _rd.GetString(1); par.value = (_rd.IsDBNull(2) ? null : _rd.GetString(2)); par.lastUTCupdate = _rd.GetDateTime(3); par.frozen = _rd.GetBoolean(4); par.hidden = _rd.GetBoolean(5); cacheData.Add(par.section + "@" + par.name, par); } result = cacheData; } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusinessConfig.SAFConfigurationDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = null; } finally { if (_rd != null) { _rd.Dispose(); } if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return(result); }
public static IDeployToken LoadAssembly(string typeName) { IDeployToken result; if (typeName == null || typeName.Length == 0) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.WARNING, "SAFBUSINESSDEPLOY", new string[] { "http://sfexpand.SAFDeploy.DeployTokenFactory.softfinanca.com/", "[IDeployToken]::" + typeName.Trim(), "Invalid or null typename!" }); result = null; } else { try { Type _type = Type.GetType(typeName, true); if (!typeof(IDeployToken).IsAssignableFrom(_type)) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.WARNING, "SAFBUSINESSDEPLOY", new string[] { "http://sfexpand.SAFDeploy.DeployTokenFactory.softfinanca.com/", "[IDeployToken]::" + typeName.Trim(), "typename not Assignable!" }); result = null; } else { result = (IDeployToken)Activator.CreateInstance(_type, true); } } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESSDEPLOY", new string[] { "http://sfexpand.SAFDeploy.DeployTokenFactory.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = null; } } return(result); }