Search in sources :

Example 1 with DefaultPrincipalProvider

use of org.apache.jackrabbit.core.security.principal.DefaultPrincipalProvider in project jackrabbit by apache.

the class DefaultSecurityManager method createDefaultPrincipalProvider.

/**
     * 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;
}
Also used : AbstractPrincipalProvider(org.apache.jackrabbit.core.security.principal.AbstractPrincipalProvider) DefaultPrincipalProvider(org.apache.jackrabbit.core.security.principal.DefaultPrincipalProvider) PrincipalProvider(org.apache.jackrabbit.core.security.principal.PrincipalProvider) DefaultPrincipalProvider(org.apache.jackrabbit.core.security.principal.DefaultPrincipalProvider) Properties(java.util.Properties)

Example 2 with DefaultPrincipalProvider

use of org.apache.jackrabbit.core.security.principal.DefaultPrincipalProvider in project jackrabbit by apache.

the class UserPerWorkspaceSecurityManager method getPrincipalProviderRegistry.

private PrincipalProviderRegistry getPrincipalProviderRegistry(SessionImpl s) throws RepositoryException {
    String wspName = s.getWorkspace().getName();
    synchronized (monitor) {
        PrincipalProviderRegistry p = ppRegistries.get(wspName);
        if (p == null) {
            SystemSession systemSession;
            if (s instanceof SystemSession) {
                systemSession = (SystemSession) s;
            } else {
                RepositoryImpl repo = (RepositoryImpl) getRepository();
                systemSession = repo.getSystemSession(wspName);
                // TODO: review again... this workaround is used in several places.
                repo.markWorkspaceActive(wspName);
            }
            Properties[] moduleConfig = new AuthContextProvider("", ((RepositoryImpl) getRepository()).getConfig().getSecurityConfig().getLoginModuleConfig()).getModuleConfig();
            PrincipalProvider defaultPP = new DefaultPrincipalProvider(systemSession, (UserManagerImpl) getUserManager(systemSession));
            boolean initialized = false;
            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());
            }
            p = new WorkspaceBasedPrincipalProviderRegistry(defaultPP);
            ppRegistries.put(wspName, p);
        }
        return p;
    }
}
Also used : DefaultPrincipalProvider(org.apache.jackrabbit.core.security.principal.DefaultPrincipalProvider) AbstractPrincipalProvider(org.apache.jackrabbit.core.security.principal.AbstractPrincipalProvider) PrincipalProvider(org.apache.jackrabbit.core.security.principal.PrincipalProvider) DefaultPrincipalProvider(org.apache.jackrabbit.core.security.principal.DefaultPrincipalProvider) Properties(java.util.Properties) PrincipalProviderRegistry(org.apache.jackrabbit.core.security.principal.PrincipalProviderRegistry) AuthContextProvider(org.apache.jackrabbit.core.security.authentication.AuthContextProvider)

Example 3 with DefaultPrincipalProvider

use of org.apache.jackrabbit.core.security.principal.DefaultPrincipalProvider in project jackrabbit by apache.

the class DefaultPrincipalProviderTest method setUp.

@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());
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) DefaultPrincipalProvider(org.apache.jackrabbit.core.security.principal.DefaultPrincipalProvider) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) Properties(java.util.Properties) Session(javax.jcr.Session)

Aggregations

Properties (java.util.Properties)3 DefaultPrincipalProvider (org.apache.jackrabbit.core.security.principal.DefaultPrincipalProvider)3 AbstractPrincipalProvider (org.apache.jackrabbit.core.security.principal.AbstractPrincipalProvider)2 PrincipalProvider (org.apache.jackrabbit.core.security.principal.PrincipalProvider)2 Session (javax.jcr.Session)1 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)1 AuthContextProvider (org.apache.jackrabbit.core.security.authentication.AuthContextProvider)1 PrincipalProviderRegistry (org.apache.jackrabbit.core.security.principal.PrincipalProviderRegistry)1 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)1