List of usage examples for org.apache.commons.httpclient.auth MalformedChallengeException printStackTrace
public void printStackTrace()
From source file:com.sipresponse.flibblecallmgr.internal.util.AuthenticationHelper.java
public static void processResponseAuthorization(CallManager callMgr, Line line, Response response, Request newRequest, boolean forRegister) { String headerName = "Authorization"; FlibbleSipProvider flibbleProvider = InternalCallManager.getInstance().getProvider(callMgr); WWWAuthenticateHeader wwwAuthenticateHeader = (WWWAuthenticateHeader) response .getHeader(WWWAuthenticateHeader.NAME); SIPHeader sipHeader = (SIPHeader) wwwAuthenticateHeader; if (sipHeader == null) { headerName = "Proxy-Authorization"; ProxyAuthenticateHeader proxyAuthenticateHeader = (ProxyAuthenticateHeader) response .getHeader(ProxyAuthenticateHeader.NAME); sipHeader = (SIPHeader) proxyAuthenticateHeader; }//from w w w . j a v a2s. c om CSeqHeader cseqHeader = (CSeqHeader) response.getHeader(CSeqHeader.NAME); String method = cseqHeader.getMethod(); System.out.println("processResponseAuthorization()"); // Proxy-Authorization header: UsernamePasswordCredentials cred = new UsernamePasswordCredentials(line.getUser(), line.getPassword()); AuthScheme authscheme = new DigestScheme(); try { authscheme.processChallenge(sipHeader.getHeaderValue()); } catch (MalformedChallengeException e) { // TODO Auto-generated catch block e.printStackTrace(); } String uriString = null; // if (forRegister == true) // { // uriString = "sip:" + line.getHost(); // } // else { uriString = newRequest.getRequestURI().toString(); } String responseString = null; try { responseString = authscheme.authenticate(cred, method, uriString); } catch (AuthenticationException e) { e.printStackTrace(); } try { Header header = flibbleProvider.headerFactory.createHeader(headerName, responseString); newRequest.addHeader(header); } catch (Exception e) { e.printStackTrace(); } }