public static bool InsertEncrptedToken(CHECK_WEBTOKEN webToken) { try { return SmartCardDL.InsertEncrptedToken(webToken); } catch (Exception ex) { throw ex; } }
public static bool CheckInsertedTokenStatus(string token) { try { var webToken = new CHECK_WEBTOKEN(); string hashedToken = PasswordHash.MD5Hash(token); using (var context = new PrinterMonitorDBEntities()) { webToken = context.CHECK_WEBTOKEN .Where(t => t.HashedToken.Equals(hashedToken)) .FirstOrDefault(); } if (webToken.Status == 0) return false; else return true; } catch (Exception ex) { throw ex; } }
public static bool InsertToken(string token, string username, string smartCardID) { try { var webToken = new CHECK_WEBTOKEN(); webToken.DateOfrequest = System.DateTime.Now; webToken.Token = token; webToken.HashedToken = PasswordHash.MD5Hash(token); webToken.Username = username; webToken.SmartCardID = Crypter.Encrypt(System.Configuration.ConfigurationManager.AppSettings.Get("ekey"), smartCardID); webToken.HashedSmartCardID = PasswordHash.MD5Hash(smartCardID); webToken.Status = 0; using (var context = new PrinterMonitorDBEntities()) { // Saves the token context.CHECK_WEBTOKEN.Add(webToken); context.SaveChanges(); } return true; } catch (Exception ex) { throw ex; } }
public static bool InsertEncrptedToken(CHECK_WEBTOKEN webToken) { try { CHECK_WEBTOKEN token; using (var context = new PrinterMonitorDBEntities()) { // Query for the token token = context.CHECK_WEBTOKEN .Where(t => t.id == webToken.id) .FirstOrDefault(); } //Insert the Encrypted Token against the Token supplied and Update Status to 1 if (token != null) { token.EncyptedToken = Crypter.Encrypt(System.Configuration.ConfigurationManager.AppSettings.Get("ekey"), webToken.Token); token.Status = 1; } using (var context = new PrinterMonitorDBEntities()) { context.Entry(token).State = EntityState.Modified; context.SaveChanges(); } return true; } catch (Exception ex) { throw ex; } }
public Response InsertEncryptedToken(CHECK_WEBTOKEN webToken) { Response response = new Response(); try { if (SmartCardPL.InsertEncrptedToken(webToken)) { response.ErrMessage = string.Empty; response.Successful = true; } else { response.ErrMessage = "InsertEncryptedToken operation was not successful."; response.Successful = false; } return response; } catch (Exception ex) { response.ErrMessage = ex.Message; response.Successful = false; ErrorHandler.WriteError(ex); return response; } }