WWWAuthenticateHeader authHeader = null;
SipURI requestUri = (SipURI) challengedTransaction.getRequest().getRequestURI();
while (authHeaders.hasNext()) {
authHeader = (WWWAuthenticateHeader) authHeaders.next();
String realm = authHeader.getRealm();
AuthorizationHeader authorization = null;
String sipDomain;
if ( this.accountManager instanceof SecureAccountManager ) {
UserCredentialHash credHash =
((SecureAccountManager)this.accountManager).getCredentialHash(challengedTransaction,realm);
if ( credHash == null ) {
logger.logDebug("Could not find creds");
throw new SipException(
"Cannot find user creds for the given user name and realm");
}
URI uri = reoriginatedRequest.getRequestURI();
sipDomain = credHash.getSipDomain();
authorization = this.getAuthorization(reoriginatedRequest
.getMethod(), uri.toString(),
(reoriginatedRequest.getContent() == null) ? "" : new String(
reoriginatedRequest.getRawContent()), authHeader, credHash);
} else {
UserCredentials userCreds = ((AccountManager) this.accountManager).getCredentials(challengedTransaction, realm);
if (userCreds == null) {
throw new SipException(
"Cannot find user creds for the given user name and realm");
}
sipDomain = userCreds.getSipDomain();
// we haven't yet authenticated this realm since we were
// started.
authorization = this.getAuthorization(reoriginatedRequest
.getMethod(), reoriginatedRequest.getRequestURI().toString(),
(reoriginatedRequest.getContent() == null) ? "" : new String(
reoriginatedRequest.getRawContent()), authHeader, userCreds);
}
if ( logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug(
"Created authorization header: " + authorization.toString());
}
if (cacheTime != 0) {
String callId = challengedRequest.getCallId().getCallId();