public static boolean checkAuthentication ( SipServletRequest request , DaoManager storage , Sid organizationSid ) throws IOException { // Make sure we force clients to authenticate. final String authorization = request . getHeader ( "Proxy-Authorization" ) ; final String method = request . getMethod ( ) ; if ( authorization == null || ! CallControlHelper . permitted ( authorization , method , storage , organizationSid ) ) { if ( logger . isDebugEnabled ( ) ) { 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 ) ; logger . debug ( msg ) ; } authenticate ( request , storage . getOrganizationsDao ( ) . getOrganization ( organizationSid ) . getDomainName ( ) ) ; return false ; } else { return true ; } }
Check if a client is authenticated . If so return true . Otherwise request authentication and return false ;