public bool DropRole(string roleName) { try { return(SystemSession.Access().UserManager.DropRole(roleName)); } finally { RevokeAllGrantsFrom(roleName); } }
public void Revoke(DbObjectType objectType, ObjectName objectName, string grantee, Privileges privileges, bool grantOption = false) { try { var revoker = Session.User.Name; var grant = new Grant(privileges, objectName, objectType, grantee, revoker, grantOption); SystemSession.Access().PrivilegeManager.Revoke(grant); } finally { var key = new GrantCacheKey(grantee, objectType, objectName.FullName, grantOption, false); PrivilegesCache.Remove(key); } }
public bool DeleteUser(string userName) { if (String.IsNullOrEmpty(userName)) { throw new ArgumentNullException("userName"); } try { return(SystemSession.Access().UserManager.DropUser(userName)); } finally { RevokeAllGrantsFrom(userName); } }
public void CreateUser(string userName, string identification, string token) { if (String.IsNullOrEmpty(userName)) { throw new ArgumentNullException("userName"); } if (String.IsNullOrEmpty(identification)) { throw new ArgumentNullException("identification"); } if (String.IsNullOrEmpty(token)) { throw new ArgumentNullException("token"); } if (String.Equals(userName, User.PublicName, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException( String.Format("User name '{0}' is reserved and cannot be registered.", User.PublicName), "userName"); } if (userName.Length <= 1) { throw new ArgumentException("User name must be at least one character."); } if (token.Length <= 1) { throw new ArgumentException("The password must be at least one character."); } var c = userName[0]; if (c == '#' || c == '@' || c == '$' || c == '&') { throw new ArgumentException( String.Format("User name '{0}' is invalid: cannot start with '{1}' character.", userName, c), "userName"); } var identifier = FindIdentifier(identification); if (identifier == null) { throw new ArgumentException(String.Format("User identification method '{0}' cannot be found", identification)); } var userId = identifier.CreateIdentification(token); var userInfo = new UserInfo(userName, userId); SystemSession.Access().UserManager.CreateUser(userInfo); }
public bool Authenticate(string username, string password) { try { if (String.IsNullOrEmpty(username)) { throw new ArgumentNullException("username"); } if (String.IsNullOrEmpty(password)) { throw new ArgumentNullException("password"); } var userInfo = SystemSession.Access().UserManager.GetUser(username); if (userInfo == null) { return(false); } var userId = userInfo.Identification; var identifier = FindIdentifier(userId.Method); if (identifier == null) { throw new SecurityException(String.Format("The user '{0}' was identified by '{1}' but the identifier cannot be found in the context.", userInfo.Name, userId.Method)); } if (!identifier.VerifyIdentification(password, userId)) { return(false); } // Successfully authenticated... return(true); } catch (SecurityException) { throw; } catch (Exception ex) { throw new SecurityException("Could not authenticate user.", ex); } }
public void AlterUserPassword(string username, string identification, string token) { if (String.IsNullOrEmpty(username)) { throw new ArgumentNullException("username"); } if (String.IsNullOrEmpty(identification)) { throw new ArgumentNullException("identification"); } var identifier = FindIdentifier(identification); if (identifier == null) { throw new ArgumentException(String.Format("User identification method '{0}' cannot be found", identification)); } var userId = identifier.CreateIdentification(token); var userInfo = new UserInfo(username, userId); SystemSession.Access().UserManager.AlterUser(userInfo); }
public void CreateUser(UserInfo userInfo) { SystemSession.Access().UserManager.CreateUser(userInfo); }
public bool UserExists(string userName) { return(SystemSession.Access().UserManager.UserExists(userName)); }
public UserStatus GetUserStatus(string userName) { return(SystemSession.Access().UserManager.GetUserStatus(userName)); }
public void SetUserStatus(string username, UserStatus status) { SystemSession.Access().UserManager.SetUserStatus(username, status); }
public void SetRoleAdmin(string roleName, string userName) { SystemSession.Access().UserManager.SetRoleAdmin(roleName, userName); }
public bool RoleExists(string roleName) { return(SystemSession.Access().UserManager.RoleExists(roleName)); }
public void CreateRole(string roleName) { SystemSession.Access().UserManager.CreateRole(roleName); }
public void CreateRoutine(RoutineInfo routineInfo) { SystemSession.Access().CreateObject(routineInfo); }
public bool DeleteRoutine(ObjectName routineName) { return(SystemSession.Access().DropObject(DbObjectType.Routine, routineName)); }