public static Map<String,String> addAuthHeader(String username,String password,Map<String,String> params){
  String creds=String.format("%s:%s",username,password);
  String encoded=Base64.encodeToString(creds.getBytes(),Base64.NO_WRAP);
  params.put("Authorization","Basic " + encoded);
  return params;
}

public static Map < String , String > addAuthHeader ( String username , String password , Map < String , String > params ) { String creds = String . format ( "%s:%s" , username , password ) ; String encoded = Base64 . encodeToString ( creds . getBytes ( ) , Base64 . NO_WRAP ) ; params . put ( "Authorization" , "Basic " + encoded ) ; return params ; }
adds an authentication header to an existing map of http headers .
