static String calculateStringToSignV2 ( URI serviceUri , Map < String , String > parameters ) { StringBuilder data = new StringBuilder ( ) ; data . append ( "POST" ) ; data . append ( "\n" ) ; data . append ( serviceUri . getHost ( ) . toLowerCase ( ) ) ; if ( ! usesStandardPort ( serviceUri ) ) { data . append ( ":" ) ; data . append ( serviceUri . getPort ( ) ) ; } data . append ( "\n" ) ; String uri = serviceUri . getPath ( ) ; data . append ( MwsUtl . urlEncode ( uri , true ) ) ; data . append ( "\n" ) ; Map < String , String > sorted = new TreeMap < String , String > ( ) ; sorted . putAll ( parameters ) ; Iterator < Map . Entry < String , String > > pairs = sorted . entrySet ( ) . iterator ( ) ; while ( pairs . hasNext ( ) ) { Map . Entry < String , String > pair = pairs . next ( ) ; String key = pair . getKey ( ) ; data . append ( MwsUtl . urlEncode ( key , false ) ) ; data . append ( "=" ) ; String value = pair . getValue ( ) ; data . append ( MwsUtl . urlEncode ( value , false ) ) ; if ( pairs . hasNext ( ) ) { data . append ( "&" ) ; } } return data . toString ( ) ; }
Calculate String to Sign for SignatureVersion 2