@Override
        public void handle(final Callback[] callbacks) {
            Arrays.stream(callbacks).forEach(callback -> {
                if (callback.getClass().equals(NameCallback.class)) {
                    ((NameCallback) callback).setName(this.userName);
                } else if (callback.getClass().equals(PasswordCallback.class)) {
                    ((PasswordCallback) callback).setPassword(this.password);
                }
            });
        }
A simple JAAS CallbackHandler which accepts a Name String and Password
String in the constructor. Only NameCallbacks and PasswordCallbacks are
accepted in the callback array. This code based loosely on example given
in Sun's javadoc for CallbackHandler interface.
core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/handler/support/jaas/JaasAuthenticationHandler.java