本文整理汇总了C#中OrganisationBuilder.AddSecurityToken方法的典型用法代码示例。如果您正苦于以下问题:C# OrganisationBuilder.AddSecurityToken方法的具体用法?C# OrganisationBuilder.AddSecurityToken怎么用?C# OrganisationBuilder.AddSecurityToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrganisationBuilder
的用法示例。
在下文中一共展示了OrganisationBuilder.AddSecurityToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeniedPermissions
public void DeniedPermissions()
{
var readOrganisationName = this.FindPermission(Organisations.Meta.Name, Operation.Read);
var databaseRole = new RoleBuilder(this.DatabaseSession).WithName("Role").WithPermission(readOrganisationName).Build();
var person = new PersonBuilder(this.DatabaseSession).WithFirstName("John").WithLastName("Doe").Build();
this.DatabaseSession.Derive(true);
this.DatabaseSession.Commit();
new AccessControlBuilder(this.DatabaseSession).WithRole(databaseRole).WithSubject(person).Build();
this.DatabaseSession.Commit();
var sessions = new ISession[] { this.DatabaseSession, this.CreateWorkspaceSession() };
foreach (var session in sessions)
{
session.Commit();
var organisation = new OrganisationBuilder(session).WithName("Organisation").Build();
var token = new SecurityTokenBuilder(session).Build();
organisation.AddSecurityToken(token);
var role = (Role)session.Instantiate(new Roles(this.DatabaseSession).FindBy(Roles.Meta.Name, "Role"));
var accessControl = (AccessControl)session.Instantiate(role.AccessControlsWhereRole.First);
accessControl.AddObject(token);
Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
var accessList = new AccessControlList(organisation, person);
Assert.IsTrue(accessList.CanRead(Organisations.Meta.Name));
organisation.AddDeniedPermission(readOrganisationName);
accessList = new AccessControlList(organisation, person);
Assert.IsFalse(accessList.CanRead(Organisations.Meta.Name));
session.Rollback();
}
}
示例2: RoleBuilder
public void GivenAWorkspaceNewAccessControlledObjectWhenGettingTheAccessControlListThenUserHasAccessToThePermissionsInTheRole()
{
var readOrganisationName = this.FindPermission(Organisations.Meta.Name, Operation.Read);
var databaseRole = new RoleBuilder(this.DatabaseSession).WithName("Role").WithPermission(readOrganisationName).Build();
var person = new PersonBuilder(this.DatabaseSession).WithFirstName("John").WithLastName("Doe").Build();
this.DatabaseSession.Derive(true);
this.DatabaseSession.Commit();
new AccessControlBuilder(this.DatabaseSession).WithSubject(person).WithRole(databaseRole).Build();
this.DatabaseSession.Commit();
var workspaceSession = this.CreateWorkspaceSession();
var organisation = new OrganisationBuilder(workspaceSession).WithName("Organisation").Build();
var token = new SecurityTokenBuilder(workspaceSession).Build();
organisation.AddSecurityToken(token);
var role = (Role)workspaceSession.Instantiate(new Roles(this.DatabaseSession).FindBy(Roles.Meta.Name, "Role"));
var accessControl = (AccessControl)workspaceSession.Instantiate(role.AccessControlsWhereRole.First);
accessControl.AddObject(token);
Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
var accessList = new AccessControlList(organisation, person);
accessList.CanRead(Organisations.Meta.Name);
}
示例3: RoleBuilder
public void GivenAUserGroupAndAnAccessControlledObjectWhenGettingTheAccessListThenUserHasAccessToThePermissionsInTheRole()
{
var readOrganisationName = this.FindPermission(Organisations.Meta.Name, Operation.Read);
var databaseRole = new RoleBuilder(this.Session).WithName("Role").WithPermission(readOrganisationName).Build();
var person = new PersonBuilder(this.Session).WithFirstName("John").WithLastName("Doe").Build();
new UserGroupBuilder(this.Session).WithName("Group").WithMember(person).Build();
this.Session.Derive(true);
this.Session.Commit();
new AccessControlBuilder(this.Session).WithSubject(person).WithRole(databaseRole).Build();
this.Session.Commit();
var sessions = new ISession[] { this.Session };
foreach (var session in sessions)
{
session.Commit();
var organisation = new OrganisationBuilder(session).WithName("Organisation").Build();
var token = new SecurityTokenBuilder(session).Build();
organisation.AddSecurityToken(token);
var role = (Role)session.Instantiate(new Roles(this.Session).FindBy(Roles.Meta.Name, "Role"));
var accessControl = (AccessControl)session.Instantiate(role.AccessControlsWhereRole.First);
accessControl.AddObject(token);
Assert.IsFalse(this.Session.Derive().HasErrors);
var accessList = new AccessControlList(organisation, person);
Assert.IsTrue(accessList.CanRead(Organisations.Meta.Name));
session.Rollback();
}
}