Package javax.jcr

Examples of javax.jcr.SimpleCredentials


            // process authenticated user
            if (authenticated) {
                if (creds instanceof SimpleCredentials) {
                    credentials = (SimpleCredentials) creds;
                } else {
                    credentials = new SimpleCredentials(getUserID(creds), new char[0]);
                }
                principal = userPrincipal;
                return true;
            }
        } catch (RepositoryException e) {
View Full Code Here


                log.warn(e.getCallback().getClass().getName() + " not supported: Unable to perform Impersonation.");
            } catch (IOException e) {
                log.error("Impersonation-Callback failed: " + e.getMessage() + ": Unable to perform Impersonation.");
            }
        } else if (credentials instanceof SimpleCredentials) {
            SimpleCredentials sc = (SimpleCredentials) credentials;
            impersonator = (Subject) sc.getAttribute(SecurityConstants.IMPERSONATOR_ATTRIBUTE);
        }
        return impersonator;
    }
View Full Code Here

            creds = ((ImpersonationCredentials) credentials).getBaseCredentials();
        } else {
            creds = credentials;
        }
        if (creds instanceof SimpleCredentials) {
            SimpleCredentials sc = (SimpleCredentials) creds;
            for (String attrName : sc.getAttributeNames()) {
                attributes.put(attrName, sc.getAttribute(attrName));
            }
        }
        return new AuthInfoImpl(userId, attributes, principals);
    }
View Full Code Here

            if (user.isDisabled()) {
                throw new LoginException("User with ID " + userId + " has been disabled: "+ user.getDisabledReason());
            }

            if (credentials instanceof SimpleCredentials) {
                SimpleCredentials creds = (SimpleCredentials) credentials;
                Credentials userCreds = user.getCredentials();
                if (userId.equals(creds.getUserID()) && userCreds instanceof CredentialsImpl) {
                    success = PasswordUtil.isSame(((CredentialsImpl) userCreds).getPasswordHash(), creds.getPassword());
                }
                checkSuccess(success, "UserId/Password mismatch.");
            } else if (credentials instanceof ImpersonationCredentials) {
                ImpersonationCredentials ipCreds = (ImpersonationCredentials) credentials;
                AuthInfo info = ipCreds.getImpersonatorInfo();
View Full Code Here

     *         object contain a {@link #TOKEN_ATTRIBUTE} attribute with an empty value;
     *         {@code false} otherwise.
     */
    @Override
    public boolean doCreateToken(Credentials credentials) {
        SimpleCredentials sc = extractSimpleCredentials(credentials);
        if (sc == null) {
            return false;
        } else {
            Object attr = sc.getAttribute(TOKEN_ATTRIBUTE);
            return (attr != null && "".equals(attr.toString()));
        }
    }
View Full Code Here

     * @return A new {@code TokenInfo} or {@code null} if the token could not
     *         be created.
     */
    @Override
    public TokenInfo createToken(Credentials credentials) {
        SimpleCredentials sc = extractSimpleCredentials(credentials);
        TokenInfo tokenInfo = null;
        if (sc != null) {
            String[] attrNames = sc.getAttributeNames();
            Map<String, String> attributes = new HashMap<String, String>(attrNames.length);
            for (String attrName : sc.getAttributeNames()) {
                attributes.put(attrName, sc.getAttribute(attrName).toString());
            }
            tokenInfo = createToken(sc.getUserID(), attributes);
            if (tokenInfo != null) {
                // also set the new token to the simple credentials.
                sc.setAttribute(TOKEN_ATTRIBUTE, tokenInfo.getToken());
            }
        }

        return tokenInfo;
    }
View Full Code Here

    //------------------------------------------------------------< private >---
    private AuthInfo createAuthInfo(@Nonnull String userId, Set<? extends Principal> principals) {
        Map<String, Object> attributes = new HashMap<String, Object>();
        if (credentials instanceof SimpleCredentials) {
            SimpleCredentials sc = (SimpleCredentials) credentials;
            for (String attrName : sc.getAttributeNames()) {
                attributes.put(attrName, sc.getAttribute(attrName));
            }
        }
        return new AuthInfoImpl(userId, attributes, principals);
    }
View Full Code Here

        final MongoMK mk1 = mks.get(0);
        final MongoMK mk2 = mks.get(1);
        Repository r1 = new Jcr(mk1).createRepository();
        Repository r2 = new Jcr(mk2).createRepository();

        Session s1 = r1.login(new SimpleCredentials("admin", "admin".toCharArray()));
        Session s2 = r2.login(new SimpleCredentials("admin", "admin".toCharArray()));

        ensureIndex(s1.getRootNode(), PROP_NAME);
        syncMKs(1);
        ensureIndex(s2.getRootNode(), PROP_NAME);
View Full Code Here

        final MongoMK mk3 = mks.get(2);
        Repository r1 = new Jcr(mk1).createRepository();
        Repository r2 = new Jcr(mk2).createRepository();
        Repository r3 = new Jcr(mk3).createRepository();

        Session s1 = r1.login(new SimpleCredentials("admin", "admin".toCharArray()));
        Session s2 = r2.login(new SimpleCredentials("admin", "admin".toCharArray()));
        Session s3 = r3.login(new SimpleCredentials("admin", "admin".toCharArray()));

        ensureIndex(s1.getRootNode(), PROP_NAME);
        syncMKs(1);
        ensureIndex(s2.getRootNode(), PROP_NAME);
        ensureIndex(s3.getRootNode(), PROP_NAME);
View Full Code Here

        final MongoMK mk1 = mks.get(0);
        final MongoMK mk2 = mks.get(1);
        Repository r1 = new Jcr(mk1).createRepository();
        Repository r2 = new Jcr(mk2).createRepository();

        Session s1 = r1.login(new SimpleCredentials("admin", "admin".toCharArray()));
        Session s2 = r2.login(new SimpleCredentials("admin", "admin".toCharArray()));

        Node root1 = s1.getRootNode().addNode("session-1");
        s1.save();
        Node root2 = s2.getRootNode().addNode("session-2");
        s2.save();
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.