Package javax.jcr

Examples of javax.jcr.SimpleCredentials


            try {
              // create a repo instance (startup)
              multiThreadedRepository = RulesRepositoryConfigurator.getInstance(null).getJCRRepository();

                // create a session to config repo
                Session session = multiThreadedRepository.login(new SimpleCredentials("alan_parsons", "password".toCharArray()));
                RulesRepositoryAdministrator admin = new RulesRepositoryAdministrator(session);

                // clear out and setup
                if (admin.isRepositoryInitialized()) {
                    admin.clearRulesRepository();
                }
                RulesRepositoryConfigurator.getInstance(null).setupRepository( session);
            } catch (Exception e) {
                throw new RulesRepositoryException(e);
            }
        }

        // associate this repo instance with thread specific sessions every time.
        Session session;
        try {
            session = multiThreadedRepository.login(new SimpleCredentials("alan_parsons", "password".toCharArray()));
            RulesRepository threadLocalRepo = new RulesRepository(session);
            return threadLocalRepo;
        } catch (LoginException e) {
            e.printStackTrace();
        } catch (RepositoryException e) {
View Full Code Here


        sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, new TestCredentials());
        AbstractLoginModule lm = initLoginModule(TestCredentials.class, sharedState);
        assertTrue(lm.getSharedCredentials() instanceof TestCredentials);

        sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, new SimpleCredentials("test", "test".toCharArray()));
        lm = initLoginModule(TestCredentials.class, sharedState);
        assertTrue(lm.getSharedCredentials() instanceof SimpleCredentials);

        lm = initLoginModule(SimpleCredentials.class, sharedState);
        assertTrue(lm.getSharedCredentials() instanceof SimpleCredentials);
View Full Code Here

        sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, new TestCredentials());
        AbstractLoginModule lm = initLoginModule(TestCredentials.class, sharedState);
        assertTrue(lm.getCredentials() instanceof TestCredentials);

        SimpleCredentials sc = new SimpleCredentials("test", "test".toCharArray());
        sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, sc);
        lm = initLoginModule(TestCredentials.class, sharedState);
        assertNull(lm.getCredentials());

        sharedState.put(AbstractLoginModule.SHARED_KEY_CREDENTIALS, sc);
View Full Code Here

        admin.save();
        return getRepository().login(new GuestCredentials());
    }

    protected Session createAdminSession() throws RepositoryException {
        return getRepository().login(new SimpleCredentials("admin", "admin".toCharArray()));
    }
View Full Code Here

    protected JcrEndpoint(String endpointUri, JcrComponent component) {
        super(endpointUri, component);
        try {
            URI uri = new URI(endpointUri);
            if (uri.getUserInfo() != null && uri.getAuthority() != null) {
                this.credentials = new SimpleCredentials(uri.getUserInfo(), uri.getAuthority().toCharArray());
            }
            this.repository = (Repository) component.getCamelContext().getRegistry().lookup(uri.getHost());
            if (repository == null) {
                throw new RuntimeCamelException("No JCR repository defined under '" + uri.getHost() + "'");
            }
View Full Code Here

    public void testJcrRoute() throws Exception {
        Exchange exchange = createExchangeWithBody("<hello>world!</hello>");
        Exchange out = template.send("direct:a", exchange);
        assertNotNull(out);
        String uuid = out.getOut().getBody(String.class);
        Session session = repository.login(new SimpleCredentials("user", "pass".toCharArray()));
        try {
            Node node = session.getNodeByUUID(uuid);
            assertNotNull(node);
            assertEquals("/home/test/node", node.getPath());
            assertEquals("<hello>world!</hello>", node.getProperty("my.contents.property").getString());
View Full Code Here

            authCtx.login();

            // create session, and add SimpleCredentials attributes (JCR-1932)
            SessionImpl session = createSession(authCtx, workspaceName);
            if (credentials instanceof SimpleCredentials) {
                SimpleCredentials sc = (SimpleCredentials) credentials;
                for (String name : sc.getAttributeNames()) {
                    session.setAttribute(name, sc.getAttribute(name));
                }
            }

            log.debug("User {} logged in to workspace {}",
                    session.getUserID(), workspaceName);
View Full Code Here

            throw new RepositoryException(msg);
        }

        // set IMPERSONATOR_ATTRIBUTE attribute of given credentials
        // with subject of current session
        SimpleCredentials creds = (SimpleCredentials) otherCredentials;
        creds.setAttribute(SecurityConstants.IMPERSONATOR_ATTRIBUTE, subject);

        try {
            return rep.login(otherCredentials, getWorkspace().getName());
        } catch (NoSuchWorkspaceException nswe) {
            // should never get here...
            String msg = "impersonate failed";
            log.error(msg, nswe);
            throw new RepositoryException(msg, nswe);
        } finally {
            // make sure IMPERSONATOR_ATTRIBUTE is removed
            creds.removeAttribute(SecurityConstants.IMPERSONATOR_ATTRIBUTE);
        }
    }
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();

        Principal p = getTestPrincipal();
        String pw = buildPassword(p);
        creds = new SimpleCredentials(p.getName(), pw.toCharArray());

        User u = userMgr.createUser(p.getName(), pw);
        save(superuser);

        uID = u.getID();
View Full Code Here

        for (String pw : pwds.keySet()) {
            u.changePassword(pw);

            String plain = pwds.get(pw);
            SimpleCredentials sc = new SimpleCredentials(u.getID(), plain.toCharArray());
            CryptedSimpleCredentials cc = (CryptedSimpleCredentials) u.getCredentials();

            assertTrue(cc.matches(sc));
        }

        // valid passwords, non-matching plain text
        Map<String, String>noMatch = new HashMap<String, String>();
        noMatch.put("{"+SecurityConstants.DEFAULT_DIGEST+"}", "");
        noMatch.put("{"+SecurityConstants.DEFAULT_DIGEST+"}", "{"+SecurityConstants.DEFAULT_DIGEST+"}");
        noMatch.put("{"+SecurityConstants.DEFAULT_DIGEST+"}any", "any");
        noMatch.put("{"+SecurityConstants.DEFAULT_DIGEST+"}any", "{"+SecurityConstants.DEFAULT_DIGEST+"}any");
        noMatch.put(sha1Hash, sha1Hash);
        noMatch.put(md5Hash, md5Hash);

        for (String pw : noMatch.keySet()) {
            u.changePassword(pw);

            String plain = noMatch.get(pw);
            SimpleCredentials sc = new SimpleCredentials(u.getID(), plain.toCharArray());
            CryptedSimpleCredentials cc = (CryptedSimpleCredentials) u.getCredentials();

            assertFalse(cc.matches(sc));
        }
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.