private static byte [ ] canonicalRequestDigest ( URIish uri ) throws NoSuchAlgorithmException { StringBuilder canonicalRequest = new StringBuilder ( ) ; canonicalRequest . append ( "GIT\n" ) // codecommit uses GIT as the request method . append ( uri . getPath ( ) ) . append ( "\n" ) // URI request path . append ( "\n" ) // Query string, always empty for codecommit // Next is canonical headers, codecommit only requires the host header . append ( "host:" ) . append ( uri . getHost ( ) ) . append ( "\n" ) . append ( "\n" ) // canonical // headers // are // always // terminated // by // newline . append ( "host\n" ) ; // The list of canonical headers, only one for // codecommit MessageDigest digest = MessageDigest . getInstance ( SHA_256 ) ; return digest . digest ( canonicalRequest . toString ( ) . getBytes ( ) ) ; }
Creates a message digest .