コード例 #1
0
        /// <summary>
        /// This instance is allowed to call only from test bed - todo security
        /// </summary>
        /// <param name="userName">The logged in user name</param>
        /// <param name="rbacName">The overridden rbac name, empty will use user's default</param>
        /// <param name="roleName">The overriden role name, empty will use user's default</param>
        public Rbac(string userName, string rbacName, string roleName)
        {
            //no cache will be implemented

            DataManager.Manager manager = new DataManager.Manager(false);
            RbacUser            user    = new RbacUser(userName);

            if (!string.IsNullOrEmpty(roleName))
            {
                user.Role = new RbacRole(roleName);  //override role
            }
            if (user.Role == null)
            {
                RbacException.Raise(string.Format("The role '{0}' is not found!", roleName), RbacExceptionCategories.Repository);
            }

            Rbac dbRbac = null;

            if (!string.IsNullOrEmpty(rbacName))
            {
                dbRbac = manager.GetRbac(rbacName);     //override rbac
            }
            else
            {
                dbRbac = manager.GetRbac(user.Role.RbacId);
            }

            if (dbRbac == null)
            {
                RbacException.Raise(string.Format("The rbac '{0}' was not defined yet!", rbacName), RbacExceptionCategories.Repository);
            }

            dbRbac.User = user;
            Assign(dbRbac);
        }
コード例 #2
0
 public RbacColumn(string name, RbacDataTypes dataType,
                   bool create = false, bool read = false, bool update = false)
 {
     this.Name     = name;
     this.DataType = dataType;
     //this.IsFilterColumn = isFilterColumn;
     this.AllowedOperations = Rbac.ParseOperations(create, read, update, false);
 }
コード例 #3
0
 public RbacSqlQueryEngine(Rbac context, string query, bool isDebugMode = false)
 {
     this.Errors = new List <string>();
     Parser      = new SqlQueryParser(context);
     Parser.Parse(query);
     IsDebugMode = isDebugMode;
     Parser.Context.Trace.WriteLine("Engine:{0}", this.GetType().Name);
 }
コード例 #4
0
ファイル: RbacEngineWeb.cs プロジェクト: karlosRivera/aarbac
 public RbacEngineWeb(Rbac rbac)
 {
     this.RbacId               = rbac.RbacId;
     this.Name                 = rbac.Name;
     this.Description          = rbac.Description;
     this.ConnectionString     = rbac.ConnectionString;
     this.MetaDataRbac         = rbac.MetaDataRbac;
     this.MetaDataEntitlements = rbac.MetaDataEntitlements;
 }
コード例 #5
0
 public void AddContext(string userName, Rbac context)
 {
     if (Contexts.ContainsKey(userName))
     {
         Contexts[userName] = context;
     }
     else
     {
         Contexts.Add(userName, context);
     }
 }
コード例 #6
0
        public static RbacEngineWeb Save(RbacEngineWeb rbacEngineWeb)
        {
            Rbac rbac = GetRbac(rbacEngineWeb.Name);

            rbac.Description          = rbacEngineWeb.Description;
            rbac.ConnectionString     = rbacEngineWeb.ConnectionString;
            rbac.MetaDataRbac         = rbacEngineWeb.MetaDataRbac;
            rbac.MetaDataEntitlements = rbacEngineWeb.MetaDataEntitlements;
            rbac = new DataManager.Manager().AddOrUpdate(rbac);
            return(rbacEngineWeb);
        }
コード例 #7
0
 public RbacTable(string objectId, string name,
                  string create = "False", string read = "False", string update = "False", string delete = "False")
 {
     this.ObjectId          = objectId;
     this.Name              = name;
     this.Columns           = new List <RbacColumn>();
     this.Conditions        = new List <RbacCondition>();
     this.Relations         = new List <RbacRelation>();
     this.Parameters        = new List <RbacParameter>();
     this.AllowedOperations = Rbac.ParseOperations(create, read, update, delete);
 }
コード例 #8
0
 public RbacColumn(string name, string dataType, string create = "False", string read = "False", string update = "False")
 {
     switch (dataType)
     {
     case "numeric":
         dataType = "Decimal";
         break;
     }
     this.Name              = name;
     this.DataType          = (RbacDataTypes)Enum.Parse(typeof(RbacDataTypes), dataType, true);
     this.AllowedOperations = Rbac.ParseOperations(create, read, update, "False");
 }
コード例 #9
0
ファイル: RbacRole.cs プロジェクト: crazyants/aarbac
        public static RbacRole GetSample(Rbac rbac)
        {
            rbac = new DataManager.Manager(false).GetRbac(rbac.Name);

            RbacRole role = new RbacRole();

            role.Name                 = "Sample Role";
            role.Description          = "Sample role description";
            role.MetaDataEntitlements = rbac.MetaDataEntitlements;
            role.MetaDataRbac         = rbac.MetaDataRbac;
            role.RbacId               = rbac.RbacId;
            return(role);
        }
コード例 #10
0
 private void Assign(Rbac rbac)
 {
     this.User                 = rbac.User;
     this.RbacId               = rbac.RbacId;
     this.Name                 = rbac.Name;
     this.Description          = rbac.Description;
     this.ConnectionString     = rbac.ConnectionString;
     this.MetaDataRbac         = rbac.MetaDataRbac;
     this.MetaDataEntitlements = rbac.MetaDataEntitlements;
     this.Version              = rbac.Version;
     this.MetaDataEntitlements = rbac.MetaDataEntitlements;
     this.Trace                = new StringWriterTrace();
 }
コード例 #11
0
ファイル: SqlQueryParser.cs プロジェクト: radtek/aarbac
 public SqlQueryParser(Rbac context, bool skipParsing = false, bool silent = false)
 {
     Context          = context;
     IsParsingSkipped = skipParsing;
     Columns          = new List <RbacSelectColumn>();
     JoinClauses      = new List <RbacJoin>();
     WhereClauses     = new List <RbacWhereClause>();
     ExecutionTime    = new ExecutionTime();
     ParseErrors      = new List <ParseError>();
     ParamErrors      = new List <string>();
     Errors           = new List <string>();
     Warnings         = new List <string>();
     IsSilent         = silent;
 }
コード例 #12
0
ファイル: ExtensionMethods.cs プロジェクト: crazyants/aarbac
        public static RbacRole ImportRole(this Rbac rbac, string fileName)
        {
            RbacRoleWeb  wRole = null;
            StreamReader sr    = new StreamReader(fileName);
            var          s     = new System.Xml.Serialization.XmlSerializer(typeof(RbacRoleWeb));

            wRole = (RbacRoleWeb)s.Deserialize(sr);
            sr.Close();

            if (wRole != null)
            {
                RbacRole role = new RbacRole(rbac.RbacId, wRole.Name, wRole.Description, wRole.MetaDataRbac, wRole.MetaDataEntitlements);
                return(role);
            }
            return(null);
        }
コード例 #13
0
        public Rbac(string userName)
        {
            Rbac rbacFromCache = RbacCache.Instance.GetContext(userName);

            if (rbacFromCache == null)
            {
                RbacUser user   = new RbacUser(userName);
                Rbac     dbRbac = new DataManager.Manager(false).GetRbac(user.Role.RbacId);
                dbRbac.User = user;
                Assign(dbRbac);
                RbacCache.Instance.Contexts.Add(userName, this);
            }
            else
            {
                Assign(rbacFromCache);
            }
        }
コード例 #14
0
        public Rbac CreateNew(string rbacName, string description, string connectionString, string metaDataEntitlement)
        {
            DataManager.Manager manager = new DataManager.Manager(false);
            if (manager.GetRbac(rbacName) != null)
            {
                RbacException.Raise(string.Format("'{0}' already exists! Please provide a different name.", rbacName), RbacExceptionCategories.Repository);
            }

            Rbac newRbac = new Rbac();

            newRbac.Name             = rbacName;
            newRbac.Description      = description;
            newRbac.ConnectionString = connectionString;
            N("Generating meta data...");
            newRbac.MetaDataRbac = RbacMetaData.Generate(newRbac.ConnectionString);
            N("Done!", LogMessageTypes.Success);
            N("Saving your rbac instance...");
            Rbac rbac = manager.AddOrUpdate(newRbac);

            N("Done!", LogMessageTypes.Success);
            return(rbac);
        }
コード例 #15
0
ファイル: JoinClauseVisitor.cs プロジェクト: radtek/aarbac
 public JoinClauseVisitor(Rbac context)
 {
     Context = context;
 }
コード例 #16
0
ファイル: ExtensionMethods.cs プロジェクト: crazyants/aarbac
 public static bool ChangePassword(this Rbac rbac, string password)
 {
     return(new DataManager.Manager().ChangePasswordRbac(rbac.Name, password));
 }
コード例 #17
0
 public static void Delete(Rbac rbac)
 {
     new DataManager.Manager().Delete(rbac);
 }
コード例 #18
0
 public NamedTableReferenceVisitor(Rbac context)
 {
     Context = context;
     Tables  = new List <RbacTable>();
 }
コード例 #19
0
 public ScalarExpressionVisitor(Rbac context, RbacTable table = null)
 {
     this.Context = context;
     this.Table   = table;
 }