if (type==SERVER_AUTHENTICATION) result=401; // response code 401 ("Unauthorized")
else result=407; // response code 407 ("Proxy Authentication Required")
err_resp=MessageFactory.createResponse(msg,result,SipResponses.reasonOf(result),null);
WwwAuthenticateHeader wah;
if (type==SERVER_AUTHENTICATION) wah=new WwwAuthenticateHeader("Digest");
else wah=new ProxyAuthenticateHeader("Digest");
wah.addRealmParam(realm);
wah.addQopOptionsParam(qop_options);
wah.addNonceParam(HEX(rand));
err_resp.setWwwAuthenticateHeader(wah);
}