/** Sends a new message. */ public void send(String recipient, String subject, String content_type, String content) { NameAddress to_url = new NameAddress(recipient); NameAddress from_url = new NameAddress(user_profile.from_url); MessageFactory msgf = new MessageFactory(); Message req = msgf.createMessageRequest(sip_provider, to_url, from_url, subject, content_type, content); TransactionClient t = new TransactionClient(sip_provider, req, this); t.request(); }
/** When the TransactionClient goes into the "Completed" state receiving a 300-699 response */ public void onTransFailureResponse(TransactionClient tc, Message msg) { // SESCA // Autentikointi String method = tc.getTransactionMethod(); StatusLine status_line = msg.getStatusLine(); int code = status_line.getCode(); // AUTHENTICATION-BEGIN if ((code == 401 && msg.hasWwwAuthenticateHeader() && msg.getWwwAuthenticateHeader().getRealmParam().equalsIgnoreCase(user_profile.realm)) || (code == 407 && msg.hasProxyAuthenticateHeader() && msg.getProxyAuthenticateHeader() .getRealmParam() .equalsIgnoreCase(user_profile.realm))) { // req:ssa on cseq:ua kasvatettu Message req = tc.getRequestMessage(); req.setCSeqHeader(req.getCSeqHeader().incSequenceNumber()); WwwAuthenticateHeader wah; if (code == 401) wah = msg.getWwwAuthenticateHeader(); else wah = msg.getProxyAuthenticateHeader(); String qop_options = wah.getQopOptionsParam(); qop = (qop_options != null) ? "auth" : null; RequestLine rl = req.getRequestLine(); // SESCA // BUGI client ei saa lähettää qop:ia // DigestAuthentication digest=new // DigestAuthentication(rl.getMethod(),rl.getAddress().toString(),wah,qop,null,username,passwd); DigestAuthentication digest = new DigestAuthentication( rl.getMethod(), rl.getAddress().toString(), wah, null, null, user_profile.authID, user_profile.passwd); AuthorizationHeader ah; if (code == 401) ah = digest.getAuthorizationHeader(); else ah = digest.getProxyAuthorizationHeader(); req.setAuthorizationHeader(ah); // transactions.remove(tc.getTransactionId()); // SESCA // BUGI // Päivitetään invite_req:uun uusin invite-viesti. // Lähetämme uuden inviten, joten teemme uuden invitetransactionclientin, eikä transaction // clientia // if (method.equals(SipMethods.INVITE)) { // invite_req = req; // tc=new InviteTransactionClient(sip_provider,req,this); tc = new TransactionClient(sip_provider, req, this); // tc=new TransactionClient(sip_provider,req,this); // } // else { // tc=new TransactionClient(sip_provider,req,this); // } // transactions.put(tc.getTransactionId(),tc); tc.request(); } // AUTHENTICATION-END else onDeliveryFailure(tc, msg.getStatusLine().getReason()); }