コード例 #1
0
ファイル: TDBObject.cs プロジェクト: trmcnealy/Apache.Thrift
        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);
        }
コード例 #2
0
ファイル: S3Grant.cs プロジェクト: nschnarr/awssdk
        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());
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        public async Task Update(Grantee grantee)
        {
            int rowsAffected = await _granteeRepository.Update(grantee);

            if (rowsAffected == 0)
            {
                throw new EntityNotFoundException(grantee.Id, typeof(Grantee));
            }
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /**
         * 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);
        }
コード例 #7
0
 /// <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;
         }
     }
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: AclXmlFactory.cs プロジェクト: jflzbest/C-
        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);
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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"));
            }
        }
コード例 #15
0
ファイル: S3Grant.cs プロジェクト: subhadlearner/aws-sdk-net
        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();
        }
コード例 #16
0
        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);
            }
        }
コード例 #17
0
        /// <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);
            }
        }
コード例 #18
0
        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());
        }
コード例 #19
0
        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);
        }
コード例 #20
0
ファイル: AccessControlList.cs プロジェクト: jflzbest/C-
        /**
         * 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);
            }
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        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"));
        }
コード例 #23
0
ファイル: Grant.cs プロジェクト: cocosip/ks3sdk-csharp
        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);
        }
コード例 #24
0
        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());
        }
コード例 #25
0
ファイル: Schema.cs プロジェクト: cwdotson/FwNs
 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;
 }
コード例 #26
0
 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);
 }
コード例 #27
0
ファイル: SecurityEditor.cs プロジェクト: windygu/ntlxproject
 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();
         }
     }
 }
コード例 #28
0
        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);
                    }
                }
            }
        }
コード例 #29
0
 /**
  * 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));
 }
コード例 #30
0
ファイル: EsuRestApi.cs プロジェクト: EMCECS/atmos-dotnet
        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 );
            }
        }
コード例 #31
0
 /**
  * Constructs a new Grant object using the specified grantee and
  * permission objects.
  */
 public Grant(Grantee grantee, String permission)
 {
     this.grantee    = grantee;
     this.permission = permission;
 }
コード例 #32
0
        public async Task <long> Create(Grantee grantee)
        {
            await _granteeRepository.Create(grantee);

            return(grantee.Id);
        }
コード例 #33
0
ファイル: AccessControlList.cs プロジェクト: jflzbest/C-
 /**
  * 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));
 }
コード例 #34
0
        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
コード例 #35
0
ファイル: Grant.cs プロジェクト: ks3sdklib/ks3sdk-csharp
 /**
  * Constructs a new Grant object using the specified grantee and
  * permission objects.
  */
 public Grant(Grantee grantee, String permission)
 {
     this.grantee = grantee;
     this.permission = permission;
 }