public static org . springframework . http . HttpHeaders createBasicAuthHeaders ( final String basicAuthUser , final String basicAuthPassword ) { val acceptHeaders = new org . springframework . http . HttpHeaders ( ) ; acceptHeaders . setAccept ( CollectionUtils . wrap ( MediaType . APPLICATION_JSON ) ) ; if ( StringUtils . isNotBlank ( basicAuthUser ) && StringUtils . isNotBlank ( basicAuthPassword ) ) { val authorization = basicAuthUser + ' ' + basicAuthPassword ; val basic = EncodingUtils . encodeBase64 ( authorization . getBytes ( Charset . forName ( "US-ASCII" ) ) ) ; acceptHeaders . set ( org . springframework . http . HttpHeaders . AUTHORIZATION , "Basic " + basic ) ; } return acceptHeaders ; }
Create headers org . springframework . http . http headers .