Package org.apache.jackrabbit.oak.api

Examples of org.apache.jackrabbit.oak.api.ContentSession


        // create user upfront in order to test update mode
        ExternalUser externalUser = TestLoginModule.externalUser;
        Authorizable user = userManager.createUser(externalUser.getId(), externalUser.getPassword());
        root.commit();

        ContentSession cs = null;
        try {
            cs = login(new SimpleCredentials(userId, new char[0]));

            root.refresh();
            for (String id : ids) {
                if (id.equals(userId)) {
                    Authorizable a = userManager.getAuthorizable(id);
                    assertNotNull(a);
                    for (String prop : TestLoginModule.externalUser.getProperties().keySet()) {
                        assertTrue(a.hasProperty(prop));
                    }
                } else {
                    assertNull(userManager.getAuthorizable(id));
                }
            }
        } finally {
            if (cs != null) {
                cs.close();
            }
            options.clear();
        }
    }
View Full Code Here


        // create user upfront in order to test update mode
        ExternalUser externalUser = TestLoginModule.externalUser;
        Authorizable user = userManager.createUser(externalUser.getId(), externalUser.getPassword());
        root.commit();

        ContentSession cs = null;
        try {
            cs = login(new SimpleCredentials(userId, new char[0]));

            root.refresh();
            for (String id : ids) {
                if (id.equals(userId)) {
                    Authorizable a = userManager.getAuthorizable(id);
                    assertNotNull(a);
                    for (String prop : TestLoginModule.externalUser.getProperties().keySet()) {
                        assertTrue(a.hasProperty(prop));
                    }
                } else {
                    assertNotNull(userManager.getAuthorizable(id));
                }
            }
        } finally {
            if (cs != null) {
                cs.close();
            }
            options.clear();
        }
    }
View Full Code Here

    @Test
    public void testDefaultSync() throws Exception {
        options.put(ExternalLoginModule.PARAM_SYNC_MODE, null);

        ContentSession cs = null;
        try {
            cs = login(new SimpleCredentials(userId, new char[0]));

            root.refresh();
            for (String id : ids) {
                if (id.equals(userId)) {
                    Authorizable a = userManager.getAuthorizable(id);
                    assertNotNull(a);
                    for (String prop : TestLoginModule.externalUser.getProperties().keySet()) {
                        assertTrue(a.hasProperty(prop));
                    }
                } else {
                    assertNotNull(userManager.getAuthorizable(id));
                }
            }
        } finally {
            if (cs != null) {
                cs.close();
            }
            options.clear();
        }
    }
View Full Code Here

    @Test
    public void testNoSync() throws Exception {
        options.put(ExternalLoginModule.PARAM_SYNC_MODE, "");

        ContentSession cs = null;
        try {
            cs = login(new SimpleCredentials(userId, new char[0]));

            root.refresh();
            for (String id : ids) {
                assertNull(userManager.getAuthorizable(id));
            }
        } finally {
            if (cs != null) {
                cs.close();
            }
            options.clear();
        }
    }
View Full Code Here

        super(fixture);
    }

    @Before
    public void setUp() throws CommitFailedException {
        ContentSession session = createContentSession();

        // Add test content
        Root root = session.getLatestRoot();
        Tree tree = root.getTree("/");
        Tree x = tree.addChild("x");
        Tree y = x.addChild("y");
        Tree z = y.addChild("z");
        root.commit();

        // Acquire a fresh new root to avoid problems from lingering state
        this.root = new ImmutableRoot(session.getLatestRoot(), TreeTypeProvider.EMPTY);
    }
View Full Code Here

        super(fixture);
    }

    @Before
    public void setUp() throws CommitFailedException {
        ContentSession session = createContentSession();

        // Add test content
        root = session.getLatestRoot();
        Tree tree = root.getTree("/");
        tree.setProperty("a", 1);
        tree.setProperty("b", 2);
        tree.setProperty("c", 3);
        tree.addChild("x");
        tree.addChild("y");
        tree.addChild("z");
        root.commit();

        // Acquire a fresh new root to avoid problems from lingering state
        root = session.getLatestRoot();
    }
View Full Code Here

        super(fixture);
    }

    @Before
    public void setUp() throws CommitFailedException {
        ContentSession session = createContentSession();

        // Add test content
        root = session.getLatestRoot();
        Tree tree = root.getTree("/");
        tree.setProperty("a", 1);
        tree.setProperty("b", 2);
        tree.setProperty("c", 3);
        tree.addChild("x");
View Full Code Here

        return user;
    }

    @Test
    public void testNullLogin() throws Exception {
        ContentSession cs = null;
        try {
            cs = login(null);
            fail("Null login should fail");
        } catch (LoginException e) {
            // success
        } finally {
            if (cs != null) {
                cs.close();
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testGuestLogin() throws Exception {
        ContentSession cs = login(new GuestCredentials());
        try {
            AuthInfo authInfo = cs.getAuthInfo();
            String anonymousID = UserUtil.getAnonymousId(getUserConfiguration().getParameters());
            assertEquals(anonymousID, authInfo.getUserID());
        } finally {
            cs.close();
        }
    }
View Full Code Here

        // verify initial user-content looks like expected
        Authorizable anonymous = userMgr.getAuthorizable(anonymousID);
        assertNotNull(anonymous);
        assertFalse(root.getTree(anonymous.getPath()).hasProperty(UserConstants.REP_PASSWORD));

        ContentSession cs = null;
        try {
            cs = login(new SimpleCredentials(anonymousID, new char[0]));
            fail("Login with anonymousID should fail since the initial setup doesn't provide a password.");
        } catch (LoginException e) {
            // success
        } finally {
            if (cs != null) {
                cs.close();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.api.ContentSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.