/// <summary> /// Gets a token based on guid if token is valie (i.e. not expired) /// </summary> /// <param name="guid">the gguis to query on</param> /// <param name="tokenModel">the token to return</param> /// <returns>a token status code</returns> internal TokenStatus TryGet(Guid guid, out TokenModel tokenModel) { TokenStatus retValue = TokenStatus.Missing; tokenModel = null; if (guid != null) { if (!memoryCache.TryGetValue <TokenModel>(guid.ToString(), out tokenModel)) { using (var db = new TokenContext(appSetings.Value.ConnectionString)) { tokenModel = db.Token.Where(b => b.Guid == guid).FirstOrDefault(); } if (tokenModel != null) { // check if token expired if (tokenModel.Expired) { retValue = TokenStatus.Expired; } else { // Since token doesnt exist in cache, Add it. memoryCache.Set <TokenModel>(tokenModel.Guid.ToString(), tokenModel, DateTimeOffset.FromUnixTimeSeconds(tokenModel.Expire)); } } } retValue = TokenStatus.Available; } return(retValue); }
public OAuthAccessToken( string token, string secret, IConsumer consumer, TokenStatus status, IRequestToken requestToken) : this() { if (string.IsNullOrEmpty(token)) { throw new ArgumentException("token must not be null or empty", "token"); } if (secret == null) { throw new ArgumentNullException("secret", "secret must not be null"); } if (consumer == null) { throw new ArgumentNullException("consumer", "consumer must not be null"); } if (requestToken == null) { throw new ArgumentNullException("requestToken", "requestToken must not be null"); } this.Token = token; this.Secret = secret; this.Status = status; this.ConsumerKey = consumer.Key; this.RequestToken = requestToken; }
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 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 async Task OnAuthorizationAsync(AuthorizationFilterContext context) { _tokensFactory = (ITokensFactory)context.HttpContext.RequestServices.GetRequiredService(typeof(ITokensFactory)); if (context.ActionDescriptor is ControllerActionDescriptor descriptor) { var attributes = descriptor.MethodInfo.CustomAttributes; if (attributes.Any(x => x.AttributeType == typeof(AllowAnonymousAttribute))) { return; } } var authHeader = (String)context.HttpContext.Request.Headers["Authorization"]; TokenStatus tokenStatus = TokenStatus.Valid; if (!string.IsNullOrEmpty(authHeader)) { var token = GetCleanToken(authHeader); tokenStatus = await ValidateToken(token); if (tokenStatus == TokenStatus.Valid) { return; } } var error = GetErrorByTokenStatus(tokenStatus); context.Result = new ObjectResult(error) { StatusCode = (int)error.HttpStatusCode, }; }
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 OAuthRequestToken( string token, string secret, IConsumer consumer, TokenStatus status, OAuthParameters associatedParameters, IIdentity authenticatedUser, string[] roles) : this() { if (string.IsNullOrEmpty(token)) throw new ArgumentException("token must not be null or empty", "token"); if (secret == null) throw new ArgumentNullException("secret", "secret must not be null"); if (consumer == null) throw new ArgumentNullException("consumer", "consumer must not be null"); if (roles == null) throw new ArgumentNullException("roles", "roles must not be null"); this.Token = token; this.Secret = secret; this.Status = status; this.ConsumerKey = consumer.Key; this.AssociatedParameters = associatedParameters; this.AuthenticatedUser = authenticatedUser; this.Roles = roles; }
public OAuthAccessToken( string token, string secret, IConsumer consumer, TokenStatus status, IRequestToken requestToken) : this() { if (string.IsNullOrEmpty(token)) throw new ArgumentException("token must not be null or empty", "token"); if (secret == null) throw new ArgumentNullException("secret", "secret must not be null"); if (consumer == null) throw new ArgumentNullException("consumer", "consumer must not be null"); if (requestToken == null) throw new ArgumentNullException("requestToken", "requestToken must not be null"); this.Token = token; this.Secret = secret; this.Status = status; this.ConsumerKey = consumer.Key; this.RequestToken = requestToken; }
private static TokenStatus ValidateToken(string token, out string username) { username = null; TokenStatus tokenStatus = TokenStatus.Failed; ClaimsPrincipal simplePrinciple = TokenManager.GetPrincipal(token, ref tokenStatus); if (tokenStatus == TokenStatus.Expired || tokenStatus == TokenStatus.Failed) { return(tokenStatus); } var identity = simplePrinciple != null ? simplePrinciple.Identity as ClaimsIdentity : null; if (identity == null) { return(TokenStatus.Failed); } if (!identity.IsAuthenticated) { return(TokenStatus.Failed); } username = identity.FindFirst(ClaimTypes.Name).Value; if (string.IsNullOrEmpty(username)) { return(TokenStatus.Failed); } // More validate to check whether username exists in system return(TokenStatus.Passed); }
/// <summary> /// Update the user token status. /// The method does the below steps: /// 1. Get the user token for the input user id or get the current user token if user id is null. /// 2. Update the user token with the token status. /// 3. Find the next user token with status as Waiting. /// 4. Set the current token number with above found user token number. /// </summary> /// <param name="tokenStatus">The token status to be updated.</param> /// <param name="userId">The user's id.</param> /// <returns>The meeting summary instance.</returns> public MeetingSummary UpdateTokenStatus(TokenStatus tokenStatus, string userId = null) { lock (SyncObj) { var userToken = (userId == null) ? this.UserTokens.Where(t => t.TokenNumber == this.MeetingMetadata.CurrentToken).FirstOrDefault() : this.UserTokens.Find((token) => token.UserInfo.AadObjectId == userId); if (userToken != null) { userToken.Status = tokenStatus; if (userToken.TokenNumber == this.MeetingMetadata.CurrentToken) { if (this.MeetingMetadata.CurrentToken < this.MeetingMetadata.MaxTokenIssued) { var iteratorToken = this.UserTokens.FirstOrDefault(tok => tok.Status.Equals(TokenStatus.Waiting)); if (iteratorToken != null) { iteratorToken.Status = TokenStatus.Current; this.MeetingMetadata.CurrentToken = iteratorToken.TokenNumber; } else { this.MeetingMetadata.CurrentToken = this.MeetingMetadata.MaxTokenIssued; } } } } return(this); } }
private void NewSerialLine(string line) { Logger.Debug($"New line on serial port: {line}"); _lastBarcode = line; switch (_tokenStatus) { case TokenStatus.Waiting: _tokenStatus = TokenStatus.Counting; _tokenWatchdog.Start(); break; case TokenStatus.Counting: _tokenWatchdog.Ping(); break; default: return; } if (_tokenStatus != TokenStatus.Counting) { return; } if (_lastBarcodeDateTime.AddSeconds(Constants.SerialBarcodeDebounceTimeout) >= DateTime.Now) { return; } _lastBarcodeDateTime = DateTime.Now; _tokenCounts++; SoundUtility.Play(SoundUtility.Sound.Ping); }
public OAuthRequestToken(string token, string secret, IConsumer consumer, TokenStatus status, OAuthParameters parameters, IIdentity user, string[] roles) { if (string.IsNullOrEmpty(token)) { throw new ArgumentException("token must not be null or empty", "token"); } if (secret == null) { throw new ArgumentNullException("secret", "secret must not be null"); } if (consumer == null) { throw new ArgumentNullException("consumer", "consumer must not be null"); } if (roles == null) { throw new ArgumentNullException("roles", "roles must not be null"); } this.token = token; this.secret = secret; this.status = status; consumerKey = consumer.Key; this.parameters = parameters; this.user = user; this.roles = roles; }
public void TokenStatusInitsWithNoArgs() { var tokenStatus = new TokenStatus(); Assert.NotNull(tokenStatus); Assert.IsType <TokenStatus>(tokenStatus); }
public void OnClick() { if (status != TokenStatus.TokenBlocked) { // TODO: change to batte scene with map_id, don't change status here status = TokenStatus.TokenCompleted; } }
/// <summary> /// Sign a user out of a given connection name previously linked to their Bot /// </summary> /// <param name="account"></param> /// <returns></returns> public async Task <IActionResult> SignOut(TokenStatus account) { var userId = GetUserId(); await this.repository.SignOutAsync(userId, CredentialProvider, account.ConnectionName); return(RedirectToAction("LinkedAccounts")); }
/// <summary> /// Retrieve a URL for the user to link a given connection name to their Bot /// </summary> /// <param name="account"></param> /// <returns></returns> public async Task <IActionResult> SignIn(TokenStatus account) { var userId = GetUserId(); string link = await repository.GetSignInLinkAsync(userId, CredentialProvider, account.ConnectionName, $"{this.Request.Scheme}://{this.Request.Host.Value}/Home/LinkedAccounts"); return(Redirect(link)); }
/// <summary> /// Updates the map status. /// </summary> /// <param name="id">Identifier.</param> /// <param name="status">Status.</param> public void UpdateMapStatus(int id, TokenStatus status) { var map = _maps [id]; if (null != map) { map._status = status; } }
public OperationResult newTokenFromPreInsertedSeed(string tokenParamsID, TokenStatus newTokenStatus, out TokenInfoCore tokenInfoCore) { IDbCommand _cmd = null; tokenInfoCore = new TokenInfoCore(); OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmd = base.CreateCommand("FreeSeedUpdateForNewToken", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param0", (byte)newTokenStatus)); _cmd.Parameters.Add(base.AddParameter("@Param1", 99)); _cmd.Parameters.Add(base.AddParameter("@Param2", tokenParamsID)); 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/newTokenFromPreInsertedSeed", 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 static TokenInfoCore loadTokenInfoCore(byte typeID, int internalID, string supplierLotID, string supplierSerialNumber, string internalSerialNumber, DateTime expirationTimeStamp, string subLotID, TokenStatus internalStatus) { return new TokenInfoCore { TypeID = typeID, InternalID = internalID, SupplierLotID = (supplierLotID == null) ? null : supplierLotID.Trim(), SupplierSerialNumber = (supplierSerialNumber == null) ? null : supplierSerialNumber.Trim(), InternalSerialNumber = (internalSerialNumber == null) ? null : internalSerialNumber.Trim(), ExpirationTimeStamp = expirationTimeStamp, InternalStatus = internalStatus, SubLotID = subLotID }; }
public bool AddError(string msg, TokenStatus stat = TokenStatus.Warning) { if (stat == TokenStatus.Error) { status = TokenStatus.Error; } else if (status != TokenStatus.Error && stat == TokenStatus.Warning) { status = TokenStatus.Warning; } rootQuery.errors.Add(msg); rootQuery.status = status; return(status == TokenStatus.Error); }
private int getTokenStatusID(TokenStatus t) { switch (t) { case TokenStatus.EMPTY: return(-1); case TokenStatus.VERIFICATION: return(1); case TokenStatus.RECOVERY: return(2); } return(-1); }
private void TokenRemoved() { _tokenStatus = TokenStatus.Parsing; _tokenWatchdog.Stop(); Logger.Info($"New Barcode command: barcode {_lastBarcode} - counts: {_tokenCounts}"); var barcode = _lastBarcode; var counts = _tokenCounts; new Thread(() => { OnNewBarcode?.Invoke(barcode, counts); }).Start(); _tokenStatus = TokenStatus.Waiting; _tokenCounts = 0; }
public void TokenStatusInits() { var channelId = "channelId"; var connectionName = "connectionName"; var hasToken = true; var serviceProviderDisplayName = "serviceProviderDisplayName"; var tokenStatus = new TokenStatus(channelId, connectionName, hasToken, serviceProviderDisplayName); Assert.NotNull(tokenStatus); Assert.IsType <TokenStatus>(tokenStatus); Assert.Equal(channelId, tokenStatus.ChannelId); Assert.Equal(connectionName, tokenStatus.ConnectionName); Assert.Equal(hasToken, tokenStatus.HasToken); Assert.Equal(serviceProviderDisplayName, tokenStatus.ServiceProviderDisplayName); }
public OperationResult CheckStatus(string tokenInternalID, out TokenStatus tokenStatus) { OperationResult result; try { string typeName = new TokensValidatorDAO().DeployAssemblyNameByTokenID(tokenInternalID); ITokens tokens = TokensFactory.LoadAssembly(typeName); result = tokens.CheckStatus(tokenInternalID, out tokenStatus); } catch (Exception) { tokenStatus = TokenStatus.Undefined; result = OperationResult.Error; } return result; }
public Token(PlayerType playerType, Transform spawnNode, Transform _tokenTransform) { tokenType = playerType; originalSpawnNode = spawnNode; originalSpawnNodeComponent = originalSpawnNode.GetComponent <SpawnNode>(); originalSpawnNodeComponent.token = this; tokenTransform = _tokenTransform; tokenTransform.SetPositionAndRotation(originalSpawnNodeComponent.GetPosition(), Quaternion.identity); tokenStatus = TokenStatus.LOCKED_IN_SPAWN; originalScale = tokenTransform.localScale; tokenComponent = tokenTransform.GetComponent <TokenComponent>(); tokenComponent.tokenInstance = this; }
public OperationResult CheckStatus(string tokenInternalID, out TokenStatus tokenStatus) { OperationResult result; try { string typeName = new TokensValidatorDAO().DeployAssemblyNameByTokenID(tokenInternalID); ITokens tokens = TokensFactory.LoadAssembly(typeName); result = tokens.CheckStatus(tokenInternalID, out tokenStatus); } catch (Exception) { tokenStatus = TokenStatus.Undefined; result = OperationResult.Error; } return(result); }
public static TokenInfo loadTokenInfo(TokenStatus status, byte typeID, int internalID, string typeDescription, string applicationUser, string phoneNumberUser, string emailAddressUser, DateTime registeredTimeStamp, string internalSerialNumber, DateTime lastStatusTimeStamp, TokenInfoCore tokenInfoCore) { TokenInfo _newTkInfoBus = new TokenInfo(); _newTkInfoBus.Status = status; _newTkInfoBus.TypeDescription = ((typeDescription == null) ? null : typeDescription.Trim()); _newTkInfoBus.ApplicationUser = ((applicationUser == null) ? null : applicationUser.Trim()); _newTkInfoBus.PhoneNumberUser = ((phoneNumberUser == null) ? null : phoneNumberUser.Trim()); _newTkInfoBus.EmailAddressUser = ((emailAddressUser == null) ? null : emailAddressUser.Trim()); _newTkInfoBus.RegisteredTimeStamp = registeredTimeStamp; _newTkInfoBus.LastStatusChangedTimeStamp = lastStatusTimeStamp; if (tokenInfoCore.InternalID == 0) { _newTkInfoBus.tokenInfoCore = TokenInfoCore.loadTokenInfoCore(typeID, internalID, null, null, internalSerialNumber, registeredTimeStamp, null, status); } else { _newTkInfoBus.tokenInfoCore = tokenInfoCore; } return _newTkInfoBus; }
protected Task <IPrincipal> AuthenticateJwtToken(string token, out TokenStatus status) { status = ValidateToken(token, out string username); if (status == TokenStatus.Passed) { // based on username to get more information from database in order to build local identity var claims = new List <Claim> { new Claim(ClaimTypes.Name, username) // Add more claims if needed: Roles, ... }; var identity = new ClaimsIdentity(claims, "Jwt"); IPrincipal user = new ClaimsPrincipal(identity); return(Task.FromResult(user)); } return(Task.FromResult <IPrincipal>(null)); }
private ErrorResponse GetErrorByTokenStatus(TokenStatus tokenStatus) { switch (tokenStatus) { case TokenStatus.Expired: return(new SecurityErrorResponse(new Error { Code = ErrorCodes.Security.AccessTokenExpired, Message = ErrorMessages.Security.AccessTokenExpired })); case TokenStatus.Invalid: return(new SecurityErrorResponse(new Error { Code = ErrorCodes.Security.AccessTokenInvalid, Message = ErrorMessages.Security.AccessTokenInvalid })); } return(new SecurityErrorResponse()); }
public static TokenInfo loadTokenInfo(TokenStatus status, byte typeID, int internalID, string typeDescription, string applicationUser, string phoneNumberUser, string emailAddressUser, DateTime registeredTimeStamp, string internalSerialNumber, DateTime lastStatusTimeStamp, TokenInfoCore tokenInfoCore) { TokenInfo _newTkInfoBus = new TokenInfo(); _newTkInfoBus.Status = status; _newTkInfoBus.TypeDescription = ((typeDescription == null) ? null : typeDescription.Trim()); _newTkInfoBus.ApplicationUser = ((applicationUser == null) ? null : applicationUser.Trim()); _newTkInfoBus.PhoneNumberUser = ((phoneNumberUser == null) ? null : phoneNumberUser.Trim()); _newTkInfoBus.EmailAddressUser = ((emailAddressUser == null) ? null : emailAddressUser.Trim()); _newTkInfoBus.RegisteredTimeStamp = registeredTimeStamp; _newTkInfoBus.LastStatusChangedTimeStamp = lastStatusTimeStamp; if (tokenInfoCore.InternalID == 0) { _newTkInfoBus.tokenInfoCore = TokenInfoCore.loadTokenInfoCore(typeID, internalID, null, null, internalSerialNumber, registeredTimeStamp, null, status); } else { _newTkInfoBus.tokenInfoCore = tokenInfoCore; } return(_newTkInfoBus); }
public static ClaimsPrincipal GetPrincipal(string token, ref TokenStatus status) { try { var tokenHandler = new JwtSecurityTokenHandler(); if (!(tokenHandler.ReadToken(token) is JwtSecurityToken jwtToken)) { return(null); } var symmetricKey = Convert.FromBase64String(SECRET_KEY); var validationParameters = new TokenValidationParameters() { RequireExpirationTime = true, ValidateIssuer = false, ValidateAudience = false, IssuerSigningKey = new SymmetricSecurityKey(symmetricKey), ClockSkew = TimeSpan.Zero }; var principal = tokenHandler.ValidateToken(token, validationParameters, out SecurityToken securityToken); status = TokenStatus.Passed; return(principal); } catch (Exception ex) { LogManager.LogDebug(ex); if (ex.Message.Contains("token is expired")) { status = TokenStatus.Expired; } return(null); } }
public OAuthRequestToken(string token, string secret, IConsumer consumer, TokenStatus status, OAuthParameters parameters, IIdentity user, string[] roles) { if (string.IsNullOrEmpty(token)) throw new ArgumentException("token must not be null or empty", "token"); if (secret == null) throw new ArgumentNullException("secret", "secret must not be null"); if (consumer == null) throw new ArgumentNullException("consumer", "consumer must not be null"); if (roles == null) throw new ArgumentNullException("roles", "roles must not be null"); this.token = token; this.secret = secret; this.status = status; consumerKey = consumer.Key; this.parameters = parameters; this.user = user; this.roles = roles; }
public OperationResult updateTokenStatus(string tokenID, TokenStatus tokenStatus) { IDbCommand dbCommand = null; OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); dbCommand = base.CreateCommand("PersistTokenStatus", CommandType.StoredProcedure); dbCommand.Parameters.Add(base.AddParameter("@Param0", (byte)tokenStatus)); dbCommand.Parameters.Add(base.AddParameter("@tkID", tokenID)); base.Connection.Open(); int num = dbCommand.ExecuteNonQuery(); result = ((num == 1) ? OperationResult.Success : OperationResult.Error); } catch (Exception ex) { LOGGER.Write(LOGGER.LogCategory.ERROR, string.Concat(new string[] { "SF.Expand.SAF.Core.TokensDAO::updateTokenStatus[", tokenID, ";", tokenStatus.ToString(), "]", Environment.NewLine, ex.ToString() }), null); result = OperationResult.Error; } finally { if (dbCommand != null) { dbCommand.Dispose(); } base.CloseConnection(); } return(result); }
public OAuthRequestToken( string token, string secret, IConsumer consumer, TokenStatus status, OAuthParameters associatedParameters, IIdentity authenticatedUser, string[] roles) : this() { if (string.IsNullOrEmpty(token)) { throw new ArgumentException("token must not be null or empty", "token"); } if (secret == null) { throw new ArgumentNullException("secret", "secret must not be null"); } if (consumer == null) { throw new ArgumentNullException("consumer", "consumer must not be null"); } if (roles == null) { throw new ArgumentNullException("roles", "roles must not be null"); } this.Token = token; this.Secret = secret; this.Status = status; this.ConsumerKey = consumer.Key; this.AssociatedParameters = associatedParameters; this.AuthenticatedUser = authenticatedUser; this.Roles = roles; }
/// <summary> /// Ověření tokenu /// </summary> /// <returns></returns> private bool VerifyToken() { this._appId = String.Empty; // Získání tokenu z hlavičky AuthToken authToken = SoapHeaderHelper <AuthToken> .GetInputHeader("AuthToken"); string token = (authToken == null ? String.Empty : authToken.Value); if (String.IsNullOrWhiteSpace(token)) { SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult() { StatusId = ActionStatus.InvalidToken.ToShort(), StatusDesc = "Invalid token" }); return(false);; } // Ověření platnosti tokenu Token tkn = new Token(Bc.SecretKey, "AuthToken", token); TokenStatus stat = tkn.Verify(); this._appId = tkn.Id; if (stat != TokenStatus.Valid) { SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult() { StatusId = ActionStatus.InvalidToken.ToShort(), StatusDesc = "Invalid token" }); return(false);; } return(true); }
public OperationResult CheckStatus(string tokenInternalID, out TokenStatus tokenStatus) { 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!" }); tokenStatus = TokenStatus.Undefined; result = OperationResult.Error; } else { result = _tokens.CheckStatus(tokenInternalID, out tokenStatus); } } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.PREProcessorTokens.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); tokenStatus = TokenStatus.Undefined; result = OperationResult.Error; } 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 void ChangeStatus(TokenStatus newStatus) { statusChanged = (status != newStatus); status = newStatus; }
public static long tokensSeedsBulkInsert(string pathFileName, TokenStatus tokenStatus, DateTime tokenExpiration) { return new TokensDAO().tokensSeedsBulkInsert(pathFileName, tokenStatus, tokenExpiration); }
public OperationResult getTokenStatus(string tokenID, string tokenUserApplicationID, out TokenStatus tokenStatus) { tokenStatus = TokenStatus.Undefined; IDbCommand _cmd = null; OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSecureBusiness(); _cmd = base.CreateCommand("GetTokenUserStatus", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param1", tokenID)); _cmd.Parameters.Add(base.AddParameter("@Param2", tokenUserApplicationID)); base.Connection.Open(); object _retVal = _cmd.ExecuteScalar(); if (_retVal == null) { tokenStatus = TokenStatus.Undefined; result = OperationResult.Success; } else { tokenStatus = (TokenStatus)((byte)_retVal); 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; }
/// <summary> /// Async Acquire Token by UserName /// </summary> /// <param name="userName"></param> /// <returns>The token status</returns> public static async Task<TokenStatus> AcquireToken(string userName) { var received = string.Empty; var tokenStatus = new TokenStatus(); User = new UserRepository { UserName = userName }; // Post data to authorize with var postData = "username="******"&appId=" + appId + "&signed=" + CreateSignedHex(); // Get User from local storage if (settings.Contains("Token")) { var token = settings["Token"].ToString(); postData += "&token=" + token; received = await Post("authorize?", postData); var jsonData = JsonConvert.DeserializeObject<dynamic>(received); if (jsonData["result"].Value == true) { // Get token from json data Token receivedToken = JsonConvert.DeserializeObject<Token>(jsonData["data"].ToString()); tokenStatus = await CheckTokenStatus(receivedToken); } else { tokenStatus = TokenStatus.ERROR; // Result is wrong, throw exception.. throw new InvalidDataException(jsonData.errorMsg.ToString()); } } else { // Get received JSON received = await Post("authorize?", postData); // Deserialize json code. var jsonData = JsonConvert.DeserializeObject<dynamic>(received); //MessageBox.Show(jsonData.result.ToString()); //if (jsonData.result == true) if (jsonData["result"].Value == true) { // Get token from json data //Token receivedToken = JsonConvert.DeserializeObject<Token>(jsonData.data.ToString()); Token receivedToken = JsonConvert.DeserializeObject<Token>(jsonData["data"].ToString()); tokenStatus = await CheckTokenStatus(receivedToken); } else { tokenStatus = TokenStatus.ERROR; // Result is wrong, throw exception.. throw new InvalidDataException(jsonData.errorMsg.ToString()); } } return tokenStatus; }
public OperationResult CheckStatus(string tokenInternalID, out TokenStatus tokenStatus) { 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!" }); tokenStatus = TokenStatus.Undefined; result = OperationResult.Error; } else { result = _tokens.CheckStatus(tokenInternalID, out tokenStatus); } } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFCORE", new string[] { "http://sfexpand.SAFCore.PREProcessorTokens.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); tokenStatus = TokenStatus.Undefined; result = OperationResult.Error; } return result; }
public TokenInfo[] loadAllTokensByStatusAndBetweenDates(TokenStatus tkStatus, string initialDate, string endDate, string firstItem, int pageSize, int pageDirection, out int totRows) { IDbCommand _cmd = null; totRows = -1; TokenInfo[] result; try { base.ConnectionString = DBConnectionString.ExpandSecureBusiness(); _cmd = base.CreateCommand("TokensGetByStatusAndBetweenDatesPAG", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param1", (int)tkStatus)); _cmd.Parameters.Add(base.AddParameter("@Param2", this._prepareUSADateFormat(initialDate, DateTime.Parse(DateTime.Now.ToShortDateString() + " 00:00:01")))); _cmd.Parameters.Add(base.AddParameter("@Param3", this._prepareUSADateFormat(endDate, DateTime.Parse(DateTime.Now.ToShortDateString() + " 23:59:59")))); this._PrepPagination(_cmd, int.Parse(firstItem), pageSize, pageDirection); result = this._loadTokensDataPAG(_cmd, out totRows); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.TokenBusinessDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = null; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return result; }
public OperationResult newTokenFromPreInsertedSeed(string tokenParamsID, TokenStatus newTokenStatus, out TokenInfoCore tokenInfoCore) { IDbCommand _cmd = null; tokenInfoCore = new TokenInfoCore(); OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSAFCore(); _cmd = base.CreateCommand("FreeSeedUpdateForNewToken", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param0", (byte)newTokenStatus)); _cmd.Parameters.Add(base.AddParameter("@Param1", 99)); _cmd.Parameters.Add(base.AddParameter("@Param2", tokenParamsID)); 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/newTokenFromPreInsertedSeed", 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 void ChangeStatus(TokenStatus newStatus) { status = newStatus; }
private OperationResult getTokenIDAndTokenIntSerial(int tokenParamsID, string tokenUserApplicationID, TokenStatus tokenStatus, out string tokenID, out string internalSerialNumber) { tokenID = null; internalSerialNumber = null; IDataReader _dr = null; IDbCommand _cmd = null; int _tRecords = 0; OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSecureBusiness(); _cmd = base.CreateCommand("GetTokensByUserAndTypeAndStatus", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param1", tokenUserApplicationID)); _cmd.Parameters.Add(base.AddParameter("@Param2", tokenParamsID)); IList arg_79_0 = _cmd.Parameters; string arg_74_1 = "@Param3"; int num = (int)tokenStatus; arg_79_0.Add(base.AddParameter(arg_74_1, num.ToString())); base.OpenConnection(); _dr = _cmd.ExecuteReader(CommandBehavior.CloseConnection); while (_dr.Read()) { _tRecords++; tokenID = _dr[0].ToString(); internalSerialNumber = _dr[8].ToString(); } if (_tRecords == 1) { result = OperationResult.Success; } else { tokenID = null; internalSerialNumber = null; result = 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 (_dr != null) { _dr.Dispose(); } if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return result; }
public OperationResult BeforeEnable(string applicationUser, string tokenID, string baseNotifyMessage, TokenStatus tokenCurrentStatus) { return OperationResult.Success; }
public TokenInfo[] loadTokensByPhoneNumber(TokenStatus tkStatus, string[] applicationUserPhoneNumber, out int totRows) { totRows = 0; IDbCommand _cmd = null; string _sBuilder = null; TokenInfo[] result; try { for (int i = 0; i < applicationUserPhoneNumber.Length; i++) { string text = _sBuilder; _sBuilder = string.Concat(new string[] { text, (_sBuilder != null) ? "," : "", "'", applicationUserPhoneNumber[i], "'" }); } base.ConnectionString = DBConnectionString.ExpandSecureBusiness(); _cmd = base.CreateCommand("GetTokensUserByPhone", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param1", (int)tkStatus)); _cmd.Parameters.Add(base.AddParameter("@Param2", _sBuilder)); result = this._loadTokensDataPAG(_cmd, out totRows); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.TokenBusinessDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = null; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return result; }
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; }
private OperationResult _updateTokenStatus(TokenStatus tokenStatus, string applicationUser, string tokenID, out long tokenEventID) { tokenEventID = -1L; IDbCommand _cmd = null; OperationResult result; try { base.ConnectionString = DBConnectionString.ExpandSecureBusiness(); _cmd = base.CreateCommand("TokenChangeStatus", CommandType.StoredProcedure); IList arg_3C_0 = _cmd.Parameters; string arg_37_1 = "@param1"; int num = (int)tokenStatus; arg_3C_0.Add(base.AddParameter(arg_37_1, num.ToString())); _cmd.Parameters.Add(base.AddParameter("@param2", applicationUser)); _cmd.Parameters.Add(base.AddParameter("@param3", tokenID)); base.Connection.Open(); base.TransactionBegin(IsolationLevel.ReadCommitted); _cmd.Transaction = base.Transaction; if (1 == _cmd.ExecuteNonQuery()) { if (OperationResult.Success == this._insertTokenEvent(tokenID, (int)tokenStatus, 0, applicationUser, out tokenEventID)) { base.TransactionCommit(); result = OperationResult.Success; return result; } } result = 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 EmptyRequestToken(string consumerKey) : base(consumerKey, TokenType.Request) { status = TokenStatus.Authorized; }
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 CheckStatus(string tokenInternalID, out TokenStatus tokenStatus) { return new TokensDAO().tokenStatus(tokenInternalID, out tokenStatus); }
public static OperationResult tokenGetStatus(int tokenVendorID, string internalSerialNumber, out TokenStatus tokenStatus) { int tkID = 0; string _tokenID = null; string _applicationUser = null; OperationResult result; if (OperationResult.Success == new TokenBusinessDAO().getTokenIDByVendorIDAndIntSerial(tokenVendorID, internalSerialNumber, out _applicationUser, out _tokenID)) { if (int.TryParse(_tokenID, out tkID)) { result = SAFBaseFunctions.tokenGetStatus(_applicationUser, tkID, out tokenStatus); return result; } } tokenStatus = TokenStatus.Undefined; result = OperationResult.Error; 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 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 tokenGetStatus(string applicationUser, int tokenID, out TokenStatus tokenStatus) { OperationResult result; try { if (!SAFBaseFunctions._checkStatusConsistency(tokenID.ToString(), applicationUser, out tokenStatus)) { result = OperationResult.WrongStatusForRequestedOperation; } else { tokenStatus = TokenStatus.Undefined; result = OperationResult.Error; } } catch (Exception ex) { SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); tokenStatus = TokenStatus.Undefined; result = OperationResult.Error; } return result; }
private static bool _checkStatusConsistency(string tokenID, string applicationUser, out TokenStatus _tokenStatusCore) { _tokenStatusCore = TokenStatus.Undefined; string __mapError = null; bool result; try { if (OperationResult.Error == new PREProcessorTokens().CheckStatus(tokenID, out _tokenStatusCore)) { __mapError = string.Concat(new string[] { "Error loading token info.core::[", applicationUser, "/", tokenID.ToString(), " ]" }); SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.ERROR, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", __mapError }); result = false; } else { TokenStatus _tokenStatusBusiness; if (OperationResult.Error == new TokenBusinessDAO().getTokenStatus(tokenID, applicationUser, out _tokenStatusBusiness)) { __mapError = string.Concat(new string[] { "Error loading token info.business::[", applicationUser, "/", tokenID.ToString(), "]" }); SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.ERROR, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", __mapError }); result = false; } else { if (_tokenStatusCore != _tokenStatusBusiness) { __mapError = string.Concat(new string[] { "Token inconsistency detected::[", applicationUser, "/", tokenID.ToString(), "][core:", _tokenStatusCore.ToString(), "][business:", _tokenStatusBusiness.ToString(), "]" }); SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.WARNING, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", __mapError }); result = false; } else { result = true; } } } } catch (Exception ex) { __mapError = "Exception :: UserToken ::[" + applicationUser + "]"; SAFBaseFunctions._logger(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.DBConnectionString.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), __mapError, ex.ToString() }); _tokenStatusCore = TokenStatus.Undefined; result = false; } finally { if (null != __mapError) { SAFInternalEvents.Export(APPEVENTSDeff.OPERATIONS_EXECUTED, 9999, "SAFBUSINESS", new string[] { "_checkStatusConsistency", __mapError }); } } return result; }
public EmptyAccessToken(string consumerKey) : base(consumerKey, TokenType.Access) { requestToken = new EmptyRequestToken(consumerKey); status = TokenStatus.Authorized; }
private TokenInfo[] loadTokensUserByStatus(string tokenUserApplicationID, TokenStatus tokenStatus, string firstItem, int pageSize, int pageDirection, out int totRows) { totRows = -1; IDbCommand _cmd = null; TokenInfo[] result; try { base.ConnectionString = DBConnectionString.ExpandSecureBusiness(); _cmd = base.CreateCommand("GetTokensByUserAndStatusPAG", CommandType.StoredProcedure); _cmd.Parameters.Add(base.AddParameter("@Param1", tokenUserApplicationID)); IList arg_53_0 = _cmd.Parameters; string arg_4E_1 = "@param2"; int num = (int)tokenStatus; arg_53_0.Add(base.AddParameter(arg_4E_1, num.ToString())); this._PrepPagination(_cmd, int.Parse(firstItem), pageSize, pageDirection); result = this._loadTokensDataPAG(_cmd, out totRows); } catch (Exception ex) { SAFLOGGER.Write(SAFLOGGER.LOGGEREventID.EXCEPTION, "SAFBUSINESS", new string[] { "http://sfexpand.SAFBusiness.TokenBusinessDAO.softfinanca.com/", Assembly.GetExecutingAssembly().FullName.ToString(), ex.ToString() }); result = null; } finally { if (_cmd != null) { _cmd.Dispose(); } base.CloseConnection(); } return result; }
public static OperationResult tokenGetStatus(string applicationUser, string SupplierSerialNumber, out TokenStatus tokenStatus) { int tkID = 0; int _tokenParamsID = 0; string _tokenID = null; OperationResult result; if (OperationResult.Success == new TokenBusinessDAO().getTokenIDByUserAndSupplierSN(applicationUser, SupplierSerialNumber, out _tokenParamsID, out _tokenID)) { if (int.TryParse(_tokenID, out tkID)) { result = SAFBaseFunctions.tokenGetStatus(applicationUser, tkID, out tokenStatus); return result; } } tokenStatus = TokenStatus.Undefined; result = OperationResult.Error; return result; }