/// <summary> /// Retrieve the user name from the given auth token. /// </summary> /// <remarks> /// Extract the User's Name from a valid auth token. If the auth token has expired or /// can't be decrypted for some reason, then NULL is returned. /// </remarks> /// <param name="auth">The authentication token to exract the user name from.</param> public static string GetUserNameFromAuthToken(string auth) { // If this has expired, this operation will return NULL. UserAuthToken CurrentToken = null; try { CurrentToken = UserAuthToken.FromAuthTokenKey(auth); } catch (Exception ex) { ex.Log(); } return((CurrentToken != null) ? CurrentToken.UserName : null); }
public static UserAuthToken LoginByAuthToken(string auth, TimeSpan ttl) { // If this has expired, this operation will return NULL. UserAuthToken CurrentToken = null; try { CurrentToken = UserAuthToken.FromAuthTokenKey(auth); } catch (Exception ex) { ex.Log(); } if (CurrentToken != null) { return(LoginUsingAD(CurrentToken.UserName, CurrentToken.Password, ttl)); } return(null); }
public static string GetUserName(string auth) { // If this has expired, this operation will return "". UserAuthToken CurrentToken = null; try { CurrentToken = UserAuthToken.FromAuthTokenKey(auth); } catch (Exception ex) { ex.Log(); } if (CurrentToken != null) { // Else we're going to use Windows Domain Auth. return(CurrentToken.UserName); } return(""); }
public static UserAuthToken CheckAuthToken(string auth) { const string LOG_TITLE = "CheckAuthToken"; UserAuthToken TR = null; try { TR = UserAuthToken.FromAuthTokenKey(auth); } catch (Exception ex) { ex.Log(LogSeverity.Warning); } if (TR != null) { // Else we're going to use Windows Domain Auth. if (LoginUsingAD(TR.UserName, TR.Password, TimeSpan.Zero) != null) { var AI = EXSLogger.CreateAdditionalItemList("UserName", TR.UserName); AI["ExpDateUTC"] = TR.ExpiresUTC.ToString(); EXSLogger.Log("Auth Token Valid", LOG_TITLE, LogSeverity.Verbose, AI); return(TR); } } EXSLogger.Log("Auth Token is invalid", LOG_TITLE, LogSeverity.Warning); return(null); }