1. Use cached auth where possible

2. Fix when cancel authentication window
cusax-fix
Damian Minkov 19 years ago
parent 1e3fb0ab75
commit 6190243db1

@ -272,6 +272,19 @@ public void sendInstantMessage(Contact to, Message message)
void sendRequestMessage(Request mes, Contact to, Message message)
{
//check whether there's a cached authorization header for this
//call id and if so - attach it to the request.
// add authorization header
CallIdHeader call = (CallIdHeader)mes.getHeader(CallIdHeader.NAME);
String callid = call.getCallId();
AuthorizationHeader authorization = sipProvider
.getSipSecurityManager()
.getCachedAuthorizationHeader(callid);
if(authorization != null)
mes.addHeader(authorization);
//Transaction
ClientTransaction messageTransaction;
SipProvider jainSipProvider
@ -1089,6 +1102,12 @@ private void processAuthenticationChallenge(
, clientTransaction
, jainSipProvider);
if(retryTran == null)
{
logger.trace("No password supplied or error occured!");
return;
}
retryTran.sendRequest();
return;
}

@ -193,6 +193,20 @@ private CallSipImpl createOutgoingCall(Address calleeAddress)
, OperationFailedException.INTERNAL_ERROR
, ex);
}
//check whether there's a cached authorization header for this
//call id and if so - attach it to the request.
// add authorization header
CallIdHeader call = (CallIdHeader)invite.
getHeader(CallIdHeader.NAME);
String callid = call.getCallId();
AuthorizationHeader authorization = protocolProvider
.getSipSecurityManager()
.getCachedAuthorizationHeader(callid);
if(authorization != null)
invite.addHeader(authorization);
//Transaction
ClientTransaction inviteTransaction;
@ -802,6 +816,12 @@ private void processAuthenticationChallenge(
response
, clientTransaction
, jainSipProvider);
if(retryTran == null)
{
logger.trace("No password supplied or error occured!");
return;
}
//There is a new dialog that will be started with this request. Get
//that dialog and record it into the Call objet for later use (by

@ -1,5 +1,5 @@
/*
u * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
@ -610,7 +610,7 @@ public void publishPresenceStatus(PresenceStatus status,
} else {
req = createPublish(this.subscriptionDuration, true);
}
ClientTransaction transac = null;
try {
transac = this.parentProvider
@ -976,6 +976,20 @@ private Request createPublish(int expires, boolean insertPresDoc)
if (ifmHeader != null) {
req.setHeader(ifmHeader);
}
//check whether there's a cached authorization header for this
//call id and if so - attach it to the request.
// add authorization header
CallIdHeader call = (CallIdHeader)req
.getHeader(CallIdHeader.NAME);
String callid = call.getCallId();
AuthorizationHeader authorization = parentProvider
.getSipSecurityManager()
.getCachedAuthorizationHeader(callid);
if(authorization != null)
req.addHeader(authorization);
return req;
}
@ -1373,6 +1387,19 @@ private Request createSubscription(ContactSipImpl contact, int expires)
}
req.setHeader(expHeader);
//check whether there's a cached authorization header for this
//call id and if so - attach it to the request.
// add authorization header
CallIdHeader call = (CallIdHeader)req.getHeader(CallIdHeader.NAME);
String callid = call.getCallId();
AuthorizationHeader authorization = parentProvider
.getSipSecurityManager()
.getCachedAuthorizationHeader(callid);
if(authorization != null)
req.addHeader(authorization);
return req;
}
@ -1483,6 +1510,19 @@ private ClientTransaction createSubscription(int expires, Dialog dialog)
req.setHeader(maxForwards);
req.setHeader(evHeader);
req.setHeader(contactHeader);
//check whether there's a cached authorization header for this
//call id and if so - attach it to the request.
// add authorization header
CallIdHeader call = (CallIdHeader)req.getHeader(CallIdHeader.NAME);
String callid = call.getCallId();
AuthorizationHeader authorization = parentProvider
.getSipSecurityManager()
.getCachedAuthorizationHeader(callid);
if(authorization != null)
req.addHeader(authorization);
// create the transaction (then add the via header as recommended
// by the jain-sip documentation at:
@ -2295,6 +2335,19 @@ private ClientTransaction createNotify(ContactSipImpl contact, byte[] doc,
req.setHeader(evHeader);
req.setHeader(sStateHeader);
req.setHeader(contactHeader);
//check whether there's a cached authorization header for this
//call id and if so - attach it to the request.
// add authorization header
CallIdHeader call = (CallIdHeader)req.getHeader(CallIdHeader.NAME);
String callid = call.getCallId();
AuthorizationHeader authorization = parentProvider
.getSipSecurityManager()
.getCachedAuthorizationHeader(callid);
if(authorization != null)
req.addHeader(authorization);
// create the transaction (then add the via header as recommended
// by the jain-sip documentation at:
@ -2939,6 +2992,12 @@ private void processAuthenticationChallenge(
response
, clientTransaction
, jainSipProvider);
if(retryTran == null)
{
logger.trace("No password supplied or error occured!");
return;
}
retryTran.sendRequest();
return;

@ -473,6 +473,17 @@ public void processOK(ClientTransaction clientTransatcion,
* or constructing the request fails.
*/
public void unregister() throws OperationFailedException
{
unregister(true);
}
/**
* Sends a unregistered request to the registrar thus ending our
* registration.
* @throws OperationFailedException with the corresponding code if sending
* or constructing the request fails.
*/
private void unregister(boolean sendUnregister) throws OperationFailedException
{
if (getRegistrationState() == RegistrationState.UNREGISTERED)
{
@ -496,6 +507,9 @@ public void unregister() throws OperationFailedException
setRegistrationState(RegistrationState.UNREGISTERING,
RegistrationStateChangeEvent.REASON_USER_REQUEST, "");
if(!sendUnregister)
return;
//We are apparently registered so send a un-Register request.
Request unregisterRequest = (Request) registerRequest.clone();
try
@ -876,6 +890,13 @@ private void processAuthenticationChallenge(
, clientTransaction
, jainSipProvider);
if(retryTran == null)
{
logger.trace("No password supplied or error occured!");
unregister(false);
return;
}
retryTran.sendRequest();
return;
}

@ -196,6 +196,9 @@ else if (challenge.getStatusCode()
logger.trace("We don't seem to have a good pass! Get one.");
ccEntry = createCcEntryWithNewCredentials(realm);
if(ccEntry == null)
return null;
}
}
else
@ -483,11 +486,16 @@ private CredentialsCacheEntry createCcEntryWithNewCredentials(String realm)
UserCredentials defaultCredentials = new UserCredentials();
defaultCredentials.setUserName(accountID.getUserID());
ccEntry.userCredentials =
UserCredentials newCredentials =
getSecurityAuthority().obtainCredentials(
realm,
defaultCredentials);
if(newCredentials.getPassword() == null)
return null;
ccEntry.userCredentials = newCredentials;
//store the password if the user wants us to
if( ccEntry.userCredentials != null
&& ccEntry.userCredentials.isPasswordPersistent())

Loading…
Cancel
Save