/** * Creates the default principal provider used to create the * {@link PrincipalProviderRegistry}. * * @return An new instance of <code>DefaultPrincipalProvider</code>. * @throws RepositoryException If an error occurs. */ protected PrincipalProvider createDefaultPrincipalProvider(Properties[] moduleConfig) throws RepositoryException { boolean initialized = false; PrincipalProvider defaultPP = new DefaultPrincipalProvider(this.systemSession, (UserManagerImpl) systemUserManager); for (Properties props : moduleConfig) { //GRANITE-4470: apply config to DefaultPrincipalProvider if there is no explicit PrincipalProvider configured if (!props.containsKey(LoginModuleConfig.PARAM_PRINCIPAL_PROVIDER_CLASS) && props.containsKey(AbstractPrincipalProvider.MAXSIZE_KEY)) { defaultPP.init(props); initialized = true; break; } } if (!initialized) { defaultPP.init(new Properties()); } return defaultPP; }
/** * Creates the default principal provider used to create the * {@link PrincipalProviderRegistry}. * * @return An new instance of <code>DefaultPrincipalProvider</code>. * @throws RepositoryException If an error occurs. */ protected PrincipalProvider createDefaultPrincipalProvider(Properties[] moduleConfig) throws RepositoryException { boolean initialized = false; PrincipalProvider defaultPP = new DefaultPrincipalProvider(this.systemSession, (UserManagerImpl) systemUserManager); for (Properties props : moduleConfig) { //GRANITE-4470: apply config to DefaultPrincipalProvider if there is no explicit PrincipalProvider configured if (!props.containsKey(LoginModuleConfig.PARAM_PRINCIPAL_PROVIDER_CLASS) && props.containsKey(AbstractPrincipalProvider.MAXSIZE_KEY)) { defaultPP.init(props); initialized = true; break; } } if (!initialized) { defaultPP.init(new Properties()); } return defaultPP; }
Class pc = Class.forName(className, true, BeanConfig.getDefaultClassLoader()); PrincipalProvider pp = (PrincipalProvider) pc.newInstance(); pp.init(config); return pp; } catch (ClassNotFoundException e) {
Class pc = Class.forName(className, true, BeanConfig.getDefaultClassLoader()); PrincipalProvider pp = (PrincipalProvider) pc.newInstance(); pp.init(config); return pp; } catch (ClassNotFoundException e) {
/** * Test if a group which is not item based will be wrapped by a JackrabbitPrincipal implementation. * @throws NotExecutableException * @throws RepositoryException */ public void testJackrabbitPrincipal() throws NotExecutableException, RepositoryException { final PrincipalProvider testProvider = new CustomPrincipalProvider(); testProvider.init(new Properties()); PrincipalManagerImpl principalManager = new PrincipalManagerImpl(superuser, new PrincipalProvider[] { testProvider }); Principal principalFromManager = principalManager.getPrincipal(TESTGROUP_NAME); assertTrue(principalFromManager instanceof JackrabbitPrincipal); } }
@Override protected void setUp() throws Exception { super.setUp(); if (!(userMgr instanceof UserManagerImpl)) { throw new NotExecutableException(); } UserManagerImpl umgr = (UserManagerImpl) userMgr; // Workaround for testing cache behaviour that relies on observation: // - retrieve session attached to the userManager implementation. // - using superuser will not work if users are stored in a different workspace. Authorizable a = umgr.getAuthorizable(getPrincipalSetFromSession(superuser).iterator().next()); Session s = ((AuthorizableImpl) a).getNode().getSession(); principalProvider = new DefaultPrincipalProvider(s, umgr); principalProvider.init(new Properties()); }
public void testNegativeCacheEntries() throws RepositoryException, NotExecutableException { String unknownName = "UnknownPrincipal"; PrincipalProvider caching = new DummyProvider(); Properties options = new Properties(); options.setProperty(DefaultPrincipalProvider.NEGATIVE_ENTRY_KEY, "true"); caching.init(options); // accessing from wrapper must not throw! as negative entry is expected // to be in the cache (default behavior of the DefaultPrincipalProvider) assertNull(caching.getPrincipal(unknownName)); assertNull(caching.getPrincipal(unknownName)); PrincipalProvider throwing = new DummyProvider(); options = new Properties(); options.setProperty(DefaultPrincipalProvider.NEGATIVE_ENTRY_KEY, "false"); throwing.init(options); // however: the noNegativeCacheProvider configured NOT to cache null-results // is expected to call 'providePrincipal' for each call to 'getPrincipal' // with a principalName that doesn't exist. assertNull(throwing.getPrincipal(unknownName)); try { throwing.getPrincipal(unknownName); fail("exception expected"); } catch (UnsupportedOperationException e) { // success } }