AccessGrant GetGrant() { AccessGrant grant; switch (AccessLevel) { case PrivilegeAccessLevel.Read: grant = AccessGrant.ConstructGrantRead(); break; case PrivilegeAccessLevel.Update: grant = AccessGrant.ConstructGrantUpdate(); break; case PrivilegeAccessLevel.Create: grant = AccessGrant.ConstructGrantCreate(); break; case PrivilegeAccessLevel.Correct: grant = AccessGrant.ConstructGrantCorrect(); break; case PrivilegeAccessLevel.Delete: grant = AccessGrant.ConstructGrantDelete(); break; default: throw new NotImplementedException( $"Value {AccessLevel} is not implemented."); } return(grant); }
void DoPrivilegeCreateSingle(string privilegeName, string privilegeLabel, AccessGrant accessGrant) { if (String.IsNullOrWhiteSpace(privilegeLabel)) { return; } AxSecurityPrivilege privilege; privilege = _axHelper.MetadataProvider.SecurityPrivileges.Read(privilegeName); if (privilege != null) { return; } privilege = new AxSecurityPrivilege(); AxSecurityEntryPointReference entryPoint = new AxSecurityEntryPointReference(); entryPoint.Name = FormName; entryPoint.Grant = accessGrant; entryPoint.ObjectName = FormName; entryPoint.ObjectType = EntryPointType.MenuItemDisplay; privilege.Name = privilegeName; privilege.EntryPoints.Add(entryPoint); privilege.Label = privilegeLabel; _axHelper.MetaModelService.CreateSecurityPrivilege(privilege, _axHelper.ModelSaveInfo); _axHelper.AppendToActiveProject(privilege); AddLog($"Privilege: {privilege.Name}; "); }
public ActionResult Callback(string code) { AccessGrant accessGrant = _gitHubProvider.OAuthOperations.ExchangeForAccessAsync(code, CallbackUrl, null).Result; Session["AccessGrant"] = accessGrant; return(RedirectToAction("Index")); }
public ActionResult UpdateStatus(string status) { AccessGrant accessGrant = Session["AccessGrant"] as AccessGrant; IFacebook facebookClient = facebookProvider.GetApi(accessGrant.AccessToken); facebookClient.UpdateStatusAsync(status).Wait(); return(View()); }
// GET: /Facebook/Callback public ActionResult Callback(string code) { AccessGrant accessGrant = facebookProvider.OAuthOperations.ExchangeForAccessAsync( code, "http://localhost/Facebook/Callback", null).Result; Session["AccessGrant"] = accessGrant; return(View()); }
/// <summary> /// Creates privilege in AOT /// </summary> /// <param name="name">Privilege's name</param> /// <param name="grant">User chosen privilege access level</param> /// <remarks>This method could be improved. Most probably are better ways to achieve this goal.</remarks> protected void create(string name, AccessGrant grant) { AxSecurityPrivilege privilege = new AxSecurityPrivilege(); AxSecurityEntryPointReference entryPoint = new AxSecurityEntryPointReference(); ModelInfo modelInfo; ModelSaveInfo modelSaveInfo = new ModelSaveInfo(); VSProjectNode project = Utils.LocalUtils.GetActiveProject(); #region Create entry point entryPoint.Name = this.menuItem.Name; entryPoint.Grant = grant; entryPoint.ObjectName = this.menuItem.Name; switch (this.menuItem.ObjectType) { case MenuItemObjectType.Form: entryPoint.ObjectType = EntryPointType.MenuItemDisplay; break; case MenuItemObjectType.Class: entryPoint.ObjectType = EntryPointType.MenuItemAction; break; case MenuItemObjectType.SSRSReport: entryPoint.ObjectType = EntryPointType.MenuItemOutput; break; default: throw new NotImplementedException($"Menuitem object type {this.menuItem.ObjectType} is not implemented."); } #endregion #region Create privilege privilege.Name = name; privilege.EntryPoints.Add(entryPoint); privilege.Label = this.menuItem.Label; #endregion // Most probably there is a better way to do this part. #region Add to AOT modelInfo = project.GetProjectsModelInfo(); modelSaveInfo.Id = modelInfo.Id; modelSaveInfo.Layer = modelInfo.Layer; var metaModelProviders = ServiceLocator.GetService(typeof(IMetaModelProviders)) as IMetaModelProviders; var metaModelService = metaModelProviders.CurrentMetaModelService; metaModelService.CreateSecurityPrivilege(privilege, modelSaveInfo); #endregion this.appendToProject(privilege); }
// GET: /Facebook/Callback public ActionResult Callback(string code) { AccessGrant accessGrant = facebookProvider.OAuthOperations.ExchangeForAccessAsync( code, "http://localhost/Facebook/Callback", null).Result; Session["AccessGrant"] = accessGrant; IFacebook facebookClient = facebookProvider.GetApi(accessGrant.AccessToken); FacebookProfile profile = facebookClient.UserOperations.GetUserProfile(); return(View(profile)); }
/// <summary> /// Convert stored access grant into persisted grant in IS4 /// </summary> /// <param name="accessGrant">The stored access grant</param> /// <returns></returns> private static PersistedGrant FromModel(AccessGrant accessGrant) { return(new PersistedGrant { Key = accessGrant.Key, ClientId = accessGrant.ClientId, SubjectId = accessGrant.SubjectId, Type = accessGrant.Type, ConsumedTime = accessGrant.ConsumedTime, CreationTime = accessGrant.CreationTime, SessionId = accessGrant.SessionId, Data = accessGrant.Data, Description = accessGrant.Description, Expiration = accessGrant.Expiration }); }
protected override RestOperationCanceler PostForAccessGrantAsync(string accessTokenUrl, NameValueCollection request, Action <RestOperationCompletedEventArgs <AccessGrant> > operationCompleted) { return(this.RestTemplate.PostForObjectAsync <NameValueCollection>(accessTokenUrl, request, r => { if (r.Error == null) { string expires = r.Response["expires"]; AccessGrant token = new AccessGrant(r.Response["access_token"], null, null, expires != null ? new Nullable <int>(Int32.Parse(expires)) : null); operationCompleted(new RestOperationCompletedEventArgs <AccessGrant>(token, null, false, r.UserState)); } else { operationCompleted(new RestOperationCompletedEventArgs <AccessGrant>(null, r.Error, r.Cancelled, r.UserState)); } })); }
void DoPrivilegeCreate() { string privilegeName; AccessGrant accessGrant; if (!string.IsNullOrWhiteSpace(PrivilegeLabelView)) { privilegeName = $"{FormName}View"; accessGrant = AccessGrant.ConstructGrantRead(); DoPrivilegeCreateSingle(privilegeName, PrivilegeLabelView, accessGrant); } if (!string.IsNullOrWhiteSpace(PrivilegeLabelMaintain)) { privilegeName = $"{FormName}Maintain"; accessGrant = AccessGrant.ConstructGrantDelete(); DoPrivilegeCreateSingle(privilegeName, PrivilegeLabelMaintain, accessGrant); } }
protected void UpdateState(AccessGrant accessGrant) { if (_collidingAmount > 1) { return; } if (accessGrant == AccessGrant.None) { ResetState(); } else if (accessGrant == AccessGrant.Yes) { Activate(); } else { Deactivate(); } }
protected virtual void SetActiveColor(AccessGrant accessGrant) { Color color = ColorUtils.White; switch (accessGrant) { case AccessGrant.None: color = ColorUtils.Blue; break; case AccessGrant.No: color = ColorUtils.Red; break; case AccessGrant.Yes: color = ColorUtils.Green; break; } _renderer.color = color; _light.SetColor(color); }
/// <summary> /// Executes routine /// </summary> public void run() { UserInterface userInterface = new UserInterface(); userInterface.ShowDialog(); if (!userInterface.closeOk) { return; } foreach (var item in userInterface.checkedItems()) { AccessGrant grant; string newName = string.Empty; string sufix = string.Empty; switch (item.ToString().ToUpper()) { case "UNSET": sufix = "Unset"; grant = AccessGrant.ConstructGrantAll(); break; case "NO ACCESS": sufix = "NoAccess"; grant = AccessGrant.ConstructDenyAll(); break; case "READ": sufix = "View"; grant = AccessGrant.ConstructGrantRead(); break; case "UPDATE": sufix = "Update"; grant = AccessGrant.ConstructGrantUpdate(); break; case "CREATE": sufix = "Create"; grant = AccessGrant.ConstructGrantCreate(); break; case "CORRECT": sufix = "Correct"; grant = AccessGrant.ConstructGrantCorrect(); break; case "DELETE": sufix = "Maintain"; grant = AccessGrant.ConstructGrantDelete(); break; default: throw new NotImplementedException($"Menu item object type {this.menuItem.ObjectType} is not implemented."); } newName = $"{this.menuItem.Name}{sufix}"; this.create(newName, grant); } }
/// <summary> /// Saves given entity /// </summary> /// <param name="entity">The entity to save</param> /// <returns></returns> public Task <AccessGrant> Save(AccessGrant entity) { return(this.dataOps.Connect().QueryFirst("PersistedGrant", "Save").ExecuteAsync <AccessGrant>(entity)); }