public void Revoke(OrderedHashSet <string> granteeList, ISchemaObject dbObject, Right rights, Grantee grantor, bool grantOption, bool cascade) { RoutineSchema schema = dbObject as RoutineSchema; if (schema != null) { ISchemaObject[] specificRoutines = schema.GetSpecificRoutines(); this.Revoke(granteeList, specificRoutines, rights, grantor, grantOption, cascade); } else { QNameManager.QName specificName = dbObject.GetName(); Routine routine = dbObject as Routine; if (routine != null) { specificName = routine.GetSpecificName(); } if (!grantor.IsFullyAccessibleByRole(specificName)) { throw Error.GetError(0x157d, dbObject.GetName().Name); } if (grantor.IsAdmin()) { grantor = dbObject.GetOwner(); } for (int i = 0; i < granteeList.Size(); i++) { string str = granteeList.Get(i); if (this.Get(str) == null) { throw Error.GetError(0xfa1, str); } if (IsImmutable(str)) { throw Error.GetError(0xfa2, str); } } for (int j = 0; j < granteeList.Size(); j++) { string str2 = granteeList.Get(j); Grantee role = this.Get(str2); role.Revoke(dbObject, rights, grantor, grantOption); role.UpdateAllRights(); if (role.IsRole) { this.UpdateAllRights(role); } } } }
public QNameManager.QName GetName(string name) { switch (this._type) { case 3: case 4: case 6: case 7: case 8: case 12: case 13: case 14: case 15: case 0x10: case 0x11: case 0x18: case 0x1b: { ISchemaObject obj2 = (ISchemaObject)this.Map.Get(name); if (obj2 == null) { return(null); } return(obj2.GetName()); } case 5: case 9: case 20: return((QNameManager.QName) this.Map.Get(name)); } return((QNameManager.QName) this.Map.Get(name)); }
public void CheckAccess(ISchemaObject obj) { if (!this.IsFullyAccessibleByRole(obj.GetName())) { QNameManager.QName key = obj.GetName(); Routine routine = obj as Routine; if (routine != null) { key = routine.GetSpecificName(); } Right right = this._fullRightsMap.Get(key); if ((right == null) || right.IsEmpty()) { throw Error.GetError(0x157d, obj.GetName().Name); } } }
public OrderedHashSet <Right> GetAllGrantedPrivileges(ISchemaObject obj) { Iterator <Right> iterator = this._grantedRightsMap.Get(obj.GetName()); if (iterator.HasNext()) { OrderedHashSet <Right> set2 = new OrderedHashSet <Right>(); while (iterator.HasNext()) { set2.Add(iterator.Next()); } return(set2); } return(Right.EmptySetRight); }
public void Revoke(ISchemaObject obj, Right right, Grantee grantor, bool grantOption) { QNameManager.QName key = obj.GetName(); Routine routine = obj as Routine; if (routine != null) { key = routine.GetSpecificName(); } Iterator <Right> iterator = this._directRightsMap.Get(key); Right right2 = null; while (iterator.HasNext()) { right2 = iterator.Next(); if (right2.Grantor == grantor) { break; } } if (right2 != null) { if (right2.GrantableRights != null) { right2.GrantableRights.Remove(obj, right); } if (!grantOption) { if (right.IsFull) { this._directRightsMap.Remove(key, right2); grantor._grantedRightsMap.Remove(key, right2); this.UpdateAllRights(); } else { right2.Remove(obj, right); if (right2.IsEmpty()) { this._directRightsMap.Remove(key, right2); grantor._grantedRightsMap.Remove(key, right2); } this.UpdateAllRights(); } } } }
public OrderedHashSet <Right> GetAllDirectPrivileges(ISchemaObject obj) { if (obj.GetOwner() == this) { OrderedHashSet <Right> set1 = new OrderedHashSet <Right>(); set1.Add(this.OwnerRights); return(set1); } Iterator <Right> iterator = this._directRightsMap.Get(obj.GetName()); if (iterator.HasNext()) { OrderedHashSet <Right> set2 = new OrderedHashSet <Right>(); while (iterator.HasNext()) { set2.Add(iterator.Next()); } return(set2); } return(Right.EmptySetRight); }
public void Add(ISchemaObject obj) { QNameManager.QName specificName = obj.GetName(); if (this._type == 0x18) { specificName = ((Routine)obj).GetSpecificName(); } if (this.Map.ContainsKey(specificName.Name)) { throw Error.GetError(GetAddErrorCode(specificName.type), specificName.Name); } object obj2 = obj; switch (specificName.type) { case 5: case 9: case 20: obj2 = specificName; break; } this.Map.Put(specificName.Name, obj2); }
public void Grant(OrderedHashSet <string> granteeList, ISchemaObject dbObject, Right right, Grantee grantor, bool withGrantOption) { RoutineSchema schema = dbObject as RoutineSchema; if (schema != null) { ISchemaObject[] specificRoutines = schema.GetSpecificRoutines(); this.Grant(granteeList, specificRoutines, right, grantor, withGrantOption); } else { QNameManager.QName specificName = dbObject.GetName(); Routine routine = dbObject as Routine; if (routine != null) { specificName = routine.GetSpecificName(); } if (!grantor.IsGrantable(dbObject, right)) { throw Error.GetError(0x7d0, grantor.GetNameString()); } if (grantor.IsAdmin()) { grantor = dbObject.GetOwner(); } this.CheckGranteeList(granteeList); for (int i = 0; i < granteeList.Size(); i++) { Grantee role = this.Get(granteeList.Get(i)); role.Grant(specificName, right, grantor, withGrantOption); if (role.IsRole) { this.UpdateAllRights(role); } } } }
public string GetSql() { ExpressionColumn column = this._expression as ExpressionColumn; if (column != null) { if (this.TokenType == 0x2a9) { StringBuilder builder = new StringBuilder(); if (((column == null) || (column.OpType != 0x61)) || (column.nodes.Length == 0)) { return this.TokenString; } builder.Append(' '); for (int i = 0; i < column.nodes.Length; i++) { Expression expression = column.nodes[i]; ColumnSchema schema = expression.GetColumn(); if (expression.OpType == 3) { if (i > 0) { builder.Append(','); } builder.Append(expression.GetColumnName()); } else { string schemaQualifiedStatementName; if (expression.GetRangeVariable().TableAlias == null) { schemaQualifiedStatementName = schema.GetName().GetSchemaQualifiedStatementName(); } else { schemaQualifiedStatementName = expression.GetRangeVariable().TableAlias.GetStatementName() + "." + schema.GetName().StatementName; } if (i > 0) { builder.Append(','); } builder.Append(schemaQualifiedStatementName); } } builder.Append(' '); return builder.ToString(); } } else { SqlType type = this._expression as SqlType; if (type != null) { this.IsDelimiter = false; if (!type.IsDistinctType() && !type.IsDomainType()) { return type.GetNameString(); } return type.GetName().GetSchemaQualifiedStatementName(); } ISchemaObject obj2 = this._expression as ISchemaObject; if (obj2 != null) { this.IsDelimiter = false; return obj2.GetName().GetSchemaQualifiedStatementName(); } } if ((this.NamePrefix == null) && this.IsUndelimitedIdentifier) { return this.TokenString; } if (this.TokenType == 0x2e9) { return this.DataType.ConvertToSQLString(this.TokenValue); } StringBuilder builder2 = new StringBuilder(); if (this.NamePrePrefix != null) { if (this.IsDelimitedPrePrefix) { builder2.Append('"'); builder2.Append(this.NamePrePrefix); builder2.Append('"'); } else { builder2.Append(this.NamePrePrefix); this.IsDelimiter = false; } builder2.Append('.'); } if (this.NamePrefix != null) { if (this.IsDelimitedPrefix) { builder2.Append('"'); builder2.Append(this.NamePrefix); builder2.Append('"'); } else { builder2.Append(this.NamePrefix); this.IsDelimiter = false; } builder2.Append('.'); } if (this.IsDelimitedIdentifier) { builder2.Append('"'); builder2.Append(this.TokenString); builder2.Append('"'); builder2.Append(' '); } else { builder2.Append(this.TokenString); } return builder2.ToString(); }
public bool IsGrantable(ISchemaObject obj, Right right) { return(this.IsFullyAccessibleByRole(obj.GetName()) || this.GetAllGrantableRights(obj.GetName()).Contains(right)); }
public bool IsAccessible(ISchemaObject obj) { return(this.IsAccessible(obj.GetName())); }
public static void AddAllSql(OrderedHashSet <object> resolved, OrderedHashSet <object> unresolved, List <string> list, Iterator <object> it, OrderedHashSet <object> newResolved) { while (it.HasNext()) { ISchemaObject key = (ISchemaObject)it.Next(); OrderedHashSet <QNameManager.QName> references = key.GetReferences(); bool flag = true; for (int i = 0; i < references.Size(); i++) { QNameManager.QName name = references.Get(i); if (SqlInvariants.IsSystemSchemaName(name) || (name.schema == SqlInvariants.ModuleQname)) { continue; } int type = name.type; switch (type) { case 3: { if (!resolved.Contains(name)) { flag = false; } continue; } case 4: case 6: case 7: case 8: case 10: case 11: case 15: { continue; } case 5: { if (name.Parent == key.GetName()) { Constraint constraint = ((Table)key).GetConstraint(name.Name); if ((constraint.GetConstraintType() == 3) && !IsChildObjectResolved(constraint, resolved)) { flag = false; } } continue; } case 9: { if (key.GetSchemaObjectType() != 3) { break; } Table table1 = (Table)key; if (!IsChildObjectResolved(table1.GetColumn(table1.FindColumn(name.Name)), resolved)) { flag = false; } continue; } case 12: case 13: case 0x10: case 0x11: goto Label_0147; case 14: { if (name.schema != null) { goto Label_0147; } continue; } default: goto Label_013B; } if (!resolved.Contains(name.Parent)) { flag = false; } continue; Label_013B: if ((type != 0x18) && (type != 0x1b)) { continue; } Label_0147: if (!resolved.Contains(name)) { flag = false; } } if (!flag) { unresolved.Add(key); } else { QNameManager.QName specificName; if (((key.GetSchemaObjectType() == 0x10) || (key.GetSchemaObjectType() == 0x1b)) || (key.GetSchemaObjectType() == 0x11)) { specificName = ((Routine)key).GetSpecificName(); } else { specificName = key.GetName(); } resolved.Add(specificName); if (newResolved != null) { newResolved.Add(key); } if (key.GetSchemaObjectType() == 3) { list.AddRange(((Table)key).GetSql(resolved, unresolved)); } else { if (((key.GetSchemaObjectType() - 0x10) <= 1) && ((Routine)key).IsRecursive) { list.Add(((Routine)key).GetSqlDeclaration()); list.Add(((Routine)key).GetSqlAlter()); continue; } list.Add(key.GetSql()); } } } }
public void GrantSystemToPublic(ISchemaObject obj, Right right) { this.PublicRole.Grant(obj.GetName(), right, SystemAuthorisation, true); }