Package org.apache.jackrabbit.core.security.authentication

Examples of org.apache.jackrabbit.core.security.authentication.CryptedSimpleCredentials


        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));
        }

        // invalid pw string
        try {
            u.changePassword(null);
View Full Code Here


     * @return
     * @throws RepositoryException
     */
    static String buildPasswordValue(String password) throws RepositoryException {
        try {
            return new CryptedSimpleCredentials("_", password).getPassword();
        } catch (NoSuchAlgorithmException e) {
            throw new RepositoryException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RepositoryException(e);
        }
View Full Code Here

     * @see User#getCredentials()
     */
    public Credentials getCredentials() throws RepositoryException {
        try {
            String password = getNode().getProperty(P_PASSWORD).getString();
            return new CryptedSimpleCredentials(getID(), password);
        } catch (NoSuchAlgorithmException e) {
            throw new RepositoryException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RepositoryException(e);
        }
View Full Code Here

     * @return
     * @throws RepositoryException
     */
    static String buildPasswordValue(String password) throws RepositoryException {
        try {
            CryptedSimpleCredentials creds = new CryptedSimpleCredentials("_", password);
            return creds.getPassword();
        } catch (NoSuchAlgorithmException e) {
            throw new RepositoryException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RepositoryException(e);
        }
View Full Code Here

     * @see User#getCredentials()
     */
    public Credentials getCredentials() throws RepositoryException {
        try {
            String password = getNode().getProperty(P_PASSWORD).getString();
            Credentials creds = new CryptedSimpleCredentials(getID(), password);
            return creds;
        } catch (NoSuchAlgorithmException e) {
            throw new RepositoryException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RepositoryException(e);
View Full Code Here

     * @return
     * @throws RepositoryException
     */
    static String buildPasswordValue(String password) throws RepositoryException {
        try {
            return new CryptedSimpleCredentials("_", password).getPassword();
        } catch (NoSuchAlgorithmException e) {
            throw new RepositoryException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RepositoryException(e);
        }
View Full Code Here

     * @see User#getCredentials()
     */
    public Credentials getCredentials() throws RepositoryException {
        try {
            String password = getNode().getProperty(P_PASSWORD).getString();
            return new CryptedSimpleCredentials(getID(), password);
        } catch (NoSuchAlgorithmException e) {
            throw new RepositoryException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RepositoryException(e);
        }
View Full Code Here

     * @return
     * @throws RepositoryException
     */
    static String buildPasswordValue(String password) throws RepositoryException {
        try {
            return new CryptedSimpleCredentials("_", password).getPassword();
        } catch (NoSuchAlgorithmException e) {
            throw new RepositoryException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RepositoryException(e);
        }
View Full Code Here

     * @see User#getCredentials()
     */
    public Credentials getCredentials() throws RepositoryException {
        try {
            String password = getNode().getProperty(P_PASSWORD).getString();
            return new CryptedSimpleCredentials(getID(), password);
        } catch (NoSuchAlgorithmException e) {
            throw new RepositoryException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RepositoryException(e);
        }
View Full Code Here

     * @see User#changePassword(String, String)
     */
    public void changePassword(String password, String oldPassword) throws RepositoryException {
        // make sure the old password matches.
        try {
            CryptedSimpleCredentials csc = (CryptedSimpleCredentials) getCredentials();
            SimpleCredentials creds = new SimpleCredentials(getID(), oldPassword.toCharArray());
            if (!csc.matches(creds)) {
                throw new RepositoryException("Failed to change password: Old password does not match.");
            }
        } catch (NoSuchAlgorithmException e) {
            throw new RepositoryException("Cannot change password: failed to validate old password.");
        } catch (UnsupportedEncodingException e) {
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.security.authentication.CryptedSimpleCredentials

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.