public RBACContext(SerializedAccessToken executingUser, SerializedAccessToken impersonatedUser, IList <RoleType> roleTypeFilter, List <RoleEntry> sortedRoleEntryFilter, IList <RoleType> logonUserRequiredRoleTypes, bool callerCheckedAccess) : this(impersonatedUser, roleTypeFilter, sortedRoleEntryFilter, logonUserRequiredRoleTypes, callerCheckedAccess) { if (executingUser == null) { throw new ArgumentNullException("executingUser"); } this.serializedExecutingUser = executingUser.ToString(); this.ExecutingUserName = executingUser.LogonName; this.AuthenticationType = executingUser.AuthenticationType; this.contextType = RBACContext.RBACContextType.Windows; }
public static string GetSerializedAccessTokenString(this HttpContext httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } string result = null; try { IIdentity callerIdentity = httpContext.GetCallerIdentity(); using (ClientSecurityContext clientSecurityContext = callerIdentity.CreateClientSecurityContext(true)) { SerializedAccessToken serializedAccessToken = new SerializedAccessToken(callerIdentity.GetSafeName(true), callerIdentity.AuthenticationType, clientSecurityContext); result = serializedAccessToken.ToString(); } } catch (AuthzException ex) { throw new HttpException(401, ex.Message); } return(result); }