}
private void handleDigestAuthentication(SipServletRequest request, String servletToInvoke, boolean proxy) throws IOException {
if (!((authMethod == null) || (authMethod.length() == 0))) {
if ("DIGEST".equals(authMethod)) {
DigestAuthenticator auth = new DigestAuthenticator(
realmName, proxy);
Principal authPrincipal = auth.authenticate(request);
if (authPrincipal != null) {
((SipServletRequestImpl) request).setUserPrincipal(authPrincipal);
((SipServletRequestImpl) request).setUser(authPrincipal.getName());
((SipServletRequestImpl) request).setAuthInfoHeader(auth.getAuthInfoHeader());
removeProcessedAuthHeader(request, proxy);
} else {
if (!(request.getMethod().equals("ACK") || request.getMethod().equals("CANCEL"))) {
SipServletResponse response = createErrorResponse(request, servletToInvoke);
response.send();