Esempio n. 1
0
 public ResourceMenuItem(string id, string role, string path, string @params, string tooltip, string moduleName)
     : base(id, null, role, tooltip, null)
 {
     _path   = path;
     _params = PropertyUtil.ConvertToDictionary(@params);
     Module  = moduleName;
 }
Esempio n. 2
0
 public ApplicationHeader(string label, string parameters, string displacement, string showExpression)
 {
     Label      = label;
     Parameters = PropertyUtil.ConvertToDictionary(parameters);
     ValidateDisplacementType(displacement);
     _parametersString = parameters;
     ShowExpression    = showExpression;
 }
Esempio n. 3
0
 public ApplicationSection(string id, string applicationName,
                           bool @abstract, string label, string attribute, string resourcepath,
                           string parameters, IList <IApplicationDisplayable> displayables, string showExpression, string toolTip)
 {
     _id = id;
     _applicationName = applicationName;
     _abstract        = @abstract;
     _resourcepath    = resourcepath;
     _parameters      = PropertyUtil.ConvertToDictionary(parameters);
     _displayables    = displayables;
     _label           = label;
     _attribute       = attribute;
     _showExpression  = showExpression;
     _toolTip         = toolTip;
 }
Esempio n. 4
0
        public static InMemoryUser CurrentUser(Boolean fetchFromDB = true, bool throwAnonymousException = true)
        {
            if (ApplicationConfiguration.IsUnitTest)
            {
                return(InMemoryUser.TestInstance("test"));
            }

            var currLogin = LogicalThreadContext.GetData <string>("user") ?? CurrentPrincipalLogin;

            if (currLogin == "")
            {
                if (!throwAnonymousException)
                {
                    return(new InMemoryUser {
                        Login = "******"
                    });
                }
                throw new UnauthorizedAccessException();
            }

            if (!fetchFromDB || currLogin == null || _users.ContainsKey(currLogin))
            {
                return(_users[currLogin]);
            }
            //cookie authenticated already
            //TODO: remove this in prod?
            var dbUser = new SWDBHibernateDAO().FindSingleByQuery <User>(User.UserByUserName, currLogin);

            if (dbUser == null)
            {
                throw new InvalidOperationException("user should exist at DB");
            }

            var formsIdentity = CurrentPrincipal.Identity as System.Web.Security.FormsIdentity;
            var timezone      = String.Empty;

            if (formsIdentity != null && formsIdentity.Ticket != null && !String.IsNullOrWhiteSpace(formsIdentity.Ticket.UserData))
            {
                var userData = PropertyUtil.ConvertToDictionary(formsIdentity.Ticket.UserData);
                timezone = userData["userTimezoneOffset"];
            }
            UserFound(dbUser, timezone);
            return(_users[currLogin]);
        }
Esempio n. 5
0
 public ApplicationSection(string id, string applicationName,
                           bool @abstract, string label, string attribute, string resourcepath,
                           string parameters, List <IApplicationDisplayable> displayables, string showExpression,
                           string toolTip, string orientation, ApplicationHeader header, FieldRenderer renderer)
 {
     Id = id;
     ApplicationName   = applicationName;
     Abstract          = @abstract;
     Resourcepath      = resourcepath;
     _parametersString = parameters;
     Parameters        = PropertyUtil.ConvertToDictionary(parameters);
     _displayables     = displayables;
     Label             = label;
     Attribute         = attribute;
     ShowExpression    = showExpression;
     ToolTip           = toolTip;
     ValidateOrientation(orientation);
     Header    = header;
     _renderer = renderer;
 }
Esempio n. 6
0
        public void OnActionExecuting(ActionExecutingContext actionContext)
        {
            if (!actionContext.HttpContext.User.Identity.IsAuthenticated)
            {
                return;
            }
            IEnumerable <String> modules;
            var currentModule               = GetValue(actionContext, CurrentModuleKey);
            var currentMetadataId           = GetValue(actionContext, CurrentMetadataKey);
            var currentMetadataParameter    = GetValue(actionContext, CurrentMetadataParameterKey);
            ApplicationLookupContext appCtx = null;

            if (currentMetadataId != null)
            {
                appCtx = new ApplicationLookupContext {
                    MetadataId = currentMetadataId
                };
            }
            ContextLookuper.AddContext(new ContextHolder()
            {
                Module = currentModule, ApplicationLookupContext = appCtx, MetadataParameters = PropertyUtil.ConvertToDictionary(currentMetadataParameter)
            }, true);
        }
Esempio n. 7
0
        private static MenuBaseDefinition ParseApplication(XElement xElement, ICollection <ModuleDefinition> modules)
        {
            var id          = xElement.Attribute(XmlMenuMetadataSchema.MenuBaseIdAttribute).ValueOrDefault((string)null);
            var title       = xElement.Attribute(XmlMenuMetadataSchema.MenuBaseTitleAttribute).ValueOrDefault((string)null);
            var tooltip     = xElement.Attribute(XmlMenuMetadataSchema.MenuBaseTipAttribute).ValueOrDefault((string)null);
            var icon        = xElement.Attribute(XmlMenuMetadataSchema.MenuBaseIconAttribute).ValueOrDefault((string)null);
            var role        = xElement.Attribute(XmlMenuMetadataSchema.MenuBaseRoleAttribute).ValueOrDefault((string)null);
            var application = xElement.Attribute(XmlMenuMetadataSchema.ApplicationMenuRefAttribute).ValueOrDefault((string)null);
            var schema      = xElement.Attribute(XmlMenuMetadataSchema.ApplicationMenuSchemaAttribute).ValueOrDefault("list");
            var modeAttr    = xElement.Attribute(XmlMenuMetadataSchema.ApplicationMenuModeAttribute).ValueOrDefault((string)null);
            var moduleName  = xElement.Attribute(XmlMenuMetadataSchema.ContainerModuleName).ValueOrDefault((string)null);
            var moduleAlias = xElement.Attribute(XmlMenuMetadataSchema.ContainerModuleAlias).ValueOrDefault((string)null);

            if (moduleName != null)
            {
                modules.Add(new ModuleDefinition(moduleName, moduleAlias));
            }
            var parameters =
                xElement.Attribute(XmlMenuMetadataSchema.ApplicationMenuParametersAttribute).ValueOrDefault((string)null);
            SchemaMode mode;

            Enum.TryParse(modeAttr, true, out mode);
            return(new ApplicationMenuItemDefinition(id, title, role, tooltip, icon, application, schema, mode, PropertyUtil.ConvertToDictionary(parameters), moduleName));
        }
Esempio n. 8
0
        private static MenuBaseDefinition ParseAction(XElement xElement, ICollection <ModuleDefinition> modules)
        {
            var id          = xElement.Attribute(XmlMenuMetadataSchema.MenuBaseIdAttribute).ValueOrDefault((string)null);
            var title       = xElement.Attribute(XmlMenuMetadataSchema.MenuBaseTitleAttribute).ValueOrDefault((string)null);
            var tooltip     = xElement.Attribute(XmlMenuMetadataSchema.MenuBaseTipAttribute).ValueOrDefault((string)null);
            var icon        = xElement.Attribute(XmlMenuMetadataSchema.MenuBaseIconAttribute).ValueOrDefault((string)null);
            var role        = xElement.Attribute(XmlMenuMetadataSchema.MenuBaseRoleAttribute).ValueOrDefault((string)null);
            var action      = xElement.Attribute(XmlMenuMetadataSchema.ActionMenuActionAttribute).ValueOrDefault((string)null);
            var target      = xElement.Attribute(XmlMenuMetadataSchema.ActionMenuTargetAttribute).ValueOrDefault((string)null);
            var moduleName  = xElement.Attribute(XmlMenuMetadataSchema.ContainerModuleName).ValueOrDefault((string)null);
            var moduleAlias = xElement.Attribute(XmlMenuMetadataSchema.ContainerModuleAlias).ValueOrDefault((string)null);

            if (moduleName != null)
            {
                modules.Add(new ModuleDefinition(moduleName, moduleAlias));
            }
            var parameters =
                xElement.Attribute(XmlMenuMetadataSchema.ActionMenuParametersAttribute).ValueOrDefault((string)null);
            var controller = xElement.Attribute(XmlMenuMetadataSchema.ActionMenuControllerAttribute).Value;

            return(new ActionMenuItemDefinition(id, title, role, tooltip, icon, action, controller, target, PropertyUtil.ConvertToDictionary(parameters), moduleName));
        }
Esempio n. 9
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var currentModule = RequestUtil.GetValue(actionContext.Request, CurrentModuleKey);
            var currentUSer   = SecurityFacade.CurrentUser();

            if (currentModule != null && currentUSer != null)
            {
                FunctionalRole fr;
                Enum.TryParse(currentModule, true, out fr);
                if (!currentUSer.IsInRole(fr.ToString()))
                {
                    throw new InvalidOperationException(
                              "this user is not allowed for this role. Please contact your administrator");
                }
            }

            var currentMetadataId        = RequestUtil.GetValue(actionContext.Request, CurrentMetadataKey);
            var currentMetadataParameter = RequestUtil.GetValue(actionContext.Request, CurrentMetadataParameterKey);
            var printMode = "true".Equals(RequestUtil.GetValue(actionContext.Request, PrintMode));
            ApplicationLookupContext appCtx = null;

            if (currentMetadataId != null)
            {
                appCtx = new ApplicationLookupContext {
                    MetadataId = currentMetadataId
                };
            }
            ContextLookuper.AddContext(new ContextHolder()
            {
                Module = currentModule, ApplicationLookupContext = appCtx, PrintMode = printMode, MetadataParameters = PropertyUtil.ConvertToDictionary(currentMetadataParameter)
            }, true);
            base.OnActionExecuting(actionContext);
        }
Esempio n. 10
0
 public IDictionary <string, string> ParametersAsDictionary()
 {
     return(PropertyUtil.ConvertToDictionary(Parameters));
 }