loginmodules/password/pwcommon/src/main/java/org/beiter/michael/authn/jaas/loginmodules/password/common/PasswordCallbackHandler.java
@Override
    // Cannot change the interface to use varags, this interface is owned by javax.security
    @SuppressWarnings("PMD.UseVarargs")
    public final void handle(final Callback[] callbacks)
            throws IOException, UnsupportedCallbackException {

        Validate.notNull(callbacks, "The validated object 'callbacks' is null");

        for (final Callback callback : callbacks) {
            if (callback instanceof NameCallback) {
                final NameCallback nameCallback = (NameCallback) callback;
                nameCallback.setName(username);
            } else if (callback instanceof PasswordCallback) {
                final PasswordCallback passwordCallback = (PasswordCallback) callback;
                passwordCallback.setPassword(password);
            } else if (callback instanceof TextInputCallback) {
                final TextInputCallback textInputCallback = (TextInputCallback) callback;
                textInputCallback.setText(domain);
            } else {
                final String error = "Unsupported callback: "
                        + callback.getClass().getCanonicalName() + " Allowed callbacks are: "
                        + NameCallback.class.getCanonicalName() + " OR "
                        + PasswordCallback.class.getCanonicalName() + " OR "
                        + TextInputCallback.class.getCanonicalName();
                LOG.warn(error);
                throw new UnsupportedCallbackException(callback, error);
            }
        }
    }
@Override
    // Cannot change the interface to use varags, this interface is owned by javax.security
    @SuppressWarnings("PMD.UseVarargs")
    public final void handle(final Callback[] callbacks)
            throws IOException, UnsupportedCallbackException {

        Validate.notNull(callbacks, "The validated object 'callbacks' is null");

        for (final Callback callback : callbacks) {
            if (callback instanceof NameCallback) {
                final NameCallback nameCallback = (NameCallback) callback;
                nameCallback.setName(username);
            } else if (callback instanceof PasswordCallback) {
                final PasswordCallback passwordCallback = (PasswordCallback) callback;
                passwordCallback.setPassword(password);
            } else if (callback instanceof TextInputCallback) {
                final TextInputCallback textInputCallback = (TextInputCallback) callback;
                textInputCallback.setText(domain);
            } else {
                final String error = "Unsupported callback: "
                        + callback.getClass().getCanonicalName() + " Allowed callbacks are: "
                        + NameCallback.class.getCanonicalName() + " OR "
                        + PasswordCallback.class.getCanonicalName() + " OR "
                        + TextInputCallback.class.getCanonicalName();
                LOG.warn(error);
                throw new UnsupportedCallbackException(callback, error);
            }
        }
    }
Retrieve or display the information requested in the provided Callbacks.
<p>
The {@code handle} method implementation checks the
instance(s) of the {@code Callback} object(s) passed in
to retrieve or display the requested information.

@param callbacks an array of {@code Callback} objects provided by an underlying security service which contains
the information requested to be retrieved or displayed.
@throws java.io.IOException          if an input or output error occurs. <p>
@throws UnsupportedCallbackException if the implementation of this method does not support one or more of the
Callbacks specified in the {@code callbacks} parameter.
@throws NullPointerException         When {@code callbacks} is {@code null}