Examples of DigestHashCallback


Examples of org.jboss.sasl.callback.DigestHashCallback

                        ((PasswordCallback) current).setPassword(password.toCharArray());
                    } else if (current instanceof VerifyPasswordCallback) {
                        VerifyPasswordCallback vpc = (VerifyPasswordCallback) current;
                        vpc.setVerified(password.equals(vpc.getPassword()));
                    } else if (current instanceof DigestHashCallback) {
                        DigestHashCallback dhc = (DigestHashCallback) current;
                        try {
                            UsernamePasswordHashUtil uph = new UsernamePasswordHashUtil();
                            if (userName == null || realm == null) {
                                throw new SaslException("Insufficient information to generate hash.");
                            }
                            dhc.setHash(uph.generateHashedURP(userName, realm, password.toCharArray()));
                        } catch (NoSuchAlgorithmException e) {
                            throw new SaslException("Unable to generate hash", e);
                        }
                    }
                }
View Full Code Here

Examples of org.jboss.sasl.callback.DigestHashCallback

                        ((PasswordCallback) current).setPassword(password.toCharArray());
                    } else if (current instanceof VerifyPasswordCallback) {
                        VerifyPasswordCallback vpc = (VerifyPasswordCallback) current;
                        vpc.setVerified(password.equals(vpc.getPassword()));
                    } else if (current instanceof DigestHashCallback) {
                        DigestHashCallback dhc = (DigestHashCallback) current;
                        try {
                            UsernamePasswordHashUtil uph = new UsernamePasswordHashUtil();
                            if (userName == null || realm == null) {
                                throw MESSAGES.insufficientInformationToGenerateHash();
                            }
                            dhc.setHash(uph.generateHashedURP(userName, realm, password.toCharArray()));
                        } catch (NoSuchAlgorithmException e) {
                            throw MESSAGES.unableToGenerateHash(e);
                        }
                    }
                }
View Full Code Here

Examples of org.jboss.sasl.callback.DigestHashCallback

                        ((PasswordCallback) current).setPassword(password.toCharArray());
                    } else if (current instanceof VerifyPasswordCallback) {
                        VerifyPasswordCallback vpc = (VerifyPasswordCallback) current;
                        vpc.setVerified(password.equals(vpc.getPassword()));
                    } else if (current instanceof DigestHashCallback) {
                        DigestHashCallback dhc = (DigestHashCallback) current;
                        try {
                            UsernamePasswordHashUtil uph = new UsernamePasswordHashUtil();
                            if (userName == null || realm == null) {
                                throw MESSAGES.insufficientInformationToGenerateHash();
                            }
                            dhc.setHash(uph.generateHashedURP(userName, realm, password.toCharArray()));
                        } catch (NoSuchAlgorithmException e) {
                            throw MESSAGES.unableToGenerateHash(e);
                        }
                    }
                }
View Full Code Here

Examples of org.jboss.sasl.callback.DigestHashCallback

                        }
                    }
                    pcb.setPassword(password);
                } else if (current instanceof DigestHashCallback && digest != null) {
                    // We don't support an interactive use of this callback so it must have been set in advance.
                    DigestHashCallback dhc = (DigestHashCallback) current;
                    dhc.setHexHash(digest);
                } else {
                    error("Unexpected Callback " + current.getClass().getName());
                    throw new UnsupportedCallbackException(current);
                }
            }
View Full Code Here

Examples of org.jboss.sasl.callback.DigestHashCallback

        }

        // Step 1 - Create Callbacks
        RealmCallback rcb = new RealmCallback("Realm", realm);
        NameCallback ncb = new NameCallback("Username", username);
        Callback credentialCallback = preDigested ? new DigestHashCallback("Password Digest") : new PasswordCallback("Password", false);
        Callback[] callbacks = new Callback[]{rcb, ncb, credentialCallback};

        // Step 2 - Call CallbackHandler
        try {
            callbackHandler.get().handle(callbacks);
        } catch (Exception e) {
            if (ROOT_LOGGER.isDebugEnabled()) {
                ROOT_LOGGER.debug("Callback handler failed", e);
            }
            return null;
        }

        // TODO - Verify that a password was set (Depending on if multiple CallbackHandlers are supported)

        // Step 3 - Generate MD5 and Compare
        try {
            // TODO - The remaining combinations from RFC-2617 need to be added.
            // TODO - Verify all required parameters were set.
            MessageDigest md = MessageDigest.getInstance(MD5);
            byte[] ha1;
            if (preDigested) {
                DigestHashCallback dhc = (DigestHashCallback) credentialCallback;

                ha1 = dhc.getHexHash().getBytes();
            } else {
                md.update(challengeParameters.get(USERNAME).getBytes());
                md.update(COLON);
                md.update(challengeParameters.get(REALM).getBytes());
                md.update(COLON);
View Full Code Here

Examples of org.jboss.sasl.callback.DigestHashCallback

                        }
                    }
                    pcb.setPassword(password);
                } else if (current instanceof DigestHashCallback && digest != null) {
                    // We don't support an interactive use of this callback so it must have been set in advance.
                    DigestHashCallback dhc = (DigestHashCallback) current;
                    dhc.setHexHash(digest);
                } else {
                    printLine("Unexpected Callback " + current.getClass().getName());
                    throw new UnsupportedCallbackException(current);
                }
            }
View Full Code Here

Examples of org.jboss.sasl.callback.DigestHashCallback

        }

        // Step 1 - Create Callbacks
        RealmCallback rcb = new RealmCallback("Realm", realm);
        NameCallback ncb = new NameCallback("Username", username);
        Callback credentialCallback = preDigested ? new DigestHashCallback("Password Digest") : new PasswordCallback("Password", false);
        Callback[] callbacks = new Callback[]{rcb, ncb, credentialCallback};

        // Step 2 - Call CallbackHandler
        try {
            callbackHandler.get().handle(callbacks);
        } catch (Exception e) {
            if (ROOT_LOGGER.isDebugEnabled()) {
                ROOT_LOGGER.debug("Callback handler failed", e);
            }
            return null;
        }

        // TODO - Verify that a password was set (Depending on if multiple CallbackHandlers are supported)

        // Step 3 - Generate MD5 and Compare
        try {
            // TODO - The remaining combinations from RFC-2617 need to be added.
            // TODO - Verify all required parameters were set.
            MessageDigest md = MessageDigest.getInstance(MD5);
            byte[] ha1;
            if (preDigested) {
                DigestHashCallback dhc = (DigestHashCallback) credentialCallback;

                ha1 = dhc.getHexHash().getBytes();
            } else {
                md.update(challengeParameters.get(USERNAME).getBytes());
                md.update(COLON);
                md.update(challengeParameters.get(REALM).getBytes());
                md.update(COLON);
View Full Code Here

Examples of org.jboss.sasl.callback.DigestHashCallback

                            }
                        }
                        pcb.setPassword(password);
                    } else if (current instanceof DigestHashCallback && digest != null) {
                        // We don't support an interactive use of this callback so it must have been set in advance.
                        DigestHashCallback dhc = (DigestHashCallback) current;
                        dhc.setHexHash(digest);
                    } else {
                        printLine("Unexpected Callback " + current.getClass().getName());
                        throw new UnsupportedCallbackException(current);
                    }
                }
View Full Code Here

Examples of org.jboss.sasl.callback.DigestHashCallback

        }

        // Step 1 - Create Callbacks
        RealmCallback rcb = new RealmCallback("Realm", realm);
        NameCallback ncb = new NameCallback("Username", username);
        Callback credentialCallback = preDigested ? new DigestHashCallback("Password Digest") : new PasswordCallback("Password", false);
        Callback[] callbacks = new Callback[]{rcb, ncb, credentialCallback};

        // Step 2 - Call CallbackHandler
        try {
            callbackHandler.handle(callbacks);
        } catch (UserNotFoundException e) {
            if (ROOT_LOGGER.isDebugEnabled()) {
                ROOT_LOGGER.debug(e.getMessage());
            }
            return null;
        } catch (IOException e) {
            throw MESSAGES.invalidCallbackHandler();
        } catch (UnsupportedCallbackException e) {
            throw MESSAGES.invalidCallbackHandler();
        }

        // TODO - Verify that a password was set (Depending on if multiple CallbackHandlers are supported)

        // Step 3 - Generate MD5 and Compare
        try {
            // TODO - The remaining combinations from RFC-2617 need to be added.
            // TODO - Verify all required parameters were set.
            MessageDigest md = MessageDigest.getInstance(MD5);
            byte[] ha1;
            if (preDigested) {
                DigestHashCallback dhc = (DigestHashCallback) credentialCallback;

                ha1 = dhc.getHexHash().getBytes();
            } else {
                md.update(challengeParameters.get(USERNAME).getBytes());
                md.update(COLON);
                md.update(challengeParameters.get(REALM).getBytes());
                md.update(COLON);
View Full Code Here

Examples of org.jboss.sasl.callback.DigestHashCallback

        NameCallback ncb = new NameCallback("User Name", getUsername());

        String password = null;
        switch (validationMode) {
            case DIGEST:
                DigestHashCallback dhc = new DigestHashCallback("Digest");
                handle(new Callback[]{rcb, ncb, dhc});
                password = dhc.getHexHash();

                break;
            case PASSWORD:
                PasswordCallback pcb = new PasswordCallback("Password", false);
                handle(new Callback[]{rcb, ncb, pcb});
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.