コード例 #1
0
ファイル: MessageAgent.java プロジェクト: BantouTelecom/swip
 /** When the delivery fails. */
 private void onDeliveryFailure(TransactionClient tc, String result) {
   printLog("Message delivery failed (" + result + ").");
   Message req = tc.getRequestMessage();
   NameAddress recipient = req.getToHeader().getNameAddress();
   String subject = null;
   if (req.hasSubjectHeader()) subject = req.getSubjectHeader().getSubject();
   if (listener != null) listener.onMaDeliveryFailure(this, recipient, subject, result);
 }
コード例 #2
0
ファイル: MessageAgent.java プロジェクト: BantouTelecom/swip
  /** 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());
  }