Search in sources :

Example 16 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() throws Exception {
    Whiteboard wb = new DefaultWhiteboard();
    SecurityProvider sp = mock(SecurityProvider.class, Mockito.withSettings().extraInterfaces(WhiteboardAware.class));
    when(((WhiteboardAware) sp).getWhiteboard()).thenReturn(wb);
    authConfiguration.setSecurityProvider(sp);
    LoginContextProvider lcp = authConfiguration.getLoginContextProvider(repo);
    assertTrue(lcp instanceof LoginContextProviderImpl);
    Field f = LoginContextProviderImpl.class.getDeclaredField("whiteboard");
    f.setAccessible(true);
    assertSame(wb, f.get(lcp));
}
Also used : Field(java.lang.reflect.Field) WhiteboardAware(org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardAware) LoginContextProvider(org.apache.jackrabbit.oak.spi.security.authentication.LoginContextProvider) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) Test(org.junit.Test)

Example 17 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 18 with DefaultWhiteboard

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

the class AbstractUserTest method before.

@Before
public void before() throws Exception {
    super.before();
    SecurityProvider sp = getSecurityProvider();
    Whiteboard wb = null;
    if (sp instanceof WhiteboardAware) {
        wb = ((WhiteboardAware) sp).getWhiteboard();
    }
    if (wb == null) {
        wb = new DefaultWhiteboard();
    }
    dynamicMembershipService.start(wb);
}
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) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) Before(org.junit.Before)

Example 19 with DefaultWhiteboard

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

the class SlowQueryMetricTest method setUp.

@Before
public void setUp() {
    queryEngineSettings.setLimitReads(11);
    Whiteboard whiteboard = new DefaultWhiteboard();
    whiteboard.register(StatisticsProvider.class, statsProvider, Collections.emptyMap());
    oak = new Oak().with(new OpenSecurityProvider()).with(new InitialContent()).with(queryEngineSettings).with(whiteboard);
    repository = oak.createContentRepository();
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Oak(org.apache.jackrabbit.oak.Oak) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Before(org.junit.Before)

Example 20 with DefaultWhiteboard

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

the class L4_CustomAccessControlManagementTest method testImportNodeWithPolicy.

@Test
public void testImportNodeWithPolicy() throws Exception {
    Repository jcrRepository = new RepositoryImpl(getContentRepository(), new DefaultWhiteboard(), getSecurityProvider(), Jcr.DEFAULT_OBSERVATION_QUEUE_LENGTH, null, false);
    Session adminSession = jcrRepository.login(getAdminCredentials(), null);
    try {
        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<sv:node sv:name=\"another2\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" + "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>oak:Unstructured</sv:value></sv:property>" + "<sv:property sv:name=\"jcr:mixinTypes\" sv:type=\"Name\"><sv:value>rep:ThreeRolesMixin</sv:value></sv:property>" + "<sv:node sv:name=\"rep:threeRolesPolicy\" " + "<sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:ThreeRolesPolicy</sv:value></sv:property>" + "<sv:property sv:name=\"rep:readers\" sv:type=\"String\"><sv:value>principalR</sv:value></sv:property>" + "</sv:node>" + "</sv:node>";
        adminSession.importXML("/test", new ByteArrayInputStream(xml.getBytes()), ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
        Node n = adminSession.getNode("/test/another");
        AccessControlPolicy[] policies = adminSession.getAccessControlManager().getPolicies("/test/another");
        assertTrue(policies.length > 0);
    } finally {
        adminSession.refresh(false);
        adminSession.logout();
    }
}
Also used : Repository(javax.jcr.Repository) NamedAccessControlPolicy(javax.jcr.security.NamedAccessControlPolicy) AccessControlPolicy(javax.jcr.security.AccessControlPolicy) ByteArrayInputStream(java.io.ByteArrayInputStream) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Node(javax.jcr.Node) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) Session(javax.jcr.Session) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

DefaultWhiteboard (org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard)26 Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)21 Test (org.junit.Test)16 Before (org.junit.Before)5 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)4 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)4 Map (java.util.Map)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 Oak (org.apache.jackrabbit.oak.Oak)3 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)3 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)3 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)3 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)3 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)3 Closeable (java.io.Closeable)2 Repository (javax.jcr.Repository)2 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)2 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)2 BlobAccessProvider (org.apache.jackrabbit.oak.api.blob.BlobAccessProvider)2 RepositoryImpl (org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl)2