开发者

How is the post token generated in GWT?

开发者 https://www.devze.com 2022-12-18 01:08 出处:网络
I have requests like 5|0|7|http://localhost:8080/testproject/|29F4EA1240F157649C12466F01F46F60|com.test.client.Greet开发者_高级运维ingService|greetServer|java.lang.String|myInput1|myInput2|1|2|3|4|2|

I have requests like

5|0|7|http://localhost:8080/testproject/|29F4EA1240F157649C12466F01F46F60|com.test.client.Greet开发者_高级运维ingService|greetServer|java.lang.String|myInput1|myInput2|1|2|3|4|2|5|5|6|7|

I would like to know how GWT generates the md5 value 29F4EA1240F157649C12466F01F46F60? Is it based on the client ip and date? Can anyone point me to the correct code? I just find stuff regarding the history token, but that looks different to me.


OK, after some research I think I found the answer.
The keywords you should have been looking for are "strong name" (or "strongName") and/or permutation, since it seems that with the RPC request they send out the permuatation strong name (that MD5 hash), so that you can possibly distinguish on the server side from which permutation the request was send.
The core function is Util.computeStrongName, it computes an MD5 hash (d'oh) of the provided byte array, with the added catch:

/*
 * Include the lengths of the contents components in the hash, so that the
 * hashed sequence of bytes is in a one-to-one correspondence with the
 * possible arguments to this method.
 */

From there, I tracked back to the linkers and then to PermutationResult which is feeding Util.computeStrongName via this function:

/**
 * The compiled JavaScript code as UTF8 bytes.
 */
byte[][] getJs();

Eh, I hope that was at least a bit helpful ;) If this still doesn't answer your question (or you were looking for something different), try in trunk/user/src/com/google/gwt/user/client/rpc (start in RpcRequestBuilder.java).


As Igor said, GWT uses MD5 hashes of your application code to produce unique names for each permutation of each version of your application. The specific hash you referenced is a part of the GWT RPC request payload that identifies a .gwt.rpc serialization policy file on the server. That policy file says which Java objects can be serialized as part of the request, response, or thrown exceptions in the GWT RPC service.

0

精彩评论

暂无评论...
验证码 换一张
取 消