Ejemplo n.º 1
0
    public void SetPermissions_Accesscontrollist()
    {
        // <snippet26>

        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // Create an AccessControlList.
        AccessControlList list = new AccessControlList();

        // Create a new trustee to represent the "Everyone" user group.
        Trustee tr = new Trustee("Everyone");

        // Create an AccessControlEntry, granting the trustee read access to
        // the queue.
        AccessControlEntry entry = new AccessControlEntry(
            tr, GenericAccessRights.Read,
            StandardAccessRights.Read,
            AccessControlEntryType.Allow);

        // Add the AccessControlEntry to the AccessControlList.
        list.Add(entry);

        // Apply the AccessControlList to the queue.
        queue.SetPermissions(list);

        // </snippet26>
    }
        /// <summary>
        ///  Create the transacted MSMQ queue if necessary.
        /// </summary>
        /// <param name="queuePath"></param>
        void CreateQueue(string queuePath)
        {
            try
            {
                if (!MessageQueue.Exists(queuePath))
                {
                    MessageQueue.Create(queuePath, true);

                    // Create a new trustee to represent the "system" user group.
                    Trustee tr = new Trustee("SYSTEM");
                    MessageQueueAccessControlEntry entry = new MessageQueueAccessControlEntry(tr, MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow);
                    // Apply the MessageQueueAccessControlEntry to the queue.
                    SysEventQueue.SetPermissions(entry);

                    if (!string.IsNullOrEmpty(Properties.Settings.Default.AdministratorGroupName))
                    {
                        tr    = new Trustee(Properties.Settings.Default.AdministratorGroupName);
                        entry = new MessageQueueAccessControlEntry(tr, MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow);
                        SysEventQueue.SetPermissions(entry);
                    }
                }
            }
            catch (MessageQueueException ex)
            {
                ReceivedInfoProc.LogError(ex);
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("FirstName,LastName,Address,Phone,Email,IsDeleted,DeletedOn,Id,CreatedOn,ModifiedOn")] Trustee trustee)
        {
            if (id != trustee.Id)
            {
                return(this.NotFound());
            }

            if (this.ModelState.IsValid)
            {
                try
                {
                    await this.trusteesService.EditTrustee(trustee);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await this.TrusteeExists(trustee.Id))
                    {
                        return(this.NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(this.RedirectToAction(nameof(this.Index)));
            }

            return(this.View(trustee));
        }
Ejemplo n.º 4
0
        public override double CalculateTrust(Agent trustor, Trustee trustee, TrustAction action)
        {
            var            actionFeatures = action.WeightedFeatures;
            List <Feature> looseFeatures  = new List <Feature>();

            double result = 0;

            foreach (Feature feature in trustee.Features)
            {
                if (actionFeatures.Any(x => x.Key.Resource.Equals(feature.FeatureID.Resource)))
                {
                    var weight = actionFeatures.First(x => x.Key.Resource.Equals(feature.FeatureID.Resource)).Value;
                    result += weight * feature.BeliefValue;
                }
                else
                {
                    looseFeatures.Add(feature);
                }
            }

            result *= 0.9d;

            foreach (Feature looseFeature in looseFeatures)
            {
                result += (looseFeature.BeliefValue / looseFeatures.Count) * 0.1;
            }

            return(result);
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("FirstName,LastName,Address,Phone,Email,IsDeleted,DeletedOn,Id,CreatedOn,ModifiedOn")] Trustee trustee)
        {
            if (this.ModelState.IsValid)
            {
                await this.trusteesService.AddTrusteeAsync(trustee);

                return(this.RedirectToAction(nameof(this.Index)));
            }

            return(this.View(trustee));
        }
Ejemplo n.º 6
0
        public void Trustee_Operator_ConvertsCharityTrustee()
        {
            var charityTrustee = new CharityTrustee
            {
                TrusteeId = 123,
                Name      = Guid.NewGuid().ToString()
            };

            Trustee trustee = charityTrustee;

            Assert.AreEqual(charityTrustee.TrusteeId.ToString(), trustee.Id);
            Assert.AreEqual(charityTrustee.Name, trustee.Name);
        }
Ejemplo n.º 7
0
		public void LoadAndPopulateAuthors()
		{
			cbAutor.Items.Clear();
			LoadAuthors();

			ArrayList tAuthors = Trustee.GetAvailableAuthors(true);
			cbAutor.DisplayMember = "Name";

			GISADataset.TrusteeRow emptyTRow = GisaDataSetHelper.GetInstance().Trustee.NewTrusteeRow();
			emptyTRow.Name = "";
			cbAutor.Items.Add(emptyTRow);
			cbAutor.Items.AddRange(tAuthors.ToArray());
		}
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes Mqueue instance to exchange messages
        /// </summary>
        /// <param name="label">Label associated to the queue</param>
        /// <returns>an instance of a Mqueue</returns>
        private MessageQueue InitMqueue(string queue, string label)
        {
            _readerWriteLockSlim.EnterWriteLock();
            try
            {
                if (MessageQueue.Exists(queue) == false)
                {
                    _log.Info(string.Format("{0} ==> ERROR: No existe la Cola [{1}], se procede a crearla", MethodBase.GetCurrentMethod().Name, queue));

                    // Si no existe crea la cola de comunicacion
                    MessageQueue.Create(queue);
                }

                // Abre la cola de comunicacion
                _adquisitionQueue = new MessageQueue(queue);

                // Create a new trustee to represent the "Everyone" user group.
                SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null);

                var     account = (NTAccount)everyone.Translate(typeof(NTAccount));
                Trustee tr      = new Trustee(account.Value);

                // Create a MessageQueueAccessControlEntry, granting the trustee the right to receive messages from the queue.
                MessageQueueAccessControlEntry entry = new MessageQueueAccessControlEntry(tr, MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow);

                // Apply the MessageQueueAccessControlEntry to the queue.
                _adquisitionQueue.SetPermissions(entry);

                _adquisitionQueue.Label = string.Format("POINTS - {0}", label);
                _adquisitionQueue.DefaultPropertiesToSend.TimeToReachQueue = new TimeSpan(0, 0, 1); // Timeout 1 segundo

                if (_adquisitionQueue != null)
                {
                    Point         point    = new Point();
                    Object        o        = new Object();
                    System.Type[] arrTypes = new System.Type[2];

                    arrTypes[0] = point.GetType();
                    arrTypes[1] = o.GetType();

                    _adquisitionQueue.Formatter = new XmlMessageFormatter(arrTypes);
                }

                return(_adquisitionQueue);
            }
            finally
            {
                _readerWriteLockSlim.ExitWriteLock();
            }
        }
Ejemplo n.º 9
0
    public void SetPermissions_Accesscontrolentry()
    {
        // <snippet24>

        // Connect to a queue on the local computer.
        MessageQueue queue = new MessageQueue(".\\exampleQueue");

        // Create a new trustee to represent the "Everyone" user group.
        Trustee tr = new Trustee("Everyone");

        // Create a MessageQueueAccessControlEntry, granting the trustee the
        // right to receive messages from the queue.
        MessageQueueAccessControlEntry entry = new
                                               MessageQueueAccessControlEntry(
            tr, MessageQueueAccessRights.ReceiveMessage,
            AccessControlEntryType.Allow);

        // Apply the MessageQueueAccessControlEntry to the queue.
        queue.SetPermissions(entry);

        // </snippet24>
    }
Ejemplo n.º 10
0
        public void TestExpandAccessStructure()
        {
            Trustee p1, p2, p3, p4;

            p1 = new Trustee(1);
            p2 = new Trustee(2);
            p3 = new Trustee(3);
            p4 = new Trustee(4);

            QualifiedSubset qs1, qs2, qs3;

            qs1 = new QualifiedSubset();
            qs1.Parties.Add(p2);
            qs1.Parties.Add(p3);

            qs2 = new QualifiedSubset();
            qs2.Parties.Add(p1);
            qs2.Parties.Add(p2);
            qs2.Parties.Add(p4);

            qs3 = new QualifiedSubset();
            qs3.Parties.Add(p1);
            qs3.Parties.Add(p3);
            qs3.Parties.Add(p4);

            AccessStructure access = new AccessStructure();

            access.Accesses.Add(qs1);
            access.Accesses.Add(qs2);
            access.Accesses.Add(qs3);

            List <Trustee> trustees = new List <Trustee>()
            {
                p1, p2, p3
            };

            ExpandAllAccessPaths(trustees);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// LOCAL ONLY - Creates a new MessageQueue if none exists, or returns existing MessageQueue
        /// </summary>
        /// <param name="messageQueueName"></param>
        /// <param name="privateQueue"></param>
        /// <returns></returns>
        public static MessageQueue CreateMessageQueue(string messageQueueName, bool privateQueue = true)
        {
            AccessControlList  acl   = new AccessControlList();
            Trustee            tr    = new Trustee("ANONYMOUS LOGON");
            AccessControlEntry entry = new AccessControlEntry(tr, GenericAccessRights.All, StandardAccessRights.All, AccessControlEntryType.Allow);

            acl.Add(entry);


            if (privateQueue)
            {
                if (!MessageQueue.Exists(".\\private$\\" + messageQueueName))
                {
                    // Create the queue if it does not exist.
                    MessageQueue myMQ = MessageQueue.Create(".\\private$\\" + messageQueueName);
                    myMQ.SetPermissions(acl);
                    return(myMQ);
                }
                else
                {
                    return(new MessageQueue(".\\private$\\" + messageQueueName));
                }
            }
            else
            {
                if (!MessageQueue.Exists(".\\" + messageQueueName))
                {
                    // Create the queue if it does not exist.
                    MessageQueue myMQ = MessageQueue.Create(".\\" + messageQueueName);
                    myMQ.SetPermissions(acl);
                    return(myMQ);
                }
                else
                {
                    return(new MessageQueue(".\\" + messageQueueName));
                }
            }
        }
Ejemplo n.º 12
0
        private void button2_Click(object sender, EventArgs e)
        {
            txtResponse.Text = "";
            //string queuePath = "FormatName:Direct=TCP:192.168.102.188\\private$\\queue";//@".\private$\lxf";
            //List<string> sMessage = QueueManger.GetAllMessage<string>(queuePath);
            //string sMessage = QueueManger.ReceiveMessage<string>(queuePath);
            //txtResponse.Text = sMessage;

            try
            {
                string       queuePath = txtURL.Text.Trim();
                MessageQueue mQueue    = new MessageQueue(queuePath, QueueAccessMode.ReceiveAndAdmin);
                mQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });
                Trustee trustee = new Trustee();
                //trustee.TrusteeType = TrusteeType.Group;
                //MessageQueuePermission mp = new MessageQueuePermission(MessageQueuePermissionAccess.Receive, queuePath);
                System.Messaging.Message msg = mQueue.Peek();
                txtResponse.Text = msg.Body.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 13
0
        static void MSMQTest()
        {
            MessageQueue mq;
            string       path = ".\\private$\\td365_offcommitdata_" + type;

            if (MessageQueue.Exists(path))
            {
                mq = new MessageQueue(path);
            }
            else
            {
                mq = MessageQueue.Create(path);
            }
            mq.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });

            Trustee tr = new Trustee("Everyone");
            MessageQueueAccessControlEntry entry = new MessageQueueAccessControlEntry(
                tr, MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow
                );

            mq.SetPermissions(entry);

            mq.Send("test");
        }
Ejemplo n.º 14
0
 static internal extern uint GetEffectiveRightsFromAclW (byte[] pAcl, ref Trustee pTrustee, out uint pAccessMask);
	public AccessControlEntry(Trustee trustee) {}
	public AccessControlEntry(Trustee trustee, GenericAccessRights genericAccessRights, StandardAccessRights standardAccessRights, AccessControlEntryType entryType) {}
Ejemplo n.º 17
0
 static internal extern uint GetEffectiveRightsFromAclW(byte[] pAcl, ref Trustee pTrustee, out uint pAccessMask);
 public AccessControlEntry(Trustee trustee, GenericAccessRights genericAccessRights, StandardAccessRights standardAccessRights, AccessControlEntryType entryType)
 {
 }
Ejemplo n.º 19
0
 public abstract double CalculateTrust(Agent trustor, Trustee trustee, TrustAction action);
Ejemplo n.º 20
0
        public async Task HardDeleteTrustee(Trustee trustee)
        {
            this.trusteeRepository.Delete(trustee);

            await this.trusteeRepository.SaveChangesAsync();
        }
Ejemplo n.º 21
0
 public async Task EditTrustee(Trustee trustee)
 {
     this.trusteeRepository.Update(trustee);
     await this.trusteeRepository.SaveChangesAsync();
 }
Ejemplo n.º 22
0
        public async Task AddTrusteeAsync(Trustee trustee)
        {
            await this.trusteeRepository.AddAsync(trustee);

            await this.trusteeRepository.SaveChangesAsync();
        }
 public MessageQueueAccessControlEntry(Trustee trustee, MessageQueueAccessRights rights, AccessControlEntryType entryType)
 {
 }
 public AccessControlEntry(Trustee trustee)
 {
 }
Ejemplo n.º 25
0
		private void btnAccept_Click(object sender, System.EventArgs e)
		{

			// A 1ª instancia demora sempre mais tempo, é necessário carregar uma série de dados
			this.Cursor = Cursors.WaitCursor;
			GISADataset ds = GisaDataSetHelper.GetInstance();
			this.Cursor = Cursors.Arrow;

			if (ds == null)
			{
				MessageBox.Show("A base de dados não se encontra disponível, por favor " + Environment.NewLine + "contacte o administrador de sistema.", "Acesso à base de dados", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}

			frmMain main = null;
			try
			{
				string username = txtUser.Text.Replace("'", "''");
				string assemblyVersion = null;

                string modules = string.Empty;
                foreach(GISADataset.ModulesRow mRow in SessionHelper.AppConfiguration.GetCurrentAppconfiguration().Modules)
                {
                    modules += mRow.ID + ",";
                }
                modules = modules.TrimEnd(',');

                assemblyVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().FullName;
                
                // Validar utilizador
                TrusteeRule.IndexErrorMessages messageIndex = TrusteeRule.IndexErrorMessages.InvalidUser;

                // Carregar o utilizador 
				GISADataset.TrusteeUserRow tuRow = null;
				tuRow = LoadCurrentOperator(username);

                // LDAP Authentication
                string ldapServerName = SessionHelper.AppConfiguration.GetCurrentAppconfiguration().LDAPServerName;
                string ldapSettings = SessionHelper.AppConfiguration.GetCurrentAppconfiguration().LDAPServerSettings;

                if (ldapServerName != null && tuRow != null && tuRow.IsLDAPUser)
                {
                    LDAPHandler ldapH = new LDAPHandler(ldapServerName, ldapSettings, username, txtPassword.Text);
                    ldapH.ConnectToLDAP();

                    if (ldapH.IsLoggedIn)
                    {
                        messageIndex = 0;                        
                    }
                    else
                    {
                        messageIndex = TrusteeRule.IndexErrorMessages.InvalidUser;
                    }
                 
                }
                else
                {
                    messageIndex = Trustee.validateUser(username, CryptographyHelper.GetMD5(txtPassword.Text));
                }
				
				//verificar se ocorreu algum erro no processo de login
				if (messageIndex != 0)
				{
                    GUIHelper.GUIHelper.MessageBoxLoginErrorMessages(Convert.ToInt32(messageIndex));
					throw new LoginException();
				}
				
                // Adicionar o GisaPrincipal
                System.Threading.Thread.CurrentPrincipal = new GisaPrincipal(tuRow);
                                 
                if (SessionHelper.GetGisaPrincipal().TrusteePrivileges.Rows.Count == 0)
                {
                    GUIHelper.GUIHelper.MessageBoxLoginErrorMessages(Convert.ToInt32(DBAbstractDataLayer.DataAccessRules.TrusteeRule.IndexErrorMessages.UserWithoutPermissions));
                    throw new LoginException();
                }
                

				main = new frmMain(username);
			}
			catch (LoginException)
			{
				return;
			}
			catch (Exception ex)
			{
				Trace.WriteLine(ex);
				MessageBox.Show("Ocorreu um erro durante o processo de início da sessão, " + Environment.NewLine + "por favor contacte o administrador de sistema.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}
			this.Hide();
			main.ShowDialog();
			this.Close();
		}
	public MessageQueueAccessControlEntry(Trustee trustee, MessageQueueAccessRights rights, AccessControlEntryType entryType) {}