Package javax.jcr

Examples of javax.jcr.Repository.login()


            throws Exception {
        synchronized (REPOSITORY_INSTANCES) {
            Repository repo = REPOSITORY_INSTANCES.get(dir);
            if (repo == null) {
                repo = createRepository(dir, xml);
                Session session = repo.login(superuser);
                try {
                    TestContentLoader loader = new TestContentLoader();
                    loader.loadTestContent(session);
                } finally {
                    session.logout();
View Full Code Here


    }

    @Test(expected = NoSuchWorkspaceException.class)
    public void loginInvalidWorkspace() throws RepositoryException {
        Repository repository = getRepository();
        repository.login(new GuestCredentials(), "invalid");
    }

    @Ignore("WIP") // TODO implement workspace management
    @Test
    public void getWorkspaceNames() throws RepositoryException {
View Full Code Here

    public void testLogin() throws RepositoryException {
        Repository repo = getHelper().getRepository();

        // make sure regular simple login works.
        Session s = repo.login(creds);
        s.logout();

        // test if token creation works.
        creds.setAttribute(TOKEN_ATTRIBUTE, "");
        // an additional attribute that must match
View Full Code Here

        // an attribute just for info purposes
        creds.setAttribute("attr", "attr");

        String token = null;

        s = repo.login(creds);
        try {
            // token credentials must be created
            Set<TokenCredentials> tokenCreds = ((SessionImpl) s).getSubject().getPublicCredentials(TokenCredentials.class);
            assertFalse(tokenCreds.isEmpty());
            assertEquals(1, tokenCreds.size());
View Full Code Here

        // login with token only must succeed as well.
        TokenCredentials tokenOnly = new TokenCredentials(token);
        tokenOnly.setAttribute(TOKEN_ATTRIBUTE + ".any", "any");

        s = repo.login(tokenOnly);
        try {
            assertEquals(creds.getUserID(), s.getUserID());

            Set<TokenCredentials> tokenCreds = ((SessionImpl) s).getSubject().getPublicCredentials(TokenCredentials.class);
            assertFalse(tokenCreds.isEmpty());
View Full Code Here

            s.logout();
        }

        // the non-mandatory attribute may have any value if present with the creds.
        tokenOnly.setAttribute("attr", "another");
        s = repo.login(tokenOnly);
        try {
            assertEquals(creds.getUserID(), s.getUserID());
        } finally {
            s.logout();
            tokenOnly.removeAttribute("attr");
View Full Code Here

        }

        // login with token but wrong mandatory attribute
        tokenOnly.setAttribute(TOKEN_ATTRIBUTE + ".any", "another");
        try {
            s = repo.login(tokenOnly);
            s.logout();
            fail("The additional mandatory attr doesn't match. login must fail.");
        } catch (LoginException e) {
            // success
        }
View Full Code Here

        }

        // login with token but missing the mandatory attribute
        tokenOnly.removeAttribute(TOKEN_ATTRIBUTE + ".any");
        try {
            s = repo.login(tokenOnly);
            s.logout();
            fail("The additional mandatory attr is missing. login must fail.");
        } catch (LoginException e) {
            // success
        }
View Full Code Here

            }

        }) {

            public Session login(String workspace) throws RepositoryException {
                return repository.login(superuser, workspace);
            }

            public Session login() throws RepositoryException {
                return repository.login(superuser);
            }
View Full Code Here

            public Session login(String workspace) throws RepositoryException {
                return repository.login(superuser, workspace);
            }

            public Session login() throws RepositoryException {
                return repository.login(superuser);
            }

        };
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.