Package org.apache.jackrabbit.oak.api

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


        }
    }

    @Test
    public void testGuestLogin() throws Exception {
        ContentSession cs = null;
        try {
            cs = login(new GuestCredentials());
        } finally {
            if (cs != null) {
                cs.close();
            }
        }
    }
View Full Code Here


        }
    }

    @Test
    public void testInvalidSimpleCredentials() throws Exception {
        ContentSession cs = null;
        try {
            SimpleCredentials sc = new SimpleCredentials("test", new char[0]);
            cs = login(sc);
            fail("Invalid simple credentials login should fail");
        } catch (LoginException e) {
            // success
        } finally {
            if (cs != null) {
                cs.close();
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testInvalidSimpleCredentialsWithAttribute() throws Exception {
        ContentSession cs = null;
        try {
            SimpleCredentials sc = new SimpleCredentials("test", new char[0]);
            sc.setAttribute(".token", "");

            cs = login(sc);
            fail("Invalid simple credentials login should fail");
        } catch (LoginException e) {
            // success
        } finally {
            if (cs != null) {
                cs.close();
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testSimpleCredentials() throws Exception {
        ContentSession cs = null;
        try {
            cs = login(getAdminCredentials());
        } finally {
            if (cs != null) {
                cs.close();
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testSimpleCredentialsWithAttribute() throws Exception {
        ContentSession cs = null;
        try {
            SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
            sc.setAttribute(".token", "");
            cs = login(sc);
        } finally {
            if (cs != null) {
                cs.close();
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testTokenCreationAndLogin() throws Exception {
        ContentSession cs = null;
        try {
            SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
            sc.setAttribute(".token", "");
            cs = login(sc);

            Object token = sc.getAttribute(".token").toString();
            assertNotNull(token);
            TokenCredentials tc = new TokenCredentials(token.toString());

            cs.close();
            cs = login(tc);
        } finally {
            if (cs != null) {
                cs.close();
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testTokenCreationAndImpersonation() throws Exception {
        ContentSession cs = null;
        try {
            SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
            sc.setAttribute(".token", "");

            ImpersonationCredentials ic = new ImpersonationCredentials(sc, new AuthInfoImpl(((SimpleCredentials) getAdminCredentials()).getUserID(), Collections.<String, Object>emptyMap(), Collections.<Principal>emptySet()));
            cs = login(ic);

            Object token = sc.getAttribute(".token").toString();
            assertNotNull(token);
            TokenCredentials tc = new TokenCredentials(token.toString());

            cs.close();
            cs = login(tc);
        } finally {
            if (cs != null) {
                cs.close();
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testInvalidTokenCredentials() throws Exception {
        ContentSession cs = null;
        try {
            cs = login(new TokenCredentials("invalid"));
            fail("Invalid token credentials login should fail");
        } catch (LoginException e) {
            // success
        } finally {
            if (cs != null) {
                cs.close();
            }
        }
    }
View Full Code Here

        TokenProvider tp = tc.getTokenProvider(root);

        SimpleCredentials sc = (SimpleCredentials) getAdminCredentials();
        TokenInfo info = tp.createToken(sc.getUserID(), Collections.<String, Object>emptyMap());

        ContentSession cs = login(new TokenCredentials(info.getToken()));
        try {
            assertEquals(sc.getUserID(), cs.getAuthInfo().getUserID());
        } finally {
            cs.close();
        }
    }
View Full Code Here

            } else if (attributes.containsKey(REFRESH_INTERVAL)) {
                throw new RepositoryException("Duplicate attribute '" + REFRESH_INTERVAL + "'.");
            }

            RefreshStrategy refreshStrategy = createRefreshStrategy(refreshInterval);
            ContentSession contentSession = contentRepository.login(credentials, workspaceName);
            SessionDelegate sessionDelegate = createSessionDelegate(refreshStrategy, contentSession);
            SessionContext context = createSessionContext(
                    statisticManager, securityProvider, createAttributes(refreshInterval), sessionDelegate);
            return context.getSession();
        } catch (LoginException e) {
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.