Package javax.jcr

Examples of javax.jcr.SimpleCredentials


            info.getPassword());
    }

    @Test
    public void testSetCredentials() {
        final Credentials creds = new SimpleCredentials("user", new char[0]);
        final AuthenticationInfo info = new AuthenticationInfo("test");

        info.put(CREDENTIALS, creds);
        Assert.assertSame(creds, info.get(CREDENTIALS));
    }
View Full Code Here


        final AuthenticationInfo info = new AuthenticationInfo("test");

        assertNull(info.get(CREDENTIALS));
        assertFalse(info.containsKey(CREDENTIALS));

        final Credentials creds = new SimpleCredentials("user", new char[0]);
        info.put(CREDENTIALS, creds);

        assertSame(creds, info.get(CREDENTIALS));

        final String user = "user";
View Full Code Here

    @Test
    public void testPutStringObject() {
        final AuthenticationInfo info = new AuthenticationInfo("test", "user",
            new char[2]);
        info.put(CREDENTIALS,
                new SimpleCredentials("user", new char[2]));

        test_put_fail(info, AuthenticationInfo.AUTH_TYPE, null);
        test_put_fail(info, ResourceResolverFactory.USER, null);
        test_put_fail(info, ResourceResolverFactory.PASSWORD, null);
View Full Code Here

            try {
                // CryptSimpleCredentials.matches(SimpleCredentials credentials)
                Class<?> oldCredsClass = oldCreds.getClass();
                Method matcher = oldCredsClass.getMethod("matches",
                    SimpleCredentials.class);
                SimpleCredentials newCreds = new SimpleCredentials(
                    authorizable.getPrincipal().getName(),
                    oldPassword.toCharArray());
                boolean match = (Boolean) matcher.invoke(oldCreds, newCreds);
                if (match) {
                    return;
View Full Code Here

        SetField.set(c, "repository", repo);
        final Session s = Mockito.mock(Session.class);
        Mockito.when(repo.login(Matchers.any(Credentials.class))).thenAnswer(new Answer<Session>() {
            @Override
            public Session answer(InvocationOnMock invocation) {
                final SimpleCredentials c = (SimpleCredentials)invocation.getArguments()[0];
                if("admin".equals(c.getUserID())) {
                    return s;
                }
                return null;
            }
        });
       
        return c.execute();
    }
View Full Code Here

    }

    @Test
    public void testLogin() throws RepositoryException {
        assertNotNull(repository.login());
        assertNotNull(repository.login(new SimpleCredentials(USER_NAME, PASSWORD)));
        assertNotNull(repository.login(MockJcr.DEFAULT_WORKSPACE));
        assertNotNull(repository.login(new SimpleCredentials(USER_NAME, PASSWORD), MockJcr.DEFAULT_WORKSPACE));
    }
View Full Code Here

                        }
                        REGISTERED_REPOSITORIES.put(address, repository);
                    }
                }

                session = repository.login(new SimpleCredentials(repositoryInfo.getUsername(), repositoryInfo
                        .getPassword().toCharArray()));
                return address;
            } catch (URISyntaxException e) {
                throw new RuntimeException(e);
            } catch (RepositoryException e) {
View Full Code Here

    }

    public static Credentials getCredentials(RepositoryInfo repositoryInfo) {

        return new SimpleCredentials(repositoryInfo.getUsername(), repositoryInfo.getPassword().toCharArray());
    }
View Full Code Here

            return admin;
        }

        // else impersonate as the owner and logout the admin session again
        try {
            return admin.impersonate(new SimpleCredentials(this.classLoaderOwner, new char[0]));
        } finally {
            admin.logout();
        }
    }
View Full Code Here

             */
            private Session getLongLivedSession(final Session slingSession) throws RepositoryException {
                Session adminSession = null;
                final String user = slingSession.getUserID();
                try {
                    final SimpleCredentials credentials = new SimpleCredentials(user, EMPTY_PW);
                    final String wsp = slingSession.getWorkspace().getName();
                    adminSession = SlingDavExServlet.this.repository.loginAdministrative(wsp);
                    return adminSession.impersonate(credentials);
                } catch (RepositoryException re) {

View Full Code Here

TOP

Related Classes of javax.jcr.SimpleCredentials

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.