Search in sources :

Example 1 with WhiteboardAware

use of org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardAware in project jackrabbit-oak by apache.

the class AuthenticationConfigurationImpl method getLoginContextProvider.

//----------------------------------------< AuthenticationConfiguration >---
/**
     * Create a {@code LoginContextProvider} using standard
     * {@link javax.security.auth.login.Configuration#getConfiguration() JAAS}
     * functionality. In case no login configuration for the specified app name
     * can be retrieve this implementation uses the default as defined by
     * {@link org.apache.jackrabbit.oak.spi.security.authentication.ConfigurationUtil#getDefaultConfiguration(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)}.
     * <p>
     * The {@link LoginContextProvider} implementation is intended to be used with
     * <ul>
     *     <li>Regular login using JAAS {@link javax.security.auth.spi.LoginModule} or</li>
     *     <li>Pre-authenticated subjects in which case any authentication
     *     related validation is omitted</li>
     * </ul>
     *
     * <h3>Configuration Options</h3>
     * <ul>
     *     <li>{@link #PARAM_APP_NAME}: The appName passed to
     *     {@code Configuration#getAppConfigurationEntry(String)}. The default
     *     value is {@link #DEFAULT_APP_NAME}.</li>
     * </ul>
     *
     * @param contentRepository The content repository.
     * @return An new instance of {@link LoginContextProvider}.
     */
@Nonnull
@Override
public LoginContextProvider getLoginContextProvider(ContentRepository contentRepository) {
    String appName = getParameters().getConfigValue(PARAM_APP_NAME, DEFAULT_APP_NAME);
    SecurityProvider provider = getSecurityProvider();
    Whiteboard whiteboard = null;
    if (provider instanceof WhiteboardAware) {
        whiteboard = ((WhiteboardAware) provider).getWhiteboard();
    } else {
        log.warn("Unable to obtain whiteboard from SecurityProvider");
    }
    return new LoginContextProviderImpl(appName, getParameters(), contentRepository, getSecurityProvider(), whiteboard);
}
Also used : WhiteboardAware(org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardAware) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) Nonnull(javax.annotation.Nonnull)

Example 2 with WhiteboardAware

use of org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardAware in project jackrabbit-oak by apache.

the class Oak method with.

@Nonnull
public Oak with(@Nonnull Whiteboard whiteboard) {
    this.whiteboard = checkNotNull(whiteboard);
    if (securityProvider instanceof WhiteboardAware) {
        ((WhiteboardAware) securityProvider).setWhiteboard(whiteboard);
    }
    QueryEngineSettings queryEngineSettings = WhiteboardUtils.getService(whiteboard, QueryEngineSettings.class);
    if (queryEngineSettings != null) {
        this.queryEngineSettings = new AnnotatedQueryEngineSettings(queryEngineSettings);
    }
    return this;
}
Also used : WhiteboardAware(org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardAware) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) Nonnull(javax.annotation.Nonnull)

Example 3 with WhiteboardAware

use of org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardAware in project jackrabbit-oak by apache.

the class AuthenticationConfigurationImplTest method testGetLoginCtxProviderWhiteboard.

@Test
public void testGetLoginCtxProviderWhiteboard() {
    SecurityProvider sp = Mockito.mock(SecurityProvider.class, Mockito.withSettings().extraInterfaces(WhiteboardAware.class));
    when(((WhiteboardAware) sp).getWhiteboard()).thenReturn(new DefaultWhiteboard());
    authConfiguration.setSecurityProvider(sp);
    assertNotNull(authConfiguration.getLoginContextProvider(repo));
}
Also used : WhiteboardAware(org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardAware) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) Test(org.junit.Test)

Aggregations

WhiteboardAware (org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardAware)3 Nonnull (javax.annotation.Nonnull)2 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)2 QueryEngineSettings (org.apache.jackrabbit.oak.query.QueryEngineSettings)1 DefaultWhiteboard (org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard)1 Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)1 Test (org.junit.Test)1