SimplePrivilegeProviderFactory extends AbstractPrivilegeProviderFactory { @Override public PrivilegeController getPrivilegeController() { return privilegeController; } SimplePrivilegeProviderFactory(Function<SessionContext, String> applicationRoleBySessionContextFunction); @Override PrivilegeController getPrivilegeController();  }
@Test public void getPrivilegeController() { createDummySessionContext().runWithContext(() -> { ApplicationPrivilegesInfo privilegesInfo = new ApplicationPrivilegesInfo("org.test"); privilegesInfo.addPrivilegeGroup(new PrivilegeGroup("test", new Privilege("read"), new Privilege("write"))); privilegesInfo.addApplicationRolePreset(new ApplicationRolePreset("admin", new PrivilegeGroupPreset(new PrivilegeGroup("test"), new Privilege("read"), new Privilege("write")))); SimplePrivilegeProviderFactory providerFactory = new SimplePrivilegeProviderFactory(context -> "admin"); PrivilegeProvider privilegeProvider = providerFactory.createPrivilegeProvider(privilegesInfo); assertTrue(privilegeProvider.isAllowed(new PrivilegeGroup("test"), new Privilege("read"))); assertTrue(privilegeProvider.isAllowed(new PrivilegeGroup("test"), new Privilege("write"))); assertFalse(privilegeProvider.isAllowed(new PrivilegeGroup("test"), new Privilege("read2"))); assertFalse(privilegeProvider.isAllowed(new PrivilegeGroup("other"), new Privilege("write"))); }); }