Esempio n. 1
0
 public PermissionPoint(PermissionPointAttribute attribute, object context, MemberInfo member, object[] args)
 {
     name     = attribute.Name;
     resource = attribute.Resource;
     action   = attribute.Action;
     Context  = context;
     Member   = member;
     Args     = args;
 }
Esempio n. 2
0
 public PermissionPoint(PermissionPointAttribute attribute, object context, MemberInfo member, object[] args)
 {
     name = attribute.Name;
     resource = attribute.Resource;
     action = attribute.Action;
     Context = context;
     Member = member;
     Args = args;
 }
Esempio n. 3
0
        private bool tryAccess(IInvocation invocation)
        {
            PermissionPointAttribute attribute = AttributeHelper.GetAttribute <PermissionPointAttribute>(invocation) as PermissionPointAttribute;

            if (attribute == null)
            {
                return(true);
            }
            string strLogHeader = "Access accepted";

            try
            {
                IPermissionPointResolve resolve = IocCoreFactory.Get <IPermissionPointResolve>(attribute.ResolveType);
                PermissionPoint         point   = new DefaultPermissionPoint(attribute,
                                                                             InterceptorHelper.GetInvocationTarget(invocation),
                                                                             InterceptorHelper.GetInvocationMethod(invocation) as MemberInfo,
                                                                             InterceptorHelper.GetInvocationMethodArgs(invocation)) as PermissionPoint;
                PermissionInfo info = resolve.Resolve(point);
                info++;
                if (attribute.IsAcceptLog && LogLevel <= attribute.LogLevel)
                {
                    StringBuilder logstr = new StringBuilder();
                    logstr.AppendFormat("{0} {1} {2} {3}-----Access Log ", strLogHeader, PrincipalTokenHolder.CurrentPrincipal.ToString(), attribute.ToString(), InterceptorHelper.GetMethodInfo(invocation));
                    Log.Log(logstr.ToString(), attribute.LogLevel);
                }
            }
            catch (AccessException ex)
            {
                strLogHeader = "Access Denied";
                if (attribute.IsAcceptLog && LogLevel <= attribute.LogLevel)
                {
                    StringBuilder logstr = new StringBuilder();
                    logstr.AppendFormat("{0} {1} {2} {3}-----Access Log ", strLogHeader, PrincipalTokenHolder.CurrentPrincipal.ToString(), attribute.ToString(), InterceptorHelper.GetMethodInfo(invocation));
                    Log.Log(logstr.ToString(), attribute.LogLevel, ex);
                }
                if (attribute.IsAlert)
                {
                    Console.WriteLine("Access diny alert!");
                }
                if (attribute.IsThrow)
                {
                    throw ex;
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 4
0
 public DefaultPermissionPoint(PermissionPointAttribute attribute, object context, MemberInfo member, object[] args)
     : base(attribute, context, member, args)
 {
 }
Esempio n. 5
0
 public DefaultPermissionPoint(PermissionPointAttribute attribute, object context, MemberInfo member, object[] args)
     : base(attribute, context, member, args)
 {
 }