Commit 45969a00b74b5a240c0dc6e2c37f5381cd0cb65f

Authored by lawrencehj
1 parent 9e8cab60

修正设备注册认证时验证Response计算的错误

src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java
... ... @@ -194,12 +194,13 @@ public class DigestServerAuthenticationHelper {
194 194  
195 195 // 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。
196 196 // 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护
197   - //String cNonce = authHeader.getCNonce();
  197 + String cnonce = authHeader.getCNonce();
198 198  
199 199 // nonce计数器,是一个16进制的数值,表示同一nonce下客户端发送出请求的数量
200 200 int nc = authHeader.getNonceCount();
201   - String ncStr = new DecimalFormat("00000000").format(nc);
202   -// String ncStr = new DecimalFormat("00000000").format(Integer.parseInt(nc + "", 16));
  201 + String ncStr = String.format("%08x", nc).toUpperCase();
  202 + // String ncStr = new DecimalFormat("00000000").format(nc);
  203 + // String ncStr = new DecimalFormat("00000000").format(Integer.parseInt(nc + "", 16));
203 204  
204 205 String A1 = username + ":" + realm + ":" + pass;
205 206 String A2 = request.getMethod().toUpperCase() + ":" + uri.toString();
... ... @@ -212,7 +213,7 @@ public class DigestServerAuthenticationHelper {
212 213 String HA2 = toHexString(mdbytes);
213 214 logger.debug("HA1: " + HA1);
214 215 logger.debug("HA2: " + HA2);
215   - String cnonce = authHeader.getCNonce();
  216 + // String cnonce = authHeader.getCNonce();
216 217 logger.debug("nonce: " + nonce);
217 218 logger.debug("nc: " + ncStr);
218 219 logger.debug("cnonce: " + cnonce);
... ...