Package org.jboss.sasl.util

Examples of org.jboss.sasl.util.UsernamePasswordHashUtil


        @Override
        public State execute() {
            String entry;

            try {
                String hash = new UsernamePasswordHashUtil().generateHashedHexURP(values.userName, values.realm,
                        values.password);
                entry = values.userName + "=" + hash;
            } catch (NoSuchAlgorithmException e) {
                return new ErrorState(e.getMessage());
            }
View Full Code Here


                VerifyPasswordCallback vpc = (VerifyPasswordCallback) current;
                if (plainText) {
                    String password = users.get(userName).toString();
                    vpc.setVerified(password.equals(vpc.getPassword()));
                } else {
                    UsernamePasswordHashUtil hashUtil = getHashUtil();
                    String hash;
                    synchronized (hashUtil) {
                        hash = hashUtil.generateHashedHexURP(userName, realm, vpc.getPassword().toCharArray());
                    }
                    String expected = users.get(userName).toString();
                    vpc.setVerified(expected.equals(hash));
                }
            }
View Full Code Here

    }

    private static UsernamePasswordHashUtil getHashUtil() {
        if (hashUtil == null) {
            try {
                hashUtil = new UsernamePasswordHashUtil();
            } catch (NoSuchAlgorithmException e) {
                throw new IllegalStateException(e);
            }
        }
        return hashUtil;
View Full Code Here

    }

    private static UsernamePasswordHashUtil getHashUtil() {
        if (hashUtil == null) {
            try {
                hashUtil = new UsernamePasswordHashUtil();
            } catch (NoSuchAlgorithmException e) {
                throw new IllegalStateException(e);
            }
        }
        return hashUtil;
View Full Code Here

                        }

                        if (credential instanceof DigestCredential) {
                            ((DigestHashCallback) current).setHexHash(((DigestCredential) credential).getHash());
                        } else if (credential instanceof PasswordCredential) {
                            UsernamePasswordHashUtil hashUtil = getHashUtil();
                            String hash;
                            synchronized (hashUtil) {
                                hash = hashUtil.generateHashedHexURP(userName, realmName,
                                        ((PasswordCredential) credential).getPassword());
                            }
                            ((DigestHashCallback) current).setHexHash(hash);
                        } else {
                            throw new UnsupportedCallbackException(current);
                        }
                    } else if (current instanceof VerifyPasswordCallback) {
                        if (credential == null) {
                            throw new UserNotFoundException(userName);
                        }

                        VerifyPasswordCallback vpc = (VerifyPasswordCallback) current;

                        if (credential instanceof PasswordCredential) {
                            vpc.setVerified(Arrays.equals(((PasswordCredential) credential).getPassword(), vpc.getPassword()
                                    .toCharArray()));
                        } else if (credential instanceof DigestCredential) {
                            UsernamePasswordHashUtil hashUtil = getHashUtil();
                            String hash;
                            synchronized (hashUtil) {
                                hash = hashUtil.generateHashedHexURP(userName, realmName, vpc.getPassword().toCharArray());
                            }
                            String expected = ((DigestCredential) credential).getHash();
                            vpc.setVerified(expected.equals(hash));
                        } else if (credential instanceof ValidatePasswordCredential) {
                            vpc.setVerified(((ValidatePasswordCredential) credential).validatePassword(vpc.getPassword()
View Full Code Here

                if (mechOpts.containsKey(DIGEST_PLAIN_TEXT) && Boolean.parseBoolean(mechOpts.get(DIGEST_PLAIN_TEXT))) {
                    validationMode = ValidationMode.PASSWORD;
                } else {
                    validationMode = ValidationMode.DIGEST;
                    try {
                        hashUtil = new UsernamePasswordHashUtil();
                    } catch (NoSuchAlgorithmException e) {
                        throw new IllegalStateException(e);
                    }
                }
            } else {
View Full Code Here

    State update(StateValues stateValues) {
        String[] entry = new String[2];

        try {
            String hash = new UsernamePasswordHashUtil().generateHashedHexURP(stateValues.getUserName(), stateValues.getRealm(),
                    stateValues.getPassword());
            entry[0] = stateValues.getUserName();
            entry[1] = hash;
        } catch (NoSuchAlgorithmException e) {
            return new ErrorState(theConsole, e.getMessage(), null, stateValues);
View Full Code Here

        @Override
        public State execute() {
            String entry;

            try {
                String hash = new UsernamePasswordHashUtil().generateHashedHexURP(values.userName, values.realm,
                        values.password);
                entry = values.userName + "=" + hash;
            } catch (NoSuchAlgorithmException e) {
                return new ErrorState(e.getMessage(), null, values);
            }
View Full Code Here

            // No point backing up the file in a test scenario, just write what we need.
            File usersFile = new File(jbossHomeDir + "/standalone/configuration/mgmt-users.properties");
            FileOutputStream fos = new FileOutputStream(usersFile);
            PrintWriter pw = new PrintWriter(fos);
            pw.println(USERNAME + "=" + new UsernamePasswordHashUtil().generateHashedHexURP(USERNAME, "ManagementRealm", PASSWORD.toCharArray()));
            pw.close();
            fos.close();

            List<String> cmd = new ArrayList<String>();
            cmd.add("java");
View Full Code Here

        @Override
        public State execute() {
            String entry;

            try {
                String hash = new UsernamePasswordHashUtil().generateHashedHexURP(values.userName, values.realm,
                        values.password);
                entry = values.userName + "=" + hash;
            } catch (NoSuchAlgorithmException e) {
                return new ErrorState(e.getMessage());
            }
View Full Code Here

TOP

Related Classes of org.jboss.sasl.util.UsernamePasswordHashUtil

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.