public static Map < String , String > createBasicAuthenticationProperty ( final String username , final String password ) { Map < String , String > map = new TreeMap < String , String > ( ) ; try { String base64Binary = DatatypeConverter . printBase64Binary ( ( username + ":" + password ) . getBytes ( "US-ASCII" ) ) ; map . put ( "Authorization" , "Basic " + base64Binary ) ; } catch ( UnsupportedEncodingException e ) { // unreachable code throw new RuntimeException ( e ) ; } return map ; }
Create HTTP Basic credentials to be used in HTTP get or post methods .