public ActionResult Index() { var user = SecurityFacade.CurrentUser(); var securedMenu = user.Menu(ClientPlatform.Web); var indexItemId = securedMenu.ItemindexId; var indexItem = securedMenu.Leafs.FirstOrDefault(l => indexItemId.EqualsIc(l.Id)); if (indexItem == null) { //first we´ll try to get the item declared, if it´s null (that item is role protected for that user, for instance, let´s pick the first leaf one as a fallback to avoid problems indexItem = securedMenu.Leafs.FirstOrDefault(a => a.Leaf); } HomeModel model = null; if (indexItem is ApplicationMenuItemDefinition) { var app = (ApplicationMenuItemDefinition)indexItem; var key = new ApplicationMetadataSchemaKey(app.Schema, app.Mode, ClientPlatform.Web); var adapter = new DataRequestAdapter(null, key); model = new HomeModel(GetUrlFromApplication(app.Application, adapter), app.Title, FetchConfigs(), user, HasPopupLogo(), _i18NResolver.FetchCatalogs(), ApplicationConfiguration.ClientName, indexItem.Module); } else if (indexItem is ActionMenuItemDefinition) { var actItem = (ActionMenuItemDefinition)indexItem; var action = actItem.Action; model = new HomeModel(GetUrlFromAction(actItem), actItem.Title, FetchConfigs(), user, HasPopupLogo(), _i18NResolver.FetchCatalogs(), ApplicationConfiguration.ClientName, indexItem.Module); } return(View(model)); }
public IApplicationResponse Get(string application, [FromUri] DataRequestAdapter request) { var user = SecurityFacade.CurrentUser(); if (null == user) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } RequestUtil.ValidateMockError(Request); if (!"solution".EqualsIc(application) && !"ci".EqualsIc(application)) { ValidateHashSecurity(request); } var applicationMetadata = MetadataProvider .Application(application) .ApplyPolicies(request.Key, user, ClientPlatform.Web); ContextLookuper.FillContext(request.Key); var response = DataSetProvider.LookupAsBaseDataSet(application).Get(applicationMetadata, user, request); response.Title = _i18NResolver.I18NSchemaTitle(response.Schema); var schemaMode = request.Key.Mode ?? response.Schema.Mode; response.Mode = schemaMode.ToString().ToLower(); return(response); }
private string GetUrlFromApplication(string application, DataRequestAdapter adapter) { var actionURL = String.Format("api/data/{0}", application); //TODO: fix WEBAPIUTIL method var queryString = "key[schemaId]=" + adapter.Key.SchemaId + "&key[mode]=" + adapter.Key.Mode.ToString().ToLower() + "&key[platform]=" + adapter.Key.Platform.ToString().ToLower(); return(WebAPIUtil.GetRelativeRedirectURL(actionURL, queryString)); }
public IApplicationResponse Get(string application, [FromUri] DataRequestAdapter request) { var user = SecurityFacade.CurrentUser(); if (null == user) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } var response = _dataController.Get(application, request); return(response); }
public IApplicationResponse OpenDetailWithInitialData(string application, [FromUri] DataRequestAdapter request, JObject initialData) { request.InitialData = initialData; var response = Get(application, request); if (!string.IsNullOrEmpty(request.Title)) { var newtitle = request.Title.Fmt(response.Title); response.Title = newtitle; response.Schema.Title = newtitle; } return(response); }
private IApplicationResponse Get(string application, [FromUri] DataRequestAdapter request) { var user = SecurityFacade.CurrentUser(); if (null == user) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } var applicationMetadata = MetadataProvider .Application(application) .ApplyPolicies(request.Key, user, ClientPlatform.Web); return(((BaseApplicationDataSet)_dataSetProvider.LookupDataSet(application)).Get(applicationMetadata, user, request)); }
private static void ValidateHashSecurity(DataRequestAdapter request) { if (request.Id == null) { return; } if (request.Id != null && request.HmacHash == null) { throw new InvalidOperationException( "You don´t have enough permissions to see that register. contact your administrator"); } if (!AuthUtils.HmacShaEncode(request.Id).Equals(request.HmacHash)) { throw new InvalidOperationException( "You don´t have enough permissions to see that register. contact your administrator"); } }
public ActionResult Index(string application, string popupmode, [FromUri] DataRequestAdapter request) { var user = SecurityFacade.CurrentUser(); var app = MetadataProvider.Application(application); var schemas = app.Schemas(); ApplicationSchemaDefinition appSchema; if (schemas.TryGetValue(request.Key, out appSchema)) { //todo apply security var dataResponse = _dataController.Get(application, request); var model = new ApplicationModel(application, appSchema.SchemaId, request.Key.Mode.ToString().ToLower(), appSchema.Title, dataResponse); TempData["model"] = model; return(RedirectToAction("Index", "Generic", new { includeUrl = "/Content/Controller/Application.html", title = appSchema.Title, popupmode = popupmode })); } throw new InvalidOperationException(String.Format("schema {0} not found", request.Key)); }