/// <summary> /// constructor /// </summary> /// <param name="AIdentity"></param> /// <param name="AGroups"></param> /// <param name="AModuleAccess"></param> /// <param name="AFunctions"></param> /// <param name="ARoles"></param> public TPetraPrincipal(System.Security.Principal.IIdentity AIdentity, SUserGroupTable AGroups, String[] AModuleAccess, String[] AFunctions, String[] ARoles) : this(AIdentity, AGroups, null, AModuleAccess, AFunctions, ARoles) { }
public static string GetClaimValue(this IIdentity identity, string type) { var claimsIdentity = identity as ClaimsIdentity; var claim = claimsIdentity?.FindAll(type).FirstOrDefault(); return(claim?.Value); }
public RtUser(string userID, string password) { // // TODO: 在此处添加构造函数逻辑 // identity = new RtIdentity(userID,password); if(identity.IsAuthenticated) { //如果通过验证则获取该用户的Role,这里可以修改为从数据库中 //读取指定用户的Role并将其添加到Role中,本例中直接为用户添加一个Admin角色 //roleList = new ArrayList(); //roleList.Add("Admin"); RTSafe.RTDP.Permission.Models.User rtUser = new RTSafe.RTDP.Permission.Models.User(); rtUser.UserId = Guid.NewGuid(); rtUser.Name = userID; RTSafe.RTDP.Permission.Models.Role role = new RTSafe.RTDP.Permission.Models.Role(); RTSafe.RTDP.Permission.Models.Operation operation= new RTSafe.RTDP.Permission.Models.Operation(); operation.OperationId = Guid.Parse("{6396B227-ACD8-475A-9865-F38FD6A19556}"); //role.Operations.Add(operation); roleList.Add(role); } else { // do nothing } }
/// <summary> /// If a user is authenticated then return the username /// </summary> /// <returns>Username of Authenticated User or Unknown if there is not Authenticated User</returns> public override string ToString() { if (HttpContext.Current != null && HttpContext.Current.User != null) { if (HttpContext.Current.User.Identity.IsAuthenticated) { UserName = HttpContext.Current.User.Identity.Name; } } //This can be cached because the User attached to the current thread //should not change for the life of the thread if (UserName == String.Empty) { System.Security.Principal.IIdentity CurrentUser = null; if (_CurrentContext != null) { //Use CurrentContext if available CurrentUser = _CurrentContext.PrimaryIdentity as System.Security.Principal.IIdentity; } if (CurrentUser != null && CurrentUser.IsAuthenticated) { UserName = CurrentUser.Name; } else if (WindowsIdentity.GetCurrent() != null && WindowsIdentity.GetCurrent().IsAuthenticated) { UserName = WindowsIdentity.GetCurrent().Name.ToString(); } else { UserName = "******"; } } return(UserName); }
public static UserPrincipal GeneratePrincipal( System.Security.Principal.IIdentity identity, string[] roles, UserInfo user) { var result = new UserPrincipal(identity, roles); result.UserData = user; return(result); }
public void GetUserInfo(IRSRequestContext requestContext, out System.Security.Principal.IIdentity userIdentity, out IntPtr userId) { //throw new NotImplementedException(); userIdentity = null; if (requestContext.User != null) { userIdentity = requestContext.User; } // initialize a pointer to the current user id to zero userId = IntPtr.Zero; }
public static string GetClaimValue(this IIdentity identity, string type) { var claimsIdentity = identity as ClaimsIdentity; if (claimsIdentity == null) { return(null); } var claim = claimsIdentity.FindAll(type).FirstOrDefault(); if (claim == null) { return(null); } return(claim.Value); }
public MyPrincipal(string userID, string password) { // // TODO: 在此处添加构造函数逻辑 // identity = new MyIdentity(userID, password); if (identity.IsAuthenticated) { //如果通过验证则获取该用户的Role,这里可以修改为从数据库中 //读取指定用户的Role并将其添加到Role中,本例中直接为用户添加一个Admin角色 roleList = new ArrayList(); roleList.Add(identity.AuthenticationType); } else { // do nothing } }
public static bool ValidateSecurityStamp(this System.Security.Principal.IIdentity identity, string stamp) { if (identity.IsAuthenticated) { var store = new UserStore <ApplicationUser>(new ApplicationDbContext()); var userManager = new ApplicationUserManager(store); var user = userManager.FindById(identity.GetUserId()); if (user != null) { if (user.SecurityStamp == stamp) { return(true); } } return(false); } else { return(false); } }
public void GetUserInfo(out System.Security.Principal.IIdentity userIdentity, out IntPtr userId) { // If the current user identity is not null, // set the userIdentity parameter to that of the current user if (HttpContext.Current != null && HttpContext.Current.User != null) { userIdentity = HttpContext.Current.User.Identity; } else // The current user identity is null. This happens when the user attempts an anonymous logon. // Although it is ok to return userIdentity as a null reference, it is best to throw an appropriate // exception for debugging purposes. // To configure for anonymous logon, return a Gener { //System.Diagnostics.Debug.Assert(false, "Warning: userIdentity is null! Modify your code if you wish to support anonymous logon."); throw new NullReferenceException("Anonymous logon is not configured. userIdentity should not be null!"); } // initialize a pointer to the current user id to zero userId = IntPtr.Zero; }
/// <summary> /// constructor /// </summary> /// <param name="AIdentity"></param> /// <param name="AGroups"></param> /// <param name="AUserTableAccessPermissions"></param> /// <param name="AModuleAccess"></param> /// <param name="AFunctions"></param> /// <param name="ARoles"></param> public TPetraPrincipal(System.Security.Principal.IIdentity AIdentity, SUserGroupTable AGroups, SUserTableAccessPermissionTable AUserTableAccessPermissions, String[] AModuleAccess, String[] AFunctions, String[] ARoles) : base() { if (AIdentity == null) { throw new ArgumentNullException("AIdentity", "Argument must not be null"); } FIdentity = AIdentity; FGroupsDT = AGroups; FUserTableAccessPermissionDT = AUserTableAccessPermissions; FModuleAccess = AModuleAccess; FFunctions = AFunctions; FRoles = ARoles; // Prepare Arrays for fast BinarySearch if (FModuleAccess != null) { System.Array.Sort(FModuleAccess); } if (FRoles != null) { System.Array.Sort(FRoles); } if (FFunctions != null) { System.Array.Sort(FFunctions); } // Default LoginMessage is not defined FLoginMessage = null; }
/// <summary> /// Initializes a new instance of the <see cref="AuthPrincipal"/> class. /// </summary> /// <param name="account">The account.</param> public AuthPrincipal(SessionIdentity account) { Identity = account; m_identity = new GenericIdentity(account.SessionDisplay); }
public UserPrincipal(System.Security.Principal.IIdentity identity, string[] roles) : base(identity, roles) { }
public FakeUser(System.Security.Principal.IIdentity ident) { _ident = ident; }
/// <summary> /// constructor /// </summary> /// <param name="AIdentity"></param> /// <param name="AGroups"></param> /// <param name="AUserTableAccessPermissions"></param> /// <param name="AModuleAccess"></param> public TPetraPrincipal(System.Security.Principal.IIdentity AIdentity, SUserGroupTable AGroups, SUserTableAccessPermissionTable AUserTableAccessPermissions, String[] AModuleAccess) : this(AIdentity, AGroups, AUserTableAccessPermissions, AModuleAccess, null, null) { }
/// <summary> /// constructor /// </summary> /// <param name="AIdentity"></param> /// <param name="AGroups"></param> public TPetraPrincipal(System.Security.Principal.IIdentity AIdentity, SUserGroupTable AGroups) : this(AIdentity, AGroups, null, null, null, null) { }
public static void AddEvent(EventDbContext dbEvents, EventTypeDbContext dbEventTypes, string eventTypeCode, string dns, string ip, System.Security.Principal.IIdentity identity) { // Add event /*Event evt = new Event(); * evt.EventID = Guid.NewGuid(); * evt.EventTypeID = dbEventTypes.EventTypes.Where(et => et.Code.Equals(eventTypeCode)).First().EventTypeID; * evt.Description = "DNS: " + dns + "; IP: " + ip; * evt.DateCreated = DateTime.Now; * if (!identity.IsAuthenticated) * evt.UserCreatedID = null; * else * evt.UserCreatedID = new Guid(identity.GetUserId()); * dbEvents.Events.Add(evt); * dbEvents.SaveChanges();*/ }
public LangdiUserPrincipal(FormsAuthenticationTicket ticket, string[] roles) { identity = new FormsIdentity(ticket); this.roles = roles; }
public Principal(string name) { Identity = new secPrincipal.GenericIdentity(name); }
public void SaveIdentity(System.Security.Principal.IIdentity identity, IToken token) { throw new NotImplementedException(); }
public UserContextualComponentMap(System.Security.Principal.IIdentity identity) { Identity = identity; }
/// <summary> /// constructor /// </summary> /// <param name="AIdentity"></param> /// <param name="AGroups"></param> /// <param name="AUserTableAccessPermissions"></param> /// <param name="AModuleAccess"></param> /// <param name="AFunctions"></param> /// <param name="ARoles"></param> public TPetraPrincipal(System.Security.Principal.IIdentity AIdentity, SUserGroupTable AGroups, SUserTableAccessPermissionTable AUserTableAccessPermissions, String[] AModuleAccess, String[] AFunctions, String[] ARoles) : base() { if (AIdentity == null) { throw new ArgumentNullException("AIdentity", "Argument must not be null"); } FIdentity = AIdentity; FGroupsDT = AGroups; FUserTableAccessPermissionDT = AUserTableAccessPermissions; FModuleAccess = AModuleAccess; FFunctions = AFunctions; FRoles = ARoles; // Prepare Arrays for fast BinarySearch if (FModuleAccess != null) { System.Array.Sort(FModuleAccess); } if (FRoles != null) { System.Array.Sort(FRoles); } if (FFunctions != null) { System.Array.Sort(FFunctions); } // Default LoginMessage is not defined FLoginMessage = null; }
public UserPrincipal(System.Security.Principal.IIdentity identity, string visitorId) { m_Identity = identity; m_VisitorId = visitorId; }
public UserPrincipal(string visitorId) { m_Identity = new Models.AnonymousIdentity("anonymousUser"); m_VisitorId = visitorId; }