/// <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); }
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); }
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); }
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; }
public void AddContext(string userName, Rbac context) { if (Contexts.ContainsKey(userName)) { Contexts[userName] = context; } else { Contexts.Add(userName, context); } }
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); }
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); }
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"); }
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); }
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(); }
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; }
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); }
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); } }
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); }
public JoinClauseVisitor(Rbac context) { Context = context; }
public static bool ChangePassword(this Rbac rbac, string password) { return(new DataManager.Manager().ChangePasswordRbac(rbac.Name, password)); }
public static void Delete(Rbac rbac) { new DataManager.Manager().Delete(rbac); }
public NamedTableReferenceVisitor(Rbac context) { Context = context; Tables = new List <RbacTable>(); }
public ScalarExpressionVisitor(Rbac context, RbacTable table = null) { this.Context = context; this.Table = table; }