ho risolto così:

codice:
Authenticator.setDefault(new Authenticator() {
                 @Override 
                protected PasswordAuthentication getPasswordAuthentication() {  
                      return new PasswordAuthentication( 
                        username,
                         password.toCharArray());
                 }            
 });