Skip to content

Commit 03bd67a

Browse files
committed
Added extra log statements around the check of client Authorization header
1 parent 8f3fb20 commit 03bd67a

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/util/CallControlHelper.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import javax.servlet.sip.SipServletResponse;
3232
import javax.servlet.sip.SipURI;
3333

34+
import org.apache.log4j.Logger;
3435
import org.restcomm.connect.dao.ClientsDao;
3536
import org.restcomm.connect.dao.DaoManager;
3637
import org.restcomm.connect.dao.entities.Client;
@@ -47,6 +48,7 @@
4748
*
4849
*/
4950
public class CallControlHelper {
51+
private static Logger logger = Logger.getLogger(CallControlHelper.class);
5052

5153
static boolean permitted(final String authorization, final String method, DaoManager daoManager, final Sid organizationSid) {
5254
final Map<String, String> map = authHeaderToMap(authorization);
@@ -66,8 +68,16 @@ static boolean permitted(final String authorization, final String method, DaoMan
6668
final String password2 = client.getPassword();
6769
final String result = DigestAuthentication.response(algorithm, user, realm, "", password2, nonce, nc, cnonce,
6870
method, uri, null, qop);
71+
if (logger.isDebugEnabled()) {
72+
String msg = String.format("Provided response [%s], generated response [%s]", response, result);
73+
logger.debug(msg);
74+
}
6975
return result.equals(response);
7076
} else {
77+
if (logger.isDebugEnabled()) {
78+
String msg = String.format("Authorization check failed, [if(client==null) evaluates %s] or [if(client.getStatus()==Client.ENABLED) evaluates %s]", client!=null, Client.ENABLED == client.getStatus());
79+
logger.debug(msg);
80+
}
7181
return false;
7282
}
7383
}
@@ -85,6 +95,10 @@ public static boolean checkAuthentication(SipServletRequest request, DaoManager
8595
final String authorization = request.getHeader("Proxy-Authorization");
8696
final String method = request.getMethod();
8797
if (authorization == null || !CallControlHelper.permitted(authorization, method, storage, organizationSid)) {
98+
if (logger.isDebugEnabled()) {
99+
String msg = String.format("Either authorization header is null [if(authorization==null) evaluates %s], or CallControlHelper.permitted() method failed, will send \"407 Proxy Authentication required\"", authorization==null);
100+
logger.debug(msg);
101+
}
88102
authenticate(request, storage.getOrganizationsDao().getOrganization(organizationSid).getDomainName());
89103
return false;
90104
} else {

0 commit comments

Comments
 (0)