public OperationResult AfterCreate(string applicationUser, string applicationUseruserPhone, string applicationEmail, string tokenVendorID, string expirationDate, string supplierSerialNumber, string creationLotID, string pin, string baseNotifyMessage, int tokenInternalID, long businessEventID, TokenStatus tokenStatus) { TokenInfo tokenInfo = new TokenInfo(); OperationResult operationResult = OperationResult.Error; TokenInfo[] array = new TokenBusinessDAO().loadTokenUserByType(applicationUser, tokenVendorID); OperationResult result; if (array == null) { result = OperationResult.PostValidationRulesFail; } else { for (int i = 0; i < array.Length; i++) { if (tokenInternalID == array[i].tokenInfoCore.InternalID) { tokenInfo = array[i]; operationResult = OperationResult.Success; } else { switch (array[i].tokenInfoCore.TypeID) { case 1: if (array[i].Status == TokenStatus.Enabled) { operationResult = SAFBaseFunctions.tokenDisable(array[i].ApplicationUser, array[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; case 2: if (array[i].Status == TokenStatus.Enabled || array[i].Status == TokenStatus.Disabled) { operationResult = SAFBaseFunctions.tokenCancel(array[i].ApplicationUser, array[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; case 3: if (array[i].Status == TokenStatus.Enabled || array[i].Status == TokenStatus.Disabled) { operationResult = SAFBaseFunctions.tokenCancel(array[i].ApplicationUser, array[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; } } } if (operationResult != OperationResult.Success) { result = operationResult; } else { string text = SAFConfiguration.readParameterExternal((tokenStatus == TokenStatus.ReadyToDeploy) ? "OP.SMS.NOTIFY.ON.CREATE.DEPLOY" : "OP.SMS.NOTIFY.ON.CREATE"); text = ((text.Trim().Length < 1) ? null : text.Trim()); string smsMessage; if (0 >= (text ?? "").IndexOf("[0]")) { smsMessage = (((baseNotifyMessage ?? "").Length > 1) ? baseNotifyMessage : text).Replace("{dt}", DateTime.Now.ToShortDateString()).Replace("{tm}", DateTime.Now.ToShortTimeString()).Replace("{dpl}", businessEventID.ToString().Trim()); } else { smsMessage = ((text != null) ? string.Format(text, baseNotifyMessage.Split(new char[] { '|' })) : string.Join("", baseNotifyMessage.Split(new char[] { '|' })).Trim()); } result = SMSSender.Send(tokenInfo.ApplicationUser, tokenInfo.tokenInfoCore.InternalID.ToString(), tokenInfo.PhoneNumberUser, smsMessage); } } return result; }
public static OperationResult tokenStartServerAuthentication(string applicationUser, string dataEntropy, int tokenVendorID, string baseNotifyMessage, out string requestedPassword, out bool possuiToken, out bool possuiTokenActivo) { possuiToken = false; possuiTokenActivo = false; requestedPassword = null; string _tokenID = null; string _internalSerialNumber = null; OperationResult _hResult; OperationResult result; if (OperationResult.Success == (_hResult = new TokenBusinessDAO().getUserActiveTokenByVendorID(tokenVendorID, applicationUser, out _tokenID, out _internalSerialNumber))) { possuiToken = true; possuiTokenActivo = true; result = SAFBaseFunctions.tokenStartServerAuthentication(applicationUser, _tokenID, dataEntropy, baseNotifyMessage, out requestedPassword); } else { if (_hResult == OperationResult.WrongStatusForRequestedOperation) { possuiToken = true; } result = OperationResult.Error; } return result; }
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 OperationResult tokenCreate(string applicationUser, string applicationUseruserPhone, string applicationEmail, string tokenVendorID, string expirationDate, string supplierSerialNumber, string creationLotID, string pin, string baseNotifyMessage, out TokenInfo tokenInfo) { long tokenEventID = 0L; OperationResult _hResult = OperationResult.Error; ITokenRules _TKRules = TokenRulesFactory.LoadAssembly(SAFConfiguration.readParameterExternal("SAFClientBusinessRules")); DateTime _dtExpiration; if (!DateTime.TryParse(expirationDate, out _dtExpiration)) { _dtExpiration = DateTime.MaxValue; } OperationResult result; try { if (_TKRules != null) { if (OperationResult.Success != (_hResult = _TKRules.BeforeCreate(applicationUser, applicationUseruserPhone, applicationEmail, tokenVendorID, expirationDate, supplierSerialNumber, creationLotID, pin, baseNotifyMessage))) { new TokensBusinessEventsDAO().insertTokenEvent("0", 100, (int)_hResult, applicationUser, out tokenEventID); tokenInfo = new TokenInfo(); result = _hResult; return result; } } TokenInfoCore _tkInfoCore; if (OperationResult.Success == (_hResult = new PREProcessorTokens().Create(tokenVendorID, _dtExpiration, supplierSerialNumber, creationLotID, pin, out _tkInfoCore))) { if (OperationResult.Success != (_hResult = new TokenBusinessDAO().insertTokenUser(_tkInfoCore, applicationUser, applicationUseruserPhone, applicationEmail, out tokenInfo, out tokenEventID))) { SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.ERROR, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), "unable to create token on [business] DB" }); if (OperationResult.Success != (_hResult = new PREProcessorTokens().UndoCreate(_tkInfoCore.InternalID.ToString()))) { SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.WARNING, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", "unable to undoCreate token on [core] DB" }); } } else { if (_TKRules != null) { result = _TKRules.AfterCreate(applicationUser, applicationUseruserPhone, applicationEmail, tokenVendorID, expirationDate, supplierSerialNumber, creationLotID, pin, baseNotifyMessage + "|" + tokenEventID.ToString(), _tkInfoCore.InternalID, tokenEventID, _tkInfoCore.InternalStatus); return result; } _hResult = OperationResult.Success; result = _hResult; return result; } } else { SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.ERROR, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), "unable to create token on [core] DB" }); } new TokensBusinessEventsDAO().insertTokenEvent("0", 100, (int)_hResult, applicationUser, out tokenEventID); tokenInfo = new TokenInfo(); _hResult = (result = OperationResult.Error); } catch (Exception ex) { SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), "unable to create token!", ex.ToString() }); tokenInfo = new TokenInfo(); _hResult = (result = OperationResult.Error); } finally { APPEVENTSDeff arg_294_0 = APPEVENTSDeff.OPERATIONS_EXECUTED; int arg_294_1 = 100; string arg_294_2 = "SAFBUSINESS"; string[] array = new string[2]; array[0] = TokenEventOperation.cTOKEN_CREATED.ToString(); string[] arg_291_0 = array; int arg_291_1 = 1; int num = (int)_hResult; arg_291_0[arg_291_1] = num.ToString(); SAFInternalEvents.Export(arg_294_0, arg_294_1, arg_294_2, array); } return result; }
public static OperationResult tokenEnable(string applicationUser, string tokenID, string baseNotifyMessage) { long tokenEventID = 0L; OperationResult _hResult = OperationResult.Error; ITokenRules _TKRules = TokenRulesFactory.LoadAssembly(SAFConfiguration.readParameterExternal("SAFClientBusinessRules")); OperationResult result; try { TokenStatus _oldCoreStatus; if (!SAFBaseFunctions._checkStatusConsistency(tokenID, applicationUser, out _oldCoreStatus)) { new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 1, 83, applicationUser, out tokenEventID); _hResult = (result = OperationResult.WrongStatusForRequestedOperation); } else { if (_oldCoreStatus == TokenStatus.Canceled) { new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 1, 83, applicationUser, out tokenEventID); _hResult = (result = OperationResult.WrongStatusForRequestedOperation); } else { if (_TKRules != null) { if (OperationResult.Success != (_hResult = _TKRules.BeforeEnable(applicationUser, tokenID, baseNotifyMessage, _oldCoreStatus))) { new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 1, (int)_hResult, applicationUser, out tokenEventID); result = _hResult; return result; } } if (OperationResult.Success == (_hResult = new PREProcessorTokens().AllowedUse(tokenID))) { if (OperationResult.Success == (_hResult = new TokenBusinessDAO().tokenAllowedUse(applicationUser, tokenID, out tokenEventID))) { if (_TKRules != null) { result = _TKRules.AfterEnable(applicationUser, tokenID, baseNotifyMessage); return result; } _hResult = (result = OperationResult.Success); return result; } else { if (_oldCoreStatus == TokenStatus.Enabled) { new PREProcessorTokens().InhibitedUse(tokenID); } if (_oldCoreStatus == TokenStatus.Disabled) { new PREProcessorTokens().AllowedUse(tokenID); } } } SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.ERROR, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), "unable to enable token::[" + applicationUser + "]" }); new TokensBusinessEventsDAO().insertTokenEvent(tokenID, 1, -1, applicationUser, out tokenEventID); _hResult = (result = OperationResult.Error); } } } catch (Exception ex) { SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), "unable to enable token::[" + applicationUser + "]", ex.ToString() }); _hResult = (result = OperationResult.Error); } finally { APPEVENTSDeff arg_225_0 = APPEVENTSDeff.OPERATIONS_EXECUTED; int arg_225_1 = 1; string arg_225_2 = "SAFBUSINESS"; string[] array = new string[2]; array[0] = TokenEventOperation.cTOKEN_ENABLE.ToString(); string[] arg_222_0 = array; int arg_222_1 = 1; int num = (int)_hResult; arg_222_0[arg_222_1] = num.ToString(); SAFInternalEvents.Export(arg_225_0, arg_225_1, arg_225_2, array); } return result; }
public OperationResult AfterCreate(string applicationUser, string applicationUseruserPhone, string applicationEmail, string tokenVendorID, string expirationDate, string supplierSerialNumber, string creationLotID, string pin, string baseNotifyMessage, int tokenInternalID, long businessEventID, TokenStatus tokenStatus) { TokenInfo _lastInsertedToken = new TokenInfo(); OperationResult _hResult = OperationResult.Error; TokenInfo[] _tkInfo = new TokenBusinessDAO().loadTokenUserByType(applicationUser, tokenVendorID); OperationResult result; if (_tkInfo == null) { result = OperationResult.PostValidationRulesFail; } else { for (int i = 0; i < _tkInfo.Length; i++) { if (tokenInternalID == _tkInfo[i].tokenInfoCore.InternalID) { _lastInsertedToken = _tkInfo[i]; _hResult = OperationResult.Success; } else { switch (_tkInfo[i].tokenInfoCore.TypeID) { case 1: if (_tkInfo[i].Status == TokenStatus.Enabled) { _hResult = SAFBaseFunctions.tokenDisable(_tkInfo[i].ApplicationUser, _tkInfo[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; case 2: if (_tkInfo[i].Status == TokenStatus.Enabled || _tkInfo[i].Status == TokenStatus.Disabled || _tkInfo[i].Status == TokenStatus.ReadyToDeploy || _tkInfo[i].Status == TokenStatus.DeployCompleted) { _hResult = SAFBaseFunctions.tokenCancel(_tkInfo[i].ApplicationUser, _tkInfo[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; case 3: if (_tkInfo[i].Status == TokenStatus.Enabled || _tkInfo[i].Status == TokenStatus.Disabled) { _hResult = SAFBaseFunctions.tokenCancel(_tkInfo[i].ApplicationUser, _tkInfo[i].tokenInfoCore.InternalID.ToString(), string.Empty); } break; } } } if (_hResult != OperationResult.Success) { result = _hResult; } else { string[] _arrayNotifMsg = (baseNotifyMessage ?? "").Split(new char[] { '|' }); string[] _params = new string[_arrayNotifMsg.Length - 1]; Array.Copy(_arrayNotifMsg, 1, _params, 0, _params.Length); string notifMsg = ((_arrayNotifMsg[0] ?? "").Length > 1) ? _arrayNotifMsg[0] : SAFConfiguration.readParameterExternal((tokenStatus == TokenStatus.ReadyToDeploy) ? "SMS.TEMPLATE.ON.CREATE.DEPLOY" : "SMS.TEMPLATE.ON.CREATE"); notifMsg = string.Format(notifMsg.Replace("{tm}", DateTime.Now.ToShortDateString()).Replace("{dt}", DateTime.Now.ToShortTimeString()), _params); result = SMSSender.Send(_lastInsertedToken.ApplicationUser, _lastInsertedToken.tokenInfoCore.InternalID.ToString(), _lastInsertedToken.PhoneNumberUser, notifMsg); } } return result; }