摘要认证 调整
This commit is contained in:
parent
84cab3441f
commit
b1d3d2d235
@ -220,7 +220,7 @@ public class DigestAuthenticationHelper {
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static AuthorizationHeader createAuthorization(String serverIp, int serverPort, String serverId, String deviceId,String password, WWWAuthenticateHeader www){
|
||||
public static AuthorizationHeader createAuthorization(String method,String serverIp, int serverPort, String serverId, String deviceId,String password, WWWAuthenticateHeader www){
|
||||
String hostAddress = SipBuilder.createHostAddress(serverIp, serverPort);
|
||||
SipURI sipURI = SipBuilder.createSipURI(serverId, hostAddress);
|
||||
if (www == null) {
|
||||
@ -249,7 +249,7 @@ public class DigestAuthenticationHelper {
|
||||
}
|
||||
}
|
||||
String HA1 = DigestUtil.md5Hex((deviceId + ":" + realm + ":" + password).getBytes());
|
||||
String HA2= DigestUtil.md5Hex((Request.REGISTER + ":" + sipURI.toString()).getBytes());
|
||||
String HA2= DigestUtil.md5Hex((method.toUpperCase() + ":" + sipURI.toString()).getBytes());
|
||||
|
||||
StringBuilder reStr = new StringBuilder();
|
||||
reStr.append(HA1);
|
||||
|
@ -17,17 +17,17 @@ public class AuthenticationTest {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
AuthorizationHeader authorization = DigestAuthenticationHelper.createAuthorization(serverIp, serverPort, serverId, deviceId, "123456",null);
|
||||
AuthorizationHeader authorization = DigestAuthenticationHelper.createAuthorization(Request.REGISTER, serverIp, serverPort, serverId, deviceId, "123456", null);
|
||||
log.info("\n{}", authorization);
|
||||
|
||||
WWWAuthenticateHeader wwwAuthenticateHeader = DigestAuthenticationHelper.generateChallenge(domain);
|
||||
log.info("\n{}", wwwAuthenticateHeader);
|
||||
|
||||
authorization = DigestAuthenticationHelper.createAuthorization(serverIp, serverPort, serverId, deviceId, "123456",wwwAuthenticateHeader);
|
||||
authorization = DigestAuthenticationHelper.createAuthorization(Request.REGISTER, serverIp, serverPort, serverId, deviceId, "123456", wwwAuthenticateHeader);
|
||||
log.info("\n{}", authorization);
|
||||
|
||||
boolean passed = DigestAuthenticationHelper.doAuthenticatePlainTextPassword(Request.REGISTER, authorization, "123456");
|
||||
log.info("authorization passed {}",passed);
|
||||
log.info("authorization passed {}", passed);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user