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);
}
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;
}
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));
}
Aggregations