Code example for UnsupportedCallbackException

0
        if (callback instanceof NameCallback) {
            handleNameCallback((NameCallback) callback);
        } else if (callback instanceof PasswordCallback) {
            handlePasswordCallback((PasswordCallback) callback);
        } else { 
            throw new UnsupportedCallbackException(callback);
        } 
    } 
 
    private void handleNameCallback(final NameCallback callback) {
        callback.setName(username);
    } 
 
    private void handlePasswordCallback(final PasswordCallback callback) {
        callback.setPassword(password.toCharArray());
    } 
 
}