public override ACLVerdict Apply(UserContext ctx, DataOperation op) { return (op == DataOperation.Retreive) ? ACLVerdict.Allowed : ACLVerdict.None; }
public ACLVerdict Apply(UserContext ctx, DataOperation op) { ACLVerdict current = ACLVerdict.Denied; foreach (IACLEntry entry in _accessControlList) { ACLVerdict result = entry.Apply(ctx, op); switch (result) { case ACLVerdict.Denied: return ACLVerdict.Denied; case ACLVerdict.Allowed: current = ACLVerdict.Allowed; break; } } return current; }
public override ACLVerdict Apply(UserContext ctx, DataOperation op) { if (op == DataOperation.Retreive && ctx.AccountId != 0) { return ACLVerdict.Allowed; } return ACLVerdict.None; }
public abstract ACLVerdict Apply(UserContext ctx, DataOperation op);
public override ACLVerdict Apply(UserContext ctx, DataOperation op) { if ((op == DataOperation.Create || op == DataOperation.Delete) && ctx.AccountId != 0) { return ACLVerdict.Allowed; } return ACLVerdict.None; }
public override ACLVerdict Apply(UserContext ctx, DataOperation op) { if (ctx.AccountId == 0) return ACLVerdict.None; if (ctx.AccountId != _accountId) return ACLVerdict.None; if ((_operation & (int)op) == 0) return ACLVerdict.None; return _permission == DataOperationPermission.Allow ? ACLVerdict.Allowed : ACLVerdict.Denied; }
public bool TryCheck(UserContext ctx, DataOperation op) { ACLVerdict result = Apply(ctx, op); switch (result) { case ACLVerdict.Denied: case ACLVerdict.None: return false; } return true; }
public void Check(UserContext ctx, DataOperation op) { if (!TryCheck(ctx, op)) { throw new AccessDeniedException(); } }
/// <summary> /// Try to login a user. /// </summary> /// <param name="username">user name</param> /// <param name="password">user password</param> /// <param name="ctx">user context</param> /// <returns>a user security context</returns> public bool TryLogin(string username, string password, out UserContext ctx) { ctx = null; // find an account by username/passsword Account account = _session.CreateCriteria(typeof(Account)) .Add(Expression.Eq("Name", username)) .Add(Expression.Eq("Password", password)) .UniqueResult<Account>(); if (account != null) { ctx = new UserContext(account); return true; } return false; }