SipService: handle cross-domain authentication error
and add new CROSS_DOMAIN_AUTHENTICATION error code and OUT_OF_NETWORK DisconnectCause. http://b/issue?id=3020185 Change-Id: Icc0a341599d5a72b7cb2d43675fbddc516544978
This commit is contained in:
@@ -810,6 +810,12 @@ class SipSessionGroup implements SipListener {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean crossDomainAuthenticationRequired(Response response) {
|
||||
String realm = getRealmFromResponse(response);
|
||||
if (realm == null) realm = "";
|
||||
return !mLocalProfile.getSipDomain().trim().equals(realm.trim());
|
||||
}
|
||||
|
||||
private AccountManager getAccountManager() {
|
||||
return new AccountManager() {
|
||||
public UserCredentials getCredentials(ClientTransaction
|
||||
@@ -831,6 +837,15 @@ class SipSessionGroup implements SipListener {
|
||||
};
|
||||
}
|
||||
|
||||
private String getRealmFromResponse(Response response) {
|
||||
WWWAuthenticate wwwAuth = (WWWAuthenticate)response.getHeader(
|
||||
SIPHeaderNames.WWW_AUTHENTICATE);
|
||||
if (wwwAuth != null) return wwwAuth.getRealm();
|
||||
ProxyAuthenticate proxyAuth = (ProxyAuthenticate)response.getHeader(
|
||||
SIPHeaderNames.PROXY_AUTHENTICATE);
|
||||
return (proxyAuth == null) ? null : proxyAuth.getRealm();
|
||||
}
|
||||
|
||||
private String getNonceFromResponse(Response response) {
|
||||
WWWAuthenticate wwwAuth = (WWWAuthenticate)response.getHeader(
|
||||
SIPHeaderNames.WWW_AUTHENTICATE);
|
||||
@@ -937,7 +952,10 @@ class SipSessionGroup implements SipListener {
|
||||
return true;
|
||||
case Response.UNAUTHORIZED:
|
||||
case Response.PROXY_AUTHENTICATION_REQUIRED:
|
||||
if (handleAuthentication(event)) {
|
||||
if (crossDomainAuthenticationRequired(response)) {
|
||||
onError(SipErrorCode.CROSS_DOMAIN_AUTHENTICATION,
|
||||
getRealmFromResponse(response));
|
||||
} else if (handleAuthentication(event)) {
|
||||
addSipSession(this);
|
||||
} else if (mLastNonce == null) {
|
||||
onError(SipErrorCode.SERVER_ERROR,
|
||||
|
||||
Reference in New Issue
Block a user