Permissions.cs :  » Build-Systems » CruiseControl.NET » ThoughtWorks » CruiseControl » Core » Security » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Build Systems » CruiseControl.NET 
CruiseControl.NET » ThoughtWorks » CruiseControl » Core » Security » Permissions.cs
using System;
using System.Collections.Generic;
using System.Text;
using ThoughtWorks.CruiseControl.Remote.Security;
using Exortech.NetReflector;
using System.ComponentModel;

namespace ThoughtWorks.CruiseControl.Core.Security{
    /// <summary>
    /// Defines a set of permissions.
    /// </summary>
    /// <title>General Security Permissions</title>
    [ReflectorType("permissions")]
    public class Permissions
    {
        #region Private fields
        private SecurityRight defaultRight = SecurityRight.Inherit;
        private SecurityRight sendMessage = SecurityRight.Inherit;
        private SecurityRight forceAbortBuild = SecurityRight.Inherit;
        private SecurityRight startStopProject = SecurityRight.Inherit;
        private SecurityRight changeProjectConfiguration = SecurityRight.Inherit;
        private SecurityRight viewSecurity = SecurityRight.Inherit;
        private SecurityRight modifySecurity = SecurityRight.Inherit;
        private SecurityRight viewProject = SecurityRight.Inherit;
        private SecurityRight viewConfiguration = SecurityRight.Inherit;
        #endregion

        #region Public properties
        #region DefaultRight
        /// <summary>
        /// The default right to use.
        /// </summary>
        /// <version>1.5</version>
        /// <default>Inherit</default>
        [ReflectorProperty("defaultRight", Required = false)]
        [DefaultValue(SecurityRight.Inherit)]
        public SecurityRight DefaultRight
        {
            get { return defaultRight; }
            set { defaultRight = value; }
        }
        #endregion

        #region SendMessageRight
        /// <summary>
        /// The right to send messages.
        /// </summary>
        /// <version>1.5</version>
        /// <default>Inherit</default>
        [ReflectorProperty("sendMessage", Required = false)]
        [DefaultValue(SecurityRight.Inherit)]
        public SecurityRight SendMessageRight
        {
            get { return sendMessage; }
            set { sendMessage = value; }
        }
        #endregion

        #region ForceBuildRight
        /// <summary>
        /// The right for force or abort builds.
        /// </summary>
        /// <version>1.5</version>
        /// <default>Inherit</default>
        [ReflectorProperty("forceBuild", Required = false)]
        [DefaultValue(SecurityRight.Inherit)]
        public SecurityRight ForceBuildRight
        {
            get { return forceAbortBuild; }
            set { forceAbortBuild = value; }
        }
        #endregion

        #region StartProjectRight
        /// <summary>
        /// The right to stop and start projects.
        /// </summary>
        /// <version>1.5</version>
        /// <default>Inherit</default>
        [ReflectorProperty("startProject", Required = false)]
        [DefaultValue(SecurityRight.Inherit)]
        public SecurityRight StartProjectRight
        {
            get { return startStopProject; }
            set { startStopProject = value; }
        }
        #endregion

        #region ChangeProjectRight
        /// <summary>
        /// The right to change the configuration of projects.
        /// </summary>
        /// <version>1.5</version>
        /// <default>Inherit</default>
        [ReflectorProperty("changeProject", Required = false)]
        [DefaultValue(SecurityRight.Inherit)]
        public SecurityRight ChangeProjectRight
        {
            get { return changeProjectConfiguration; }
            set { changeProjectConfiguration = value; }
        }
        #endregion

        #region ViewSecurityRight
        /// <summary>
        /// The right to view security.
        /// </summary>
        /// <version>1.5</version>
        /// <default>Inherit</default>
        [ReflectorProperty("viewSecurity", Required = false)]
        [DefaultValue(SecurityRight.Inherit)]
        public SecurityRight ViewSecurityRight
        {
            get { return viewSecurity; }
            set { viewSecurity = value; }
        }
        #endregion

        #region ModifySecurityRight
        /// <summary>
        /// The right to modify security.
        /// </summary>
        /// <version>1.5</version>
        /// <default>Inherit</default>
        [ReflectorProperty("modifySecurity", Required = false)]
        [DefaultValue(SecurityRight.Inherit)]
        public SecurityRight ModifySecurityRight
        {
            get { return modifySecurity; }
            set { modifySecurity = value; }
        }
        #endregion

        #region ViewProjectRight
        /// <summary>
        /// The right to view a project.
        /// </summary>
        /// <version>1.5</version>
        /// <default>Inherit</default>
        [ReflectorProperty("viewProject", Required = false)]
        [DefaultValue(SecurityRight.Inherit)]
        public SecurityRight ViewProjectRight
        {
            get { return viewProject; }
            set { viewProject = value; }
        }
        #endregion

        #region ViewConfigurationRight
        /// <summary>
        /// The right to view configuration and logs.
        /// </summary>
        /// <version>1.5</version>
        /// <default>Inherit</default>
        [ReflectorProperty("viewConfiguration", Required = false)]
        [DefaultValue(SecurityRight.Inherit)]
        public SecurityRight ViewConfigurationRight
        {
            get { return viewConfiguration; }
            set { viewConfiguration = value; }
        }
        #endregion
        #endregion

        #region Public methods
        #region GetPermission()
        /// <summary>
        /// Retrieves the actual permission.
        /// </summary>
        /// <param name="permission"></param>
        /// <returns></returns>
        public SecurityRight GetPermission(SecurityPermission permission)
        {
            var right = SecurityRight.Inherit;
            switch (permission)
            {
                case SecurityPermission.ViewProject:
                    right = ViewProjectRight;
                    break;
                case SecurityPermission.ViewConfiguration:
                    right = ViewConfigurationRight;
                    break;
                case SecurityPermission.ForceAbortBuild:
                    right = ForceBuildRight;
                    break;
                case SecurityPermission.SendMessage:
                    right = SendMessageRight;
                    break;
                case SecurityPermission.StartStopProject:
                    right = StartProjectRight;
                    break;
                case SecurityPermission.ChangeProjectConfiguration:
                    right = ChangeProjectRight;
                    break;
                case SecurityPermission.ViewSecurity:
                    right = ViewSecurityRight;
                    break;
                case SecurityPermission.ModifySecurity:
                    right = ModifySecurityRight;
                    break;
            }
            if (right == SecurityRight.Inherit) right = DefaultRight;
            return right;
        }
        #endregion
        #endregion
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.