* 用户登录验证
* @return
*/
public SipcRequest createUserAuthRequest(SipcHeader wwwHeader, int presence, boolean isSupportedMutiConnection, StoreVersion version)
{
SipcRequest req = this.createDefaultSipcRequest(SipcMethod.REGISTER);
Pattern pt = Pattern.compile("Digest algorithm=\"SHA1-sess-v4\",nonce=\"(.*?)\",key=\"(.*?)\",signature=\"(.*?)\"");
Matcher mc = pt.matcher(wwwHeader.getValue());
if(mc.matches()) {
String passHex = PasswordEncrypterV4.encryptV4(this.user.getUserId(),this.user.getPassword());
AuthGeneratorV4 auth = new AuthGeneratorV4();
String aeskey = ConvertHelper.byte2HexStringWithoutSpace(user.getAesKey());
String response = auth.generate(mc.group(2), passHex, mc.group(1), aeskey);
String authString ="Digest response=\""+response+"\",algorithm=\"SHA1-sess-v4\"";
req.addHeader(SipcHeader.AUTHORIZATION, authString);
req.addHeader("AK", "ak-value");
String body = MessageTemplate.TMPL_USER_AUTH;
body = body.replace("{machineCode}", FetionConfig.getString("fetion.sip.machine-code"));
body = body.replace("{sid}", Integer.toString(this.user.getFetionId()));
body = body.replace("{userId}", Integer.toString(this.user.getUserId()));
body = body.replace("{presence}", Integer.toString(presence));
body = body.replace("{personalVersion}", Integer.toString(version.getPersonalVersion()));
body = body.replace("{contactVersion}", Integer.toString(version.getContactVersion()));
req.setBody(new SipcBody(body));
}else {
throw new IllegalStateException("parse wwwHeader failed. wwwHeader="+wwwHeader.getValue());
}