DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Static Public Member Functions | Static Private Member Functions | List of all members
Deveel.Data.Security.Query Class Reference

Static Public Member Functions

static void CreateUserGroup (this IQuery query, string groupName)
 
static User GetUser (this IQuery query, string userName)
 
static void SetUserStatus (this IQuery queryContext, string username, UserStatus status)
 
static UserStatus GetUserStatus (this IQuery queryContext, string userName)
 
static void SetUserGroups (this IQuery query, string userName, string[] groups)
 
static bool UserExists (this IQuery query, string userName)
 
static void CreatePublicUser (this IQuery query)
 
static User CreateUser (this IQuery query, string userName, string password)
 
static void AlterUserPassword (this IQuery queryContext, string username, string password)
 
static bool DeleteUser (this IQuery query, string userName)
 
static User Authenticate (this IQuery queryContext, string username, string password)
 Authenticates the specified user using the provided credentials. More...
 
static void AddUserToGroup (this IQuery queryContext, string username, string group, bool asAdmin=false)
 
static void GrantToUserOn (this IQuery query, ObjectName objectName, string grantee, Privileges privileges, bool withOption=false)
 
static void GrantToUserOn (this IQuery query, DbObjectType objectType, ObjectName objectName, string grantee, Privileges privileges, bool withOption=false)
 
static void GrantToUserOnSchema (this IQuery query, string schemaName, string grantee, Privileges privileges, bool withOption=false)
 
static void GrantToGroupOn (this IQuery query, DbObjectType objectType, ObjectName objectName, string groupName, Privileges privileges, bool withOption=false)
 
static void GrantTo (this IQuery query, string groupOrUserName, DbObjectType objectType, ObjectName objectName, Privileges privileges, bool withOption=false)
 
static void RevokeAllGrantsOnTable (this IQuery query, ObjectName objectName)
 
static void RevokeAllGrantsOnView (this IQuery query, ObjectName objectName)
 
static void RevokeAllGrantsOn (this IQuery query, DbObjectType objectType, ObjectName objectName)
 
static void GrantToUserOnTable (this IQuery query, ObjectName tableName, string grantee, Privileges privileges)
 
static string[] GetGroupsUserBelongsTo (this IQuery queryContext, string username)
 
static bool UserBelongsToGroup (this IQuery queryContext, string group)
 
static bool UserBelongsToGroup (this IQuery query, string username, string groupName)
 
static bool UserCanManageGroups (this IQuery query)
 
static bool UserHasSecureAccess (this IQuery query)
 
static bool UserBelongsToSecureGroup (this IQuery query)
 
static bool UserHasGrantOption (this IQuery query, DbObjectType objectType, ObjectName objectName, Privileges privileges)
 
static bool UserHasPrivilege (this IQuery query, DbObjectType objectType, ObjectName objectName, Privileges privileges)
 
static bool UserCanCreateUsers (this IQuery query)
 
static bool UserCanDropUser (this IQuery query, string userToDrop)
 
static bool UserCanAlterUser (this IQuery query, string userName)
 
static bool UserCanManageUsers (this IQuery query)
 
static bool UserCanAccessUsers (this IQuery query)
 
static bool UserHasTablePrivilege (this IQuery query, ObjectName tableName, Privileges privileges)
 
static bool UserHasSchemaPrivilege (this IQuery query, string schemaName, Privileges privileges)
 
static bool UserCanCreateSchema (this IQuery query)
 
static bool UserCanCreateInSchema (this IQuery query, string schemaName)
 
static bool UserCanCreateTable (this IQuery query, ObjectName tableName)
 
static bool UserCanAlterInSchema (this IQuery query, string schemaName)
 
static bool UserCanAlterTable (this IQuery query, ObjectName tableName)
 
static bool UserCanSelectFromTable (this IQuery query, ObjectName tableName)
 
static bool UserCanReferenceTable (this IQuery query, ObjectName tableName)
 
static bool UserCanSelectFromPlan (this IQuery query, IQueryPlanNode queryPlan)
 
static bool UserCanSelectFromTable (this IQuery query, ObjectName tableName, params string[] columnNames)
 
static bool UserCanUpdateTable (this IQuery query, ObjectName tableName, params string[] columnNames)
 
static bool UserCanInsertIntoTable (this IQuery query, ObjectName tableName, params string[] columnNames)
 
static bool UserCanExecute (this IQuery query, RoutineType routineType, Invoke invoke)
 
static bool UserCanExecuteFunction (this IQuery query, Invoke invoke)
 
static bool UserCanExecuteProcedure (this IQuery query, Invoke invoke)
 
static bool UserCanCreateObject (this IQuery query, DbObjectType objectType, ObjectName objectName)
 
static bool UserCanDropObject (this IQuery query, DbObjectType objectType, ObjectName objectName)
 
static bool UserCanAlterObject (this IQuery query, DbObjectType objectType, ObjectName objectName)
 
static bool UserCanAccessObject (this IQuery query, DbObjectType objectType, ObjectName objectName)
 
static bool UserCanDeleteFromTable (this IQuery query, ObjectName tableName)
 
static bool UserCanAddToGroup (this IQuery query, string groupName)
 

Static Private Member Functions

static IUserManager UserManager (this IQuery query)
 
static IPrivilegeManager PrivilegeManager (this IQuery query)
 

Detailed Description

Definition at line 28 of file Query.Security.cs.

Member Function Documentation

static void Deveel.Data.Security.Query.AddUserToGroup ( this IQuery  queryContext,
string  username,
string  group,
bool  asAdmin = false 
)
inlinestatic

Definition at line 209 of file Query.Security.cs.

209  {
210  if (String.IsNullOrEmpty(@group))
211  throw new ArgumentNullException("group");
212  if (String.IsNullOrEmpty(username))
213  throw new ArgumentNullException("username");
214 
215  if (!queryContext.UserCanAddToGroup(group))
216  throw new SecurityException();
217 
218  queryContext.Direct().UserManager().AddUserToGroup(username, group, asAdmin);
219  }
A long string in the system.
static void Deveel.Data.Security.Query.AlterUserPassword ( this IQuery  queryContext,
string  username,
string  password 
)
inlinestatic

Definition at line 141 of file Query.Security.cs.

141  {
142  if (!queryContext.UserCanAlterUser(username))
143  throw new MissingPrivilegesException(queryContext.UserName(), new ObjectName(username), Privileges.Alter);
144 
145  var userId = UserIdentification.PlainText;
146  var userInfo = new UserInfo(username, userId);
147 
148  queryContext.Direct().UserManager().AlterUser(userInfo, password);
149  }
Describes the name of an object within a database.
Definition: ObjectName.cs:44
static User Deveel.Data.Security.Query.Authenticate ( this IQuery  queryContext,
string  username,
string  password 
)
inlinestatic

Authenticates the specified user using the provided credentials.

Parameters
queryContextThe query query.
usernameThe name of the user to authenticate.
passwordThe password used to authenticate the user.
Returns
Exceptions
System.ArgumentNullExceptionIf either username or password are null or empty.
SecurityExceptionIf the authentication was not successful for the credentials provided.
System.NotImplementedExceptionThe external authentication mechanism is not implemented yet

Definition at line 176 of file Query.Security.cs.

176  {
177  try {
178  if (String.IsNullOrEmpty(username))
179  throw new ArgumentNullException("username");
180  if (String.IsNullOrEmpty(password))
181  throw new ArgumentNullException("password");
182 
183  var userInfo = queryContext.Direct().UserManager().GetUser(username);
184 
185  if (userInfo == null)
186  return null;
187 
188  var userId = userInfo.Identification;
189 
190  if (userId.Method != "plain")
191  throw new NotImplementedException();
192 
193  if (!queryContext.Direct().UserManager().CheckIdentifier(username, password))
194  return null;
195 
196  // Successfully authenticated...
197  return new User(username);
198  } catch (SecurityException) {
199  throw;
200  } catch (Exception ex) {
201  throw new SecurityException("Could not authenticate user.", ex);
202  }
203  }
A long string in the system.
static void Deveel.Data.Security.Query.CreatePublicUser ( this IQuery  query)
inlinestatic

Definition at line 98 of file Query.Security.cs.

98  {
99  if (!query.User().IsSystem)
100  throw new InvalidOperationException("The @PUBLIC user can be created only by the SYSTEM");
101 
102  var userName = User.PublicName;
103  var userId = UserIdentification.PlainText;
104  var userInfo = new UserInfo(userName, userId);
105 
106  query.Direct().UserManager().CreateUser(userInfo, "####");
107  }
static User Deveel.Data.Security.Query.CreateUser ( this IQuery  query,
string  userName,
string  password 
)
inlinestatic

Definition at line 109 of file Query.Security.cs.

109  {
110  if (String.IsNullOrEmpty(userName))
111  throw new ArgumentNullException("userName");
112  if (String.IsNullOrEmpty(password))
113  throw new ArgumentNullException("password");
114 
115  if (!query.UserCanCreateUsers())
116  throw new MissingPrivilegesException(userName, new ObjectName(userName), Privileges.Create,
117  String.Format("User '{0}' cannot create users.", query.UserName()));
118 
119  if (String.Equals(userName, User.PublicName, StringComparison.OrdinalIgnoreCase))
120  throw new ArgumentException(
121  String.Format("User name '{0}' is reserved and cannot be registered.", User.PublicName), "userName");
122 
123  if (userName.Length <= 1)
124  throw new ArgumentException("User name must be at least one character.");
125  if (password.Length <= 1)
126  throw new ArgumentException("The password must be at least one character.");
127 
128  var c = userName[0];
129  if (c == '#' || c == '@' || c == '$' || c == '&')
130  throw new ArgumentException(
131  String.Format("User name '{0}' is invalid: cannot start with '{1}' character.", userName, c), "userName");
132 
133  var userId = UserIdentification.PlainText;
134  var userInfo = new UserInfo(userName, userId);
135 
136  query.Direct().UserManager().CreateUser(userInfo, password);
137 
138  return new User(userName);
139  }
A long string in the system.
Describes the name of an object within a database.
Definition: ObjectName.cs:44
static void Deveel.Data.Security.Query.CreateUserGroup ( this IQuery  query,
string  groupName 
)
inlinestatic

Definition at line 37 of file Query.Security.cs.

37  {
38  if (!query.UserCanManageGroups())
39  throw new InvalidOperationException(String.Format("User '{0}' has not enough privileges to create a group.", query.UserName()));
40 
41  query.Direct().UserManager().CreateUserGroup(groupName);
42  }
A long string in the system.
static bool Deveel.Data.Security.Query.DeleteUser ( this IQuery  query,
string  userName 
)
inlinestatic

Definition at line 151 of file Query.Security.cs.

151  {
152  if (String.IsNullOrEmpty(userName))
153  throw new ArgumentNullException("userName");
154 
155  if (!query.UserCanDropUser(userName))
156  throw new MissingPrivilegesException(query.UserName(), new ObjectName(userName), Privileges.Drop);
157 
158  return query.Direct().UserManager().DropUser(userName);
159  }
A long string in the system.
Describes the name of an object within a database.
Definition: ObjectName.cs:44
static string [] Deveel.Data.Security.Query.GetGroupsUserBelongsTo ( this IQuery  queryContext,
string  username 
)
inlinestatic

Definition at line 308 of file Query.Security.cs.

308  {
309  return queryContext.Direct().UserManager().GetUserGroups(username);
310  }
static User Deveel.Data.Security.Query.GetUser ( this IQuery  query,
string  userName 
)
inlinestatic

Definition at line 46 of file Query.Security.cs.

46  {
47  if (query.UserName().Equals(userName, StringComparison.OrdinalIgnoreCase))
48  return new User(userName);
49 
50  if (!query.UserCanAccessUsers())
51  throw new MissingPrivilegesException(query.UserName(), new ObjectName(userName), Privileges.Select,
52  String.Format("The user '{0}' has not enough rights to access other users information.", query.UserName()));
53 
54  if (!query.Direct().UserManager().UserExists(userName))
55  return null;
56 
57  return new User(userName);
58  }
A long string in the system.
Describes the name of an object within a database.
Definition: ObjectName.cs:44
static UserStatus Deveel.Data.Security.Query.GetUserStatus ( this IQuery  queryContext,
string  userName 
)
inlinestatic

Definition at line 68 of file Query.Security.cs.

68  {
69  if (!queryContext.UserName().Equals(userName) &&
70  !queryContext.UserCanAccessUsers())
71  throw new MissingPrivilegesException(queryContext.UserName(), new ObjectName(userName), Privileges.Select,
72  String.Format("The user '{0}' has not enough rights to access other users information.", queryContext.UserName()));
73 
74  return queryContext.Direct().UserManager().GetUserStatus(userName);
75  }
A long string in the system.
Describes the name of an object within a database.
Definition: ObjectName.cs:44
static void Deveel.Data.Security.Query.GrantTo ( this IQuery  query,
string  groupOrUserName,
DbObjectType  objectType,
ObjectName  objectName,
Privileges  privileges,
bool  withOption = false 
)
inlinestatic

Definition at line 263 of file Query.Security.cs.

263  {
264  if (query.Direct().UserManager().UserGroupExists(groupOrUserName)) {
265  if (withOption)
266  throw new SecurityException("User groups cannot be granted with grant option.");
267 
268  query.GrantToGroupOn(objectType, objectName, groupOrUserName, privileges);
269  } else if (query.Direct().UserManager().UserExists(groupOrUserName)) {
270  query.GrantToUserOn(objectType, objectName, groupOrUserName, privileges, withOption);
271  } else {
272  throw new SecurityException(String.Format("User or group '{0}' was not found.", groupOrUserName));
273  }
274  }
A long string in the system.
static void Deveel.Data.Security.Query.GrantToGroupOn ( this IQuery  query,
DbObjectType  objectType,
ObjectName  objectName,
string  groupName,
Privileges  privileges,
bool  withOption = false 
)
inlinestatic

Definition at line 248 of file Query.Security.cs.

248  {
249  if (SystemGroups.IsSystemGroup(groupName))
250  throw new InvalidOperationException("Cannot grant to a system group.");
251 
252  if (!query.UserCanManageGroups())
253  throw new MissingPrivilegesException(query.UserName(), new ObjectName(groupName));
254 
255  if (!query.ObjectExists(objectType, objectName))
256  throw new ObjectNotFoundException(objectName);
257 
258  var granter = query.UserName();
259  var grant = new Grant(privileges, objectName, objectType, granter, withOption);
260  query.Direct().PrivilegeManager().GrantToGroup(groupName, grant);
261  }
Describes the name of an object within a database.
Definition: ObjectName.cs:44
static void Deveel.Data.Security.Query.GrantToUserOn ( this IQuery  query,
ObjectName  objectName,
string  grantee,
Privileges  privileges,
bool  withOption = false 
)
inlinestatic

Definition at line 221 of file Query.Security.cs.

221  {
222  var obj = query.FindObject(objectName);
223  if (obj == null)
224  throw new ObjectNotFoundException(objectName);
225 
226  query.GrantToUserOn(obj.ObjectType, obj.FullName, grantee, privileges, withOption);
227  }
static void Deveel.Data.Security.Query.GrantToUserOn ( this IQuery  query,
DbObjectType  objectType,
ObjectName  objectName,
string  grantee,
Privileges  privileges,
bool  withOption = false 
)
inlinestatic

Definition at line 229 of file Query.Security.cs.

229  {
230  if (String.Equals(grantee, User.SystemName)) // The @SYSTEM user does not need any other
231  return;
232 
233  if (!query.ObjectExists(objectType, objectName))
234  throw new ObjectNotFoundException(objectName);
235 
236  if (!query.UserHasGrantOption(objectType, objectName, privileges))
237  throw new MissingPrivilegesException(query.UserName(), objectName, privileges);
238 
239  var granter = query.UserName();
240  var grant = new Grant(privileges, objectName, objectType, granter, withOption);
241  query.Direct().PrivilegeManager().GrantToUser(grantee, grant);
242  }
A long string in the system.
static void Deveel.Data.Security.Query.GrantToUserOnSchema ( this IQuery  query,
string  schemaName,
string  grantee,
Privileges  privileges,
bool  withOption = false 
)
inlinestatic

Definition at line 244 of file Query.Security.cs.

244  {
245  query.GrantToUserOn(DbObjectType.Schema, new ObjectName(schemaName), grantee, privileges, withOption);
246  }
Describes the name of an object within a database.
Definition: ObjectName.cs:44
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static void Deveel.Data.Security.Query.GrantToUserOnTable ( this IQuery  query,
ObjectName  tableName,
string  grantee,
Privileges  privileges 
)
inlinestatic

Definition at line 300 of file Query.Security.cs.

300  {
301  query.GrantToUserOn(DbObjectType.Table, tableName, grantee, privileges);
302  }
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static IPrivilegeManager Deveel.Data.Security.Query.PrivilegeManager ( this IQuery  query)
inlinestaticprivate

Definition at line 33 of file Query.Security.cs.

33  {
34  return query.Context.ResolveService<IPrivilegeManager>();
35  }
static void Deveel.Data.Security.Query.RevokeAllGrantsOn ( this IQuery  query,
DbObjectType  objectType,
ObjectName  objectName 
)
inlinestatic

Definition at line 284 of file Query.Security.cs.

284  {
285  var grantTable = query.GetMutableTable(SystemSchema.UserGrantsTableName);
286 
287  var objectTypeColumn = grantTable.GetResolvedColumnName(1);
288  var objectNameColumn = grantTable.GetResolvedColumnName(2);
289  // All that match the given object
290  var t1 = grantTable.SimpleSelect(query, objectTypeColumn, SqlExpressionType.Equal,
291  SqlExpression.Constant(DataObject.Integer((int)objectType)));
292  // All that match the given parameter
293  t1 = t1.SimpleSelect(query, objectNameColumn, SqlExpressionType.Equal,
294  SqlExpression.Constant(DataObject.String(objectName.FullName)));
295 
296  // Remove these rows from the table
297  grantTable.Delete(t1);
298  }
SqlExpressionType
All the possible type of SqlExpression supported
string FullName
Gets the full reference name formatted.
Definition: ObjectName.cs:114
Defines the base class for instances that represent SQL expression tree nodes.
static SqlConstantExpression Constant(object value)
static void Deveel.Data.Security.Query.RevokeAllGrantsOnTable ( this IQuery  query,
ObjectName  objectName 
)
inlinestatic

Definition at line 276 of file Query.Security.cs.

276  {
277  RevokeAllGrantsOn(query, DbObjectType.Table, objectName);
278  }
static void RevokeAllGrantsOn(this IQuery query, DbObjectType objectType, ObjectName objectName)
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static void Deveel.Data.Security.Query.RevokeAllGrantsOnView ( this IQuery  query,
ObjectName  objectName 
)
inlinestatic

Definition at line 280 of file Query.Security.cs.

280  {
281  query.RevokeAllGrantsOn(DbObjectType.View, objectName);
282  }
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static void Deveel.Data.Security.Query.SetUserGroups ( this IQuery  query,
string  userName,
string[]  groups 
)
inlinestatic

Definition at line 77 of file Query.Security.cs.

77  {
78  if (!query.UserCanManageUsers())
79  throw new MissingPrivilegesException(query.UserName(), new ObjectName(userName), Privileges.Alter,
80  String.Format("The user '{0}' has not enough rights to modify other users information.", query.UserName()));
81 
82  // TODO: Check if the user exists?
83 
84  var userGroups = query.Direct().UserManager().GetUserGroups(userName);
85  foreach (var userGroup in userGroups) {
86  query.Direct().UserManager().RemoveUserFromGroup(userName, userGroup);
87  }
88 
89  foreach (var userGroup in groups) {
90  query.Direct().UserManager().AddUserToGroup(userName, userGroup, false);
91  }
92  }
A long string in the system.
Describes the name of an object within a database.
Definition: ObjectName.cs:44
static void Deveel.Data.Security.Query.SetUserStatus ( this IQuery  queryContext,
string  username,
UserStatus  status 
)
inlinestatic

Definition at line 60 of file Query.Security.cs.

60  {
61  if (!queryContext.UserCanManageUsers())
62  throw new MissingPrivilegesException(queryContext.UserName(), new ObjectName(username), Privileges.Alter,
63  String.Format("User '{0}' cannot change the status of user '{1}'", queryContext.UserName(), username));
64 
65  queryContext.Direct().UserManager().SetUserStatus(username, status);
66  }
A long string in the system.
Describes the name of an object within a database.
Definition: ObjectName.cs:44
static bool Deveel.Data.Security.Query.UserBelongsToGroup ( this IQuery  queryContext,
string  group 
)
inlinestatic

Definition at line 312 of file Query.Security.cs.

312  {
313  return UserBelongsToGroup(queryContext, queryContext.UserName(), group);
314  }
static bool UserBelongsToGroup(this IQuery queryContext, string group)
static bool Deveel.Data.Security.Query.UserBelongsToGroup ( this IQuery  query,
string  username,
string  groupName 
)
inlinestatic

Definition at line 316 of file Query.Security.cs.

316  {
317  return query.Direct().UserManager().IsUserInGroup(username, groupName);
318  }
static bool Deveel.Data.Security.Query.UserBelongsToSecureGroup ( this IQuery  query)
inlinestatic

Definition at line 331 of file Query.Security.cs.

331  {
332  return query.UserBelongsToGroup(SystemGroups.SecureGroup);
333  }
static bool Deveel.Data.Security.Query.UserCanAccessObject ( this IQuery  query,
DbObjectType  objectType,
ObjectName  objectName 
)
inlinestatic

Definition at line 491 of file Query.Security.cs.

491  {
492  return query.UserHasPrivilege(objectType, objectName, Privileges.Select);
493  }
static bool Deveel.Data.Security.Query.UserCanAccessUsers ( this IQuery  query)
inlinestatic

Definition at line 385 of file Query.Security.cs.

385  {
386  return query.UserHasSecureAccess() || query.UserBelongsToGroup(SystemGroups.UserManagerGroup);
387  }
static bool Deveel.Data.Security.Query.UserCanAddToGroup ( this IQuery  query,
string  groupName 
)
inlinestatic

Definition at line 499 of file Query.Security.cs.

499  {
500  if (query.User().IsSystem)
501  return true;
502 
503  if (query.UserBelongsToSecureGroup() ||
504  query.UserBelongsToGroup(SystemGroups.UserManagerGroup))
505  return true;
506 
507  return query.Direct().UserManager().IsUserGroupAdmin(query.UserName(), groupName);
508  }
static bool Deveel.Data.Security.Query.UserCanAlterInSchema ( this IQuery  query,
string  schemaName 
)
inlinestatic

Definition at line 416 of file Query.Security.cs.

416  {
417  if (query.UserHasSchemaPrivilege(schemaName, Privileges.Alter))
418  return true;
419 
420  return query.UserHasSecureAccess();
421  }
static bool Deveel.Data.Security.Query.UserCanAlterObject ( this IQuery  query,
DbObjectType  objectType,
ObjectName  objectName 
)
inlinestatic

Definition at line 487 of file Query.Security.cs.

487  {
488  return query.UserHasPrivilege(objectType, objectName, Privileges.Alter);
489  }
static bool Deveel.Data.Security.Query.UserCanAlterTable ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 423 of file Query.Security.cs.

423  {
424  var schema = tableName.Parent;
425  if (schema == null)
426  return false;
427 
428  return query.UserCanAlterInSchema(schema.FullName);
429  }
ObjectName Parent
Gets the parent reference of the current one, if any or null if none.
Definition: ObjectName.cs:99
static bool Deveel.Data.Security.Query.UserCanAlterUser ( this IQuery  query,
string  userName 
)
inlinestatic

Definition at line 371 of file Query.Security.cs.

371  {
372  if (query.UserName().Equals(userName))
373  return true;
374 
375  if (userName.Equals(User.PublicName, StringComparison.OrdinalIgnoreCase))
376  return false;
377 
378  return query.UserHasSecureAccess();
379  }
static bool Deveel.Data.Security.Query.UserCanCreateInSchema ( this IQuery  query,
string  schemaName 
)
inlinestatic

Definition at line 404 of file Query.Security.cs.

404  {
405  return query.UserHasSchemaPrivilege(schemaName, Privileges.Create);
406  }
static bool Deveel.Data.Security.Query.UserCanCreateObject ( this IQuery  query,
DbObjectType  objectType,
ObjectName  objectName 
)
inlinestatic

Definition at line 479 of file Query.Security.cs.

479  {
480  return query.UserHasPrivilege(objectType, objectName, Privileges.Create);
481  }
static bool Deveel.Data.Security.Query.UserCanCreateSchema ( this IQuery  query)
inlinestatic

Definition at line 400 of file Query.Security.cs.

400  {
401  return query.UserHasSecureAccess();
402  }
static bool Deveel.Data.Security.Query.UserCanCreateTable ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 408 of file Query.Security.cs.

408  {
409  var schema = tableName.Parent;
410  if (schema == null)
411  return query.UserHasSecureAccess();
412 
413  return query.UserCanCreateInSchema(schema.FullName);
414  }
ObjectName Parent
Gets the parent reference of the current one, if any or null if none.
Definition: ObjectName.cs:99
static bool Deveel.Data.Security.Query.UserCanCreateUsers ( this IQuery  query)
inlinestatic

Definition at line 360 of file Query.Security.cs.

360  {
361  return query.UserHasSecureAccess() ||
362  query.UserBelongsToGroup(SystemGroups.UserManagerGroup);
363  }
static bool Deveel.Data.Security.Query.UserCanDeleteFromTable ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 495 of file Query.Security.cs.

495  {
496  return query.UserHasTablePrivilege(tableName, Privileges.Delete);
497  }
static bool Deveel.Data.Security.Query.UserCanDropObject ( this IQuery  query,
DbObjectType  objectType,
ObjectName  objectName 
)
inlinestatic

Definition at line 483 of file Query.Security.cs.

483  {
484  return query.UserHasPrivilege(objectType, objectName, Privileges.Drop);
485  }
static bool Deveel.Data.Security.Query.UserCanDropUser ( this IQuery  query,
string  userToDrop 
)
inlinestatic

Definition at line 365 of file Query.Security.cs.

365  {
366  return query.UserHasSecureAccess() ||
367  query.UserBelongsToGroup(SystemGroups.UserManagerGroup) ||
368  query.UserName().Equals(userToDrop, StringComparison.OrdinalIgnoreCase);
369  }
static bool Deveel.Data.Security.Query.UserCanExecute ( this IQuery  query,
RoutineType  routineType,
Invoke  invoke 
)
inlinestatic

Definition at line 459 of file Query.Security.cs.

459  {
460  if (routineType == RoutineType.Function &&
461  query.IsSystemFunction(invoke)) {
462  return true;
463  }
464 
465  if (query.UserHasSecureAccess())
466  return true;
467 
468  return query.UserHasPrivilege(DbObjectType.Routine, invoke.RoutineName, Privileges.Execute);
469  }
RoutineType
The type of routine program.
Definition: RoutineType.cs:23
ObjectName RoutineName
Gets the fully qualified name of the routine to invoke.
Definition: Invoke.cs:58
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static bool Deveel.Data.Security.Query.UserCanExecuteFunction ( this IQuery  query,
Invoke  invoke 
)
inlinestatic

Definition at line 471 of file Query.Security.cs.

471  {
472  return query.UserCanExecute(RoutineType.Function, invoke);
473  }
RoutineType
The type of routine program.
Definition: RoutineType.cs:23
static bool Deveel.Data.Security.Query.UserCanExecuteProcedure ( this IQuery  query,
Invoke  invoke 
)
inlinestatic

Definition at line 475 of file Query.Security.cs.

475  {
476  return query.UserCanExecute(RoutineType.Procedure, invoke);
477  }
RoutineType
The type of routine program.
Definition: RoutineType.cs:23
static bool Deveel.Data.Security.Query.UserCanInsertIntoTable ( this IQuery  query,
ObjectName  tableName,
params string[]  columnNames 
)
inlinestatic

Definition at line 454 of file Query.Security.cs.

454  {
455  // TODO: Column-level select will be implemented in the future
456  return query.UserHasTablePrivilege(tableName, Privileges.Insert);
457  }
static bool Deveel.Data.Security.Query.UserCanManageGroups ( this IQuery  query)
inlinestatic

Definition at line 320 of file Query.Security.cs.

320  {
321  return query.User().IsSystem || query.UserHasSecureAccess();
322  }
static bool Deveel.Data.Security.Query.UserCanManageUsers ( this IQuery  query)
inlinestatic

Definition at line 381 of file Query.Security.cs.

381  {
382  return query.UserHasSecureAccess() || query.UserBelongsToGroup(SystemGroups.UserManagerGroup);
383  }
static bool Deveel.Data.Security.Query.UserCanReferenceTable ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 435 of file Query.Security.cs.

435  {
436  return query.UserHasTablePrivilege(tableName, Privileges.References);
437  }
static bool Deveel.Data.Security.Query.UserCanSelectFromPlan ( this IQuery  query,
IQueryPlanNode  queryPlan 
)
inlinestatic

Definition at line 439 of file Query.Security.cs.

439  {
440  var selectedTables = queryPlan.DiscoverTableNames();
441  return selectedTables.All(query.UserCanSelectFromTable);
442  }
static bool Deveel.Data.Security.Query.UserCanSelectFromTable ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 431 of file Query.Security.cs.

431  {
432  return UserCanSelectFromTable(query, tableName, new string[0]);
433  }
static bool UserCanSelectFromTable(this IQuery query, ObjectName tableName)
static bool Deveel.Data.Security.Query.UserCanSelectFromTable ( this IQuery  query,
ObjectName  tableName,
params string[]  columnNames 
)
inlinestatic

Definition at line 444 of file Query.Security.cs.

444  {
445  // TODO: Column-level select will be implemented in the future
446  return query.UserHasTablePrivilege(tableName, Privileges.Select);
447  }
static bool Deveel.Data.Security.Query.UserCanUpdateTable ( this IQuery  query,
ObjectName  tableName,
params string[]  columnNames 
)
inlinestatic

Definition at line 449 of file Query.Security.cs.

449  {
450  // TODO: Column-level select will be implemented in the future
451  return query.UserHasTablePrivilege(tableName, Privileges.Update);
452  }
static bool Deveel.Data.Security.Query.UserExists ( this IQuery  query,
string  userName 
)
inlinestatic

Definition at line 94 of file Query.Security.cs.

94  {
95  return query.Direct().UserManager().UserExists(userName);
96  }
static bool Deveel.Data.Security.Query.UserHasGrantOption ( this IQuery  query,
DbObjectType  objectType,
ObjectName  objectName,
Privileges  privileges 
)
inlinestatic

Definition at line 335 of file Query.Security.cs.

335  {
336  var user = query.User();
337  if (user.IsSystem)
338  return true;
339 
340  if (query.UserBelongsToSecureGroup())
341  return true;
342 
343  var grant = query.Direct().PrivilegeManager().GetUserPrivileges(user.Name, objectType, objectName, true);
344  return (grant & privileges) != 0;
345  }
static bool Deveel.Data.Security.Query.UserHasPrivilege ( this IQuery  query,
DbObjectType  objectType,
ObjectName  objectName,
Privileges  privileges 
)
inlinestatic

Definition at line 347 of file Query.Security.cs.

347  {
348  var user = query.User();
349  if (user.IsSystem)
350  return true;
351 
352  if (query.UserBelongsToSecureGroup())
353  return true;
354 
355  var userName = user.Name;
356  var grant = query.Direct().PrivilegeManager().GetUserPrivileges(userName, objectType, objectName, false);
357  return (grant & privileges) != 0;
358  }
static bool Deveel.Data.Security.Query.UserHasSchemaPrivilege ( this IQuery  query,
string  schemaName,
Privileges  privileges 
)
inlinestatic

Definition at line 393 of file Query.Security.cs.

393  {
394  if (query.UserHasPrivilege(DbObjectType.Schema, new ObjectName(schemaName), privileges))
395  return true;
396 
397  return query.UserHasSecureAccess();
398  }
Describes the name of an object within a database.
Definition: ObjectName.cs:44
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static bool Deveel.Data.Security.Query.UserHasSecureAccess ( this IQuery  query)
inlinestatic

Definition at line 324 of file Query.Security.cs.

324  {
325  if (query.User().IsSystem)
326  return true;
327 
328  return query.UserBelongsToSecureGroup();
329  }
static bool Deveel.Data.Security.Query.UserHasTablePrivilege ( this IQuery  query,
ObjectName  tableName,
Privileges  privileges 
)
inlinestatic

Definition at line 389 of file Query.Security.cs.

389  {
390  return query.UserHasPrivilege(DbObjectType.Table, tableName, privileges);
391  }
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static IUserManager Deveel.Data.Security.Query.UserManager ( this IQuery  query)
inlinestaticprivate

Definition at line 29 of file Query.Security.cs.

29  {
30  return query.Context.ResolveService<IUserManager>();
31  }

The documentation for this class was generated from the following file: