public override int GetHashCode() { int hashcode = 157; unchecked { if (isset.objectName) { hashcode = (hashcode * 397) + ObjectName.GetHashCode(); } if (isset.objectType) { hashcode = (hashcode * 397) + ObjectType.GetHashCode(); } if (isset.privs) { hashcode = (hashcode * 397) + TCollections.GetHashCode(Privs); } if (isset.grantee) { hashcode = (hashcode * 397) + Grantee.GetHashCode(); } if (isset.privilegeObjectType) { hashcode = (hashcode * 397) + PrivilegeObjectType.GetHashCode(); } } return(hashcode); }
internal string ToXML() { StringBuilder sb = new StringBuilder(1024); sb.Append("<Grant>"); if (Grantee.IsSetCanonicalUser()) { sb.Append("<Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\">"); sb.Append("<ID>").Append(SecurityElement.Escape(this.Grantee.CanonicalUser.First)).Append("</ID>"); sb.Append("<DisplayName>").Append(SecurityElement.Escape(this.Grantee.CanonicalUser.Second)).Append("</DisplayName>"); sb.Append("</Grantee>"); sb.Append("<Permission>").Append(this.Permission).Append("</Permission>"); } else if (this.Grantee.IsSetEmailAddress()) { sb.Append("<Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"AmazonCustomerByEmail\">"); sb.Append("<EmailAddress>").Append(SecurityElement.Escape(this.Grantee.EmailAddress)).Append("</EmailAddress>"); sb.Append("</Grantee>"); sb.Append("<Permission>").Append(this.Permission).Append("</Permission>"); } else if (this.Grantee.IsSetURI()) { sb.Append("<Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"Group\">"); sb.Append("<URI>").Append(SecurityElement.Escape(this.Grantee.URI)).Append("</URI>"); sb.Append("</Grantee>"); sb.Append("<Permission>").Append(this.Permission).Append("</Permission>"); } sb.Append("</Grant>"); return(sb.ToString()); }
private static String convertGrantee(Grantee grantee) { if (grantee.GetType().Equals(typeof(CanonicalGrantee))) return convertCanonicalGrantee((CanonicalGrantee)grantee); else if (grantee.GetType().Equals(typeof(GroupGrantee))) return convertGroupGrantee((GroupGrantee)grantee); return null; }
public async Task Update(Grantee grantee) { int rowsAffected = await _granteeRepository.Update(grantee); if (rowsAffected == 0) { throw new EntityNotFoundException(grantee.Id, typeof(Grantee)); } }
/// <summary> /// Grant permissions to a user or user group (grantee). /// </summary> /// <param name="grantee"> Grantee name </param> /// <param name="permission">Permission information</param> public void AddGrant(Grantee grantee, PermissionEnum permission) { Grant grant = new Grant { }; grant.Grantee = grantee; grant.Permission = permission; Grants.Add(grant); }
/** * Revokes the permissions of a grantee by removing the grantee from the access control list (ACL). */ public void revokeAllPermissions(Grantee grantee) { IList<Grant> grantsToRemove = new List<Grant>(); foreach (Grant grant in grants) if (grant.getGrantee().Equals(grantee)) grantsToRemove.Add(grant); foreach (Grant grant in grantsToRemove) grants.Remove(grant); }
/// <summary> /// Remove permissions from a grantee. /// </summary> /// <param name="grantee"> Grantee name </param> /// <param name="permission">Permission information</param> public void RemoveGrant(Grantee grantee, PermissionEnum permission) { foreach (Grant grant in Grants) { if (grant.Grantee.Equals(grantee) && grant.Permission == permission) { Grants.Remove(grant); break; } } }
public async Task <int> Update(Grantee grantee) { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@Id", grantee.Id, DbType.Guid); parameters.Add("@Name", grantee.Name); int rowsAffected = await ExecuteAsync(StoredProcedures.Grantee.Update, parameters); return(rowsAffected); }
private static void DropRole(Session session, QNameManager.QName name, bool cascade) { Grantee role = session.database.GetGranteeManager().GetRole(name.Name); if (!cascade && session.database.schemaManager.HasSchemas(role)) { Schema schema = session.database.schemaManager.GetSchemas(role)[0]; throw Error.GetError(0x157e, schema.GetName().StatementName); } session.database.schemaManager.DropSchemas(session, role, cascade); session.database.GetGranteeManager().DropRole(name.Name); }
private static String convertGrantee(Grantee grantee) { if (grantee.GetType().Equals(typeof(CanonicalGrantee))) { return(convertCanonicalGrantee((CanonicalGrantee)grantee)); } else if (grantee.GetType().Equals(typeof(GroupGrantee))) { return(convertGroupGrantee((GroupGrantee)grantee)); } return(null); }
private void ProcessCreateUser(Session session) { QNameManager.QName name = (QNameManager.QName) this.Arguments[0]; string password = (string)this.Arguments[1]; Grantee grantor = (Grantee)this.Arguments[2]; session.CheckAdmin(); session.CheckDdlWrite(); session.database.GetUserManager().CreateUser(name, password); if (Convert.ToBoolean(this.Arguments[3], CultureInfo.CurrentCulture)) { session.database.GetGranteeManager().Grant(name.Name, "DBA", grantor); } }
public void Handle(ICommandContext context, CreateGranteeCommand command) { var grantee = new Grantee(GuidUtil.NewSequentialId(), command.Publisher, new GranteeInfo( command.Section, command.Title, command.Description, command.Max, command.Days, DateTime.Now.AddDays(command.Days), command.Pics )); context.Add(grantee); }
public async Task <Grantee> Create(Grantee grantee) { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@Id", grantee.Id, DbType.Int64, ParameterDirection.Output); parameters.Add("@Name", grantee.Name); parameters.Add("@UserId", grantee.UserId); await ExecuteAsync(StoredProcedures.Grantee.Create, parameters); grantee.Id = parameters.Get <long>("@Id"); return(grantee); }
public HttpResponseMessage NewGrantee([FromBody] Grantee data) { SLW_DatabaseInfo db = new SLW_DatabaseInfo(); try { Grantee grantee = db.NewLocalGrantee(data); return(Request.CreateResponse(HttpStatusCode.OK, grantee)); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "something went wrong")); } }
internal void Marshall(string memberName, XmlWriter xmlWriter) { xmlWriter.WriteStartElement(memberName); { if (Grantee != null) { xmlWriter.WriteStartElement("Grantee"); if (Grantee.IsSetType()) { xmlWriter.WriteAttributeString("xsi", "type", "http://www.w3.org/2001/XMLSchema-instance", Grantee.Type.ToString()); } if (Grantee.IsSetDisplayName()) { xmlWriter.WriteElementString("DisplayName", S3Transforms.ToXmlStringValue( Grantee.DisplayName)); } if (Grantee.IsSetEmailAddress()) { xmlWriter.WriteElementString("EmailAddress", S3Transforms.ToXmlStringValue( Grantee.EmailAddress)); } if (Grantee.IsSetCanonicalUser()) { xmlWriter.WriteElementString("ID", S3Transforms.ToXmlStringValue( Grantee.CanonicalUser)); } if (Grantee.IsSetURI()) { xmlWriter.WriteElementString("URI", S3Transforms.ToXmlStringValue( Grantee.URI)); } xmlWriter.WriteEndElement(); } if (IsSetPermission()) { xmlWriter.WriteElementString("Permission", S3Transforms.ToXmlStringValue( Permission)); } } xmlWriter.WriteEndElement(); }
private void ProcessCreateSchema(Session session, SchemaManager schemaManager) { QNameManager.QName name = (QNameManager.QName) this.Arguments[0]; Grantee owner = (Grantee)this.Arguments[1]; session.CheckDdlWrite(); if (!schemaManager.SchemaExists(name.Name)) { schemaManager.CreateSchema(name, owner); base.Sql = schemaManager.FindSchema(name.Name).GetSql(); } else if (!session.IsProcessingScript() || !"PUBLIC".Equals(name.Name)) { throw Error.GetError(0x1580, name.Name); } }
/// <summary> /// Remove all permissions from a grantee. /// </summary> /// <param name="grantee"> Grantee name </param> public void RemoveGrant(Grantee grantee) { IList <Grant> removeList = new List <Grant>(); foreach (Grant grant in Grants) { if (grant.Grantee.Equals(grantee)) { removeList.Add(grant); } } foreach (Grant grant in removeList) { this.Grants.Remove(grant); } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Grantee = await _context.Grantee .Include(g => g.City).FirstOrDefaultAsync(m => m.Id == id); if (Grantee == null) { return(NotFound()); } return(Page()); }
private static void DropUser(Session session, QNameManager.QName name, bool cascade) { Grantee grantee = session.database.GetUserManager().Get(name.Name); if (session.database.GetSessionManager().IsUserActive(name.Name)) { throw Error.GetError(0x15a3); } if (!cascade && session.database.schemaManager.HasSchemas(grantee)) { Schema schema = session.database.schemaManager.GetSchemas(grantee)[0]; throw Error.GetError(0x157e, schema.GetName().StatementName); } session.database.schemaManager.DropSchemas(session, grantee, cascade); session.database.GetUserManager().DropUser(name.Name); }
/** * Revokes the permissions of a grantee by removing the grantee from the access control list (ACL). */ public void revokeAllPermissions(Grantee grantee) { IList <Grant> grantsToRemove = new List <Grant>(); foreach (Grant grant in grants) { if (grant.getGrantee().Equals(grantee)) { grantsToRemove.Add(grant); } } foreach (Grant grant in grantsToRemove) { grants.Remove(grant); } }
public List <Grantee> GranteeSystemPrivileges(string privilege, bool isAdmin) { List <Grantee> result = new List <Grantee>(); DataSet dataSet = this.systemPrivilegeRepository.Grantee(privilege.ToUpper(), BooleanUtils.FromBoolean(isAdmin)); DataTable table = dataSet.Tables[0]; for (int i = 0; i < table.Rows.Count; i++) { Grantee p = new Grantee { Name = table.Rows[i]["GRANTEE"].ToString(), IsAdmin = BooleanUtils.FromString(table.Rows[i]["ADMIN_OPTION"].ToString()) }; result.Add(p); } return(result); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Grantee = await _context.Grantee.FindAsync(id); if (Grantee != null) { _context.Grantee.Remove(Grantee); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj is Grant other) { if (Permission.Equals(other.Permission) && Grantee.Equals(other.Grantee)) { return(true); } } return(false); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Grantee = await _context.Grantee .Include(g => g.City).FirstOrDefaultAsync(m => m.Id == id); if (Grantee == null) { return(NotFound()); } ViewData["CityId"] = new SelectList(_context.City, "Id", "Name"); return(Page()); }
public Schema(QNameManager.QName name, Grantee owner) { this.Name = name; this.TriggerLookup = new SchemaObjectSet(8); this.IndexLookup = new SchemaObjectSet(20); this.ConstraintLookup = new SchemaObjectSet(5); this.TableLookup = new SchemaObjectSet(3); this.SequenceLookup = new SchemaObjectSet(7); this.TypeLookup = new SchemaObjectSet(12); this.CharsetLookup = new SchemaObjectSet(14); this.CollationLookup = new SchemaObjectSet(15); this.ProcedureLookup = new SchemaObjectSet(0x11); this.FunctionLookup = new SchemaObjectSet(0x10); this.AggregateLookup = new SchemaObjectSet(0x1b); this.SpecificRoutineLookup = new SchemaObjectSet(0x18); this.AssertionLookup = new SchemaObjectSet(6); this.TableList = (HashMappedList <string, object>) this.TableLookup.Map; this.SequenceList = (HashMappedList <string, object>) this.SequenceLookup.Map; this.Owner = owner; name.Owner = owner; }
public void TestInitialize() { this.bucketName = (BucketPrefix + new Random().Next().ToString("X")).ToLower(); this.owner = new User() { Id = this.userId, DisplayName = "PASSPORT:105015426" }; this.grantee = new Grantee() { Id = this.userId }; this.anonymous = new Grantee() { Id = "*" }; this.config = new BceClientConfiguration(); this.config.Credentials = new DefaultBceCredentials(this.ak, this.sk); this.config.Endpoint = this.endpoint; this.client = new BosClient(this.config); this.client.CreateBucket(this.bucketName); }
private void buttonAdd_Click(object sender, EventArgs e) { using (var form = new SecurityAddForm()) { if (form.ShowDialog() == DialogResult.OK) { var grantee = new Grantee(form.UserEmailOrId.Contains('@') ? GranteeType.Email : GranteeType.User, form.UserEmailOrId); foreach (DataGridViewRow row in dataGridViewACL.Rows) { if (grantee.Equals(row.Cells[1].Value)) { row.Selected = true; return; } } accessControlList.AddGrant(grantee, Permission.Default); SetACL(accessControlList); dataGridViewACL.Rows[dataGridViewACL.RowCount - 1].Selected = true; OnACLChanged(); } } }
private void ProcessGrantRevokeRole(Session session) { bool grant = base.type == 0x31; OrderedHashSet <string> granteeList = (OrderedHashSet <string>) this.Arguments[0]; OrderedHashSet <string> roleList = (OrderedHashSet <string>) this.Arguments[1]; Grantee grantor = (Grantee)this.Arguments[2]; GranteeManager granteeManager = session.database.granteeManager; granteeManager.CheckGranteeList(granteeList); for (int i = 0; i < granteeList.Size(); i++) { string granteeName = granteeList.Get(i); granteeManager.CheckRoleList(granteeName, roleList, grantor, grant); } if (grant) { for (int j = 0; j < granteeList.Size(); j++) { string granteeName = granteeList.Get(j); for (int k = 0; k < roleList.Size(); k++) { string roleName = roleList.Get(k); granteeManager.Grant(granteeName, roleName, grantor); } } } else { for (int j = 0; j < granteeList.Size(); j++) { string granteeName = granteeList.Get(j); for (int k = 0; k < roleList.Size(); k++) { granteeManager.Revoke(granteeName, roleList.Get(k), grantor); } } } }
/** * Adds a grantee to the access control list (ACL) with the given permission. * If this access control list already * contains the grantee (i.e. the same grantee object) the permission for the * grantee will be updated. */ public void grantPermission(Grantee grantee, String permission) { this.grants.Add(new Grant(grantee, permission)); }
private void readAcl( Acl acl, string header, EsuApiLib.Grantee.GRANTEE_TYPE type ) { log.TraceEvent(TraceEventType.Verbose, 0, "readAcl: " + header ); string[] grants = header.Split( new string[] { "," }, StringSplitOptions.RemoveEmptyEntries ); for( int i = 0; i < grants.Length; i++ ) { string[] nvpair = grants[i].Split( new string[] { "=" }, 2, StringSplitOptions.RemoveEmptyEntries ); string grantee = nvpair[0]; string permission = nvpair[1]; grantee = grantee.Trim(); // Currently, the server returns "FULL" instead of "FULL_CONTROL". // For consistency, change this to value use in the request if( "FULL".Equals( permission ) ) { permission = Permission.FULL_CONTROL; } log.TraceEvent(TraceEventType.Verbose, 0, "grant: " + grantee + "." + permission + " (" + type + ")" ); Grantee ge = new Grantee( grantee, type ); Grant gr = new Grant( ge, permission ); log.TraceEvent(TraceEventType.Verbose, 0, "Grant: " + gr ); acl.AddGrant( gr ); } }
/** * Constructs a new Grant object using the specified grantee and * permission objects. */ public Grant(Grantee grantee, String permission) { this.grantee = grantee; this.permission = permission; }
public async Task <long> Create(Grantee grantee) { await _granteeRepository.Create(grantee); return(grantee.Id); }
public AccessControlList unmarshall(Stream inputStream) { AccessControlList acl = new AccessControlList(); Owner owner = null; String ownerId = null; String ownerDisplayName = null; Grantee grantee = null; String granteeType = null; String userId = null; String userDisplayName = null; String groupUri = null; String permission = null; bool insideGrant = false; StringBuilder currText = new StringBuilder(); XmlReader xr = XmlReader.Create(new BufferedStream(inputStream)); while (xr.Read()) { if (xr.NodeType.Equals(XmlNodeType.Element)) { if (xr.Name.Equals("Grant")) { insideGrant = true; } else if (xr.Name.Equals("Grantee")) { granteeType = xr.GetAttribute("xsi:type"); } } else if (xr.NodeType.Equals(XmlNodeType.EndElement)) { if (xr.Name.Equals("DisplayName")) { if (!insideGrant) { ownerId = currText.ToString(); } else { userId = currText.ToString(); } } else if (xr.Name.Equals("ID")) { if (!insideGrant) { ownerDisplayName = currText.ToString(); } else { userDisplayName = currText.ToString(); } } else if (xr.Name.Equals("URI")) { groupUri = currText.ToString(); } else if (xr.Name.Equals("Owner")) { owner = new Owner(ownerId, ownerDisplayName); acl.setOwner(owner); } else if (xr.Name.Equals("Grantee")) { if (granteeType.Equals("CanonicalUser")) { grantee = new CanonicalGrantee(userId, userDisplayName); } else if (granteeType.Equals("Group")) { grantee = new GroupGrantee(groupUri); } } else if (xr.Name.Equals("Permission")) { permission = currText.ToString(); } else if (xr.Name.Equals("Grant")) { acl.grantPermission(grantee, permission); insideGrant = false; } currText.Clear(); } else if (xr.NodeType.Equals(XmlNodeType.Text)) { currText.Append(xr.Value); } } // end while return(acl); } // end of unmarshall