From 827a8490a200b83eaf340c1142323bac18c2bb85 Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Tue, 11 Mar 2008 21:41:41 +0000 Subject: [PATCH] Fix SIP behavior when user cancels the authorization process --- .../sip/security/SipSecurityManager.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/sip/security/SipSecurityManager.java b/src/net/java/sip/communicator/impl/protocol/sip/security/SipSecurityManager.java index 7f159a607..a5a7348c5 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/security/SipSecurityManager.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/security/SipSecurityManager.java @@ -12,8 +12,10 @@ import javax.sip.header.*; import javax.sip.message.*; +import net.java.sip.communicator.impl.netaddr.*; import net.java.sip.communicator.impl.protocol.sip.*; import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; /** @@ -76,7 +78,7 @@ public void setHeaderFactory(HeaderFactory headerFactory) } /** - * Uses securityAuthority to determinie a set of valid user credentials + * Uses securityAuthority to determine a set of valid user credentials * for the specified Response (Challenge) and appends it to the challenged * request so that it could be retransmitted. * @@ -196,9 +198,11 @@ 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; + throw new OperationFailedException( + "User has canceled the authentication process.", + OperationFailedException.AUTHENTICATION_CANCELED); } } else @@ -217,6 +221,11 @@ else if (challenge.getStatusCode() accountID, null); ccEntry = createCcEntryWithNewCredentials(realm); + + if(ccEntry == null) + throw new OperationFailedException( + "User has canceled the authentication process.", + OperationFailedException.AUTHENTICATION_CANCELED); } else { @@ -470,7 +479,7 @@ private void removeBranchID(Request request) } /** - * Obtains user credentials from the security suthority for the speicified + * Obtains user credentials from the security authority for the specified * realm and creates a new CredentialsCacheEntry with them. * * @param realm the realm that we'd like to obtain a @@ -491,9 +500,13 @@ private CredentialsCacheEntry createCcEntryWithNewCredentials(String realm) realm, defaultCredentials); + // in case user has canceled the login window + if(newCredentials == null) + return null; + if(newCredentials.getPassword() == null) return null; - + ccEntry.userCredentials = newCredentials; //store the password if the user wants us to