public Map < String , String > signRequest ( String accessKey , String secretKey , String httpMethod , String endpointURL , String reqPath , Map < String , String > headers , MultivaluedMap < String , String > params , byte [ ] jsonEntity ) { if ( StringUtils . isBlank ( accessKey ) ) { logger . error ( "Blank access key: {} {}" , httpMethod , reqPath ) ; return headers ; } if ( StringUtils . isBlank ( secretKey ) ) { logger . debug ( "Anonymous request: {} {}" , httpMethod , reqPath ) ; if ( headers == null ) { headers = new HashMap <> ( ) ; } headers . put ( HttpHeaders . AUTHORIZATION , "Anonymous " + accessKey ) ; return headers ; } if ( httpMethod == null ) { httpMethod = HttpMethod . GET ; } InputStream in = null ; Map < String , String > sigParams = new HashMap <> ( ) ; if ( params != null ) { for ( Map . Entry < String , List < String > > param : params . entrySet ( ) ) { String key = param . getKey ( ) ; List < String > value = param . getValue ( ) ; if ( value != null && ! value . isEmpty ( ) && value . get ( 0 ) != null ) { sigParams . put ( key , value . get ( 0 ) ) ; } } } if ( jsonEntity != null && jsonEntity . length > 0 ) { in = new ByteArrayInputStream ( jsonEntity ) ; } return sign ( httpMethod , endpointURL , reqPath , headers , sigParams , in , accessKey , secretKey ) ; }
Builds and signs a request to an API endpoint using the provided credentials .