public ServiceResponse <string> GetUserNameFromAuthToken(string auth) { return(AuthResultWrapper(auth, () => { var TR = SecurityService.GetUserNameFromAuthToken(auth); if (TR == null) { ExecMsgScope.RaiseMsg(ExecMsgSeverity.Error, SysMsgCode.AuthTokenNotValid); } return TR; })); }
public ServiceResponse <string> LoginByAuthToken(string auth, int ttlSeconds) { return(AuthResultWrapper(auth, () => { var TR = SecurityService.LoginByAuthToken(auth, (ttlSeconds <= 0) ? TimeSpan.Zero : TimeSpan.FromSeconds(ttlSeconds)); if (TR == null) { ExecMsgScope.RaiseMsg(ExecMsgSeverity.Error, SysMsgCode.InvalidLogin); } return TR.ToString(); })); }
public ServiceResponse <string> LoginByUsernamePassword(string username, string password, int ttlSeconds) { return(ResultWrapper(() => { //UserBase UB = new UserBaseService().LoginByUserNamePassword(username, password); //if ( UB == null ) // ExecMsgScope.RaiseMsg(ExecMsgSeverity.Error, SysMsgCode.InvalidLogin); var TR = SecurityService.LoginByUserNamePassword(username, password, (ttlSeconds <= 0) ? TimeSpan.Zero : TimeSpan.FromSeconds(ttlSeconds)); if (TR == null) { ExecMsgScope.RaiseMsg(ExecMsgSeverity.Error, SysMsgCode.InvalidLogin); } return TR.ToString(); })); }
public static void AuthWrapper(string auth, Action toExecute) { var Token = SecurityService.CheckAuthToken(auth); if (Token == null) { ExecMsgScope.RaiseMsg(ExecMsgSeverity.Error, SysMsgCode.AuthTokenNotValid); } // Throw this token info into the context so logging can include it if needed. // Using the item [] instead of Add() method will replace an existing item in the Dictionary, where // the Add method throws an exception if there is already an item with the same name in the Dictionary. EXSLogger.ExtraEnvironmentInfo["UserName"] = Token.UserName; EXSLogger.ExtraEnvironmentInfo["ExpDateUTC"] = Token.ExpiresUTC; Token.ExecuteAsUser(toExecute); }
//public string FormatDataToXml(DataSet ds) //{ // string Xml = ""; // if ( ds.Tables.Count > 0 ) // if ( ds.Tables[0].Rows.Count > 0 ) // Xml = ds.GetXml(); // return Xml; //} #endregion #region RaiseEXSMessages /// <summary> /// Converts the ExecutionMessageCollection into ExecMsg objects, then uses /// ExecMsgScope.RaiseMsg to raise the messages. /// </summary> /// <param name="msgs">List of EXS Messages.</param> protected void RaiseEXSMessages(ExecutionMessageCollection msgs) { var Errors = LogEXSMessages(msgs); ExecMsgScope.RaiseMsg(Errors); }