Search in sources :

Example 11 with DefaultWhiteboard

use of org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard 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)

Example 12 with DefaultWhiteboard

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

the class LoginContextProviderImplTest method testGetLoginContextTwice.

@Test
public void testGetLoginContextTwice() throws Exception {
    Configuration.setConfiguration(new Configuration() {

        @Override
        public AppConfigurationEntry[] getAppConfigurationEntry(String applicationName) {
            return new AppConfigurationEntry[] { new AppConfigurationEntry(GuestLoginModule.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL, new HashMap()) };
        }
    });
    LoginContextProvider provider = new LoginContextProviderImpl(AuthenticationConfiguration.DEFAULT_APP_NAME, ConfigurationParameters.EMPTY, getContentRepository(), getSecurityProvider(), new DefaultWhiteboard());
    provider.getLoginContext(null, null);
    LoginContext ctx = provider.getLoginContext(null, null);
    ctx.login();
    assertFalse(ctx.getSubject().getPublicCredentials(GuestCredentials.class).isEmpty());
}
Also used : AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) JaasLoginContext(org.apache.jackrabbit.oak.spi.security.authentication.JaasLoginContext) LoginContext(org.apache.jackrabbit.oak.spi.security.authentication.LoginContext) Configuration(javax.security.auth.login.Configuration) AuthenticationConfiguration(org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration) HashMap(java.util.HashMap) LoginContextProvider(org.apache.jackrabbit.oak.spi.security.authentication.LoginContextProvider) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 13 with DefaultWhiteboard

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

the class LoginContextProviderImplTest method testGetLoginContextWithConfigurationPreset.

@Test
public void testGetLoginContextWithConfigurationPreset() throws Exception {
    Configuration.setConfiguration(new Configuration() {

        @Override
        public AppConfigurationEntry[] getAppConfigurationEntry(String applicationName) {
            return new AppConfigurationEntry[] { new AppConfigurationEntry(GuestLoginModule.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL, new HashMap()) };
        }
    });
    LoginContextProvider provider = new LoginContextProviderImpl(AuthenticationConfiguration.DEFAULT_APP_NAME, ConfigurationParameters.EMPTY, getContentRepository(), getSecurityProvider(), new DefaultWhiteboard());
    LoginContext ctx = provider.getLoginContext(null, null);
    ctx.login();
    assertFalse(ctx.getSubject().getPublicCredentials(GuestCredentials.class).isEmpty());
}
Also used : AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) JaasLoginContext(org.apache.jackrabbit.oak.spi.security.authentication.JaasLoginContext) LoginContext(org.apache.jackrabbit.oak.spi.security.authentication.LoginContext) Configuration(javax.security.auth.login.Configuration) AuthenticationConfiguration(org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration) HashMap(java.util.HashMap) LoginContextProvider(org.apache.jackrabbit.oak.spi.security.authentication.LoginContextProvider) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 14 with DefaultWhiteboard

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

the class InternalSecurityProviderTest method testSetWhiteboard.

@Test
public void testSetWhiteboard() {
    Whiteboard wb = new DefaultWhiteboard();
    securityProvider.setWhiteboard(wb);
    assertSame(wb, securityProvider.getWhiteboard());
}
Also used : DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) Test(org.junit.Test)

Example 15 with DefaultWhiteboard

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

the class RefreshOnGCTest method setup.

@Before
public void setup() throws Exception {
    File directory = createTempFile(getClass().getSimpleName(), "test", new File("target"));
    directory.delete();
    directory.mkdir();
    Whiteboard whiteboard = new DefaultWhiteboard();
    gcMonitor = new GCMonitorTracker();
    gcMonitor.start(whiteboard);
    Oak oak = new Oak(createSegmentTarStore(directory, gcMonitor));
    oak.with(whiteboard);
    repository = new Jcr(oak).createRepository();
}
Also used : GCMonitorTracker(org.apache.jackrabbit.oak.spi.gc.GCMonitorTracker) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Oak(org.apache.jackrabbit.oak.Oak) File.createTempFile(java.io.File.createTempFile) File(java.io.File) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) Before(org.junit.Before)

Aggregations

DefaultWhiteboard (org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard)15 Test (org.junit.Test)13 Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)10 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)3 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)3 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)3 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)3 JaasLoginContext (org.apache.jackrabbit.oak.spi.security.authentication.JaasLoginContext)3 LoginContext (org.apache.jackrabbit.oak.spi.security.authentication.LoginContext)3 LoginContextProvider (org.apache.jackrabbit.oak.spi.security.authentication.LoginContextProvider)3 Closeable (java.io.Closeable)2 HashMap (java.util.HashMap)2 AppConfigurationEntry (javax.security.auth.login.AppConfigurationEntry)2 Configuration (javax.security.auth.login.Configuration)2 Oak (org.apache.jackrabbit.oak.Oak)2 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)2 LongPropertyState (org.apache.jackrabbit.oak.plugins.memory.LongPropertyState)2 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)2 AuthenticationConfiguration (org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2