ListIterator<String> authenticates = challengeResponse.getHeaders(SipHeaders.WWW_AUTHENTICATE);
while (authenticates.hasNext())
{
Authenticate authenticate = new Authenticate(authenticates.next());
AuthElement element = ((AuthInfoImpl) authInfo).getAuthElement(challengeResponse.getStatus(), authenticate.getRealm());
Authorization authorization =
new Authorization(authenticate, element.getUsername(), element.getPassword(), getRequestURIAsString(), getMethod());
addHeader(SipHeaders.AUTHORIZATION, authorization.toString());
}
authenticates = challengeResponse.getHeaders(SipHeaders.PROXY_AUTHENTICATE);
while (authenticates.hasNext())
{
Authenticate authenticate = new Authenticate(authenticates.next());
AuthElement element = ((AuthInfoImpl) authInfo).getAuthElement(challengeResponse.getStatus(), authenticate.getRealm());
Authorization authorization =
new Authorization(authenticate, element.getUsername(), element.getPassword(), getRequestURIAsString(), getMethod());
addHeader(SipHeaders.PROXY_AUTHORIZATION, authorization.toString());
}
}