javax.sip.message.Request.getHeader()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(250)

本文整理了Java中javax.sip.message.Request.getHeader方法的一些代码示例,展示了Request.getHeader的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getHeader方法的具体详情如下:
包路径:javax.sip.message.Request
类名称:Request
方法名:getHeader

Request.getHeader介绍

暂无

代码示例

代码示例来源:origin: org.jitsi/jain-sip-ri-ossonly

/**
 * Removes all via headers from <tt>request</tt> and replaces them with a new one, equal to
 * the one that was top most.
 *
 * @param request the Request whose branchID we'd like to remove.
 *
 */
private void removeBranchID(Request request) {
  ViaHeader viaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
  viaHeader.removeParameter("branch");
}

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

public int getMaxForwards() {
  return ((MaxForwardsHeader) ((Request) message)
      .getHeader(MaxForwardsHeader.NAME)).getMaxForwards();
}

代码示例来源:origin: org.mobicents.javax.sip/mobicents-jain-sip-ext

/**
 * @param request
 * @return
 */
private boolean securityCheck(Request request) {
  //        User-Agent: sipcli/v1.8
  //        User-Agent: friendly-scanner
  //        To: "sipvicious" <sip:100@1.1.1.1>
  //        From: "sipvicious" <sip:100@1.1.1.1>;tag=3336353363346565313363340133313330323436343236
  //        From: "1" <sip:1@87.202.36.237>;tag=3e7a78de
  Header userAgentHeader = request.getHeader("User-Agent");
  Header toHeader = request.getHeader("To");
  Header fromHeader = request.getHeader("From");
  for (String blockedValue: blockedList){
    if(userAgentHeader != null && userAgentHeader.toString().toLowerCase().contains(blockedValue.toLowerCase())) {
      return false;
    } else if (toHeader != null && toHeader.toString().toLowerCase().contains(blockedValue.toLowerCase())) {
      return false;
    } else if (fromHeader != null && fromHeader.toString().toLowerCase().contains(blockedValue.toLowerCase())) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: org.mobicents.examples/converged-demo-callcontrol-sbb

public void execute(RequestEvent event) {
  Request request = event.getRequest();
  final String calleeCallId = ((CallIdHeader) request
      .getHeader(CallIdHeader.NAME)).getCallId();
  String method = request.getMethod();
  if (Request.BYE.equals(method)) {
    handleBye(calleeCallId, request);
  }
}

代码示例来源:origin: org.mobicents.examples/converged-demo-callcontrol-sbb

public void execute(RequestEvent event) {
    Request request = event.getRequest();
    final String calleeCallId = ((CallIdHeader) request
        .getHeader(CallIdHeader.NAME)).getCallId();
    String method = request.getMethod();
    if (Request.BYE.equals(method)) {
      handleBye(calleeCallId, request);
    }
  }
}

代码示例来源:origin: org.mobicents.examples/converged-demo-callcontrol-sbb

public void execute(RequestEvent event) {
    Request request = event.getRequest();
    final String calleeCallId = ((CallIdHeader) request
        .getHeader(CallIdHeader.NAME)).getCallId();
    String method = request.getMethod();
    if (Request.BYE.equals(method)) {
      handleBye(calleeCallId, request);
    }
  }
}

代码示例来源:origin: org.mobicents.examples/call-controller2-sbbs

public InitialEventSelector callIDSelect(InitialEventSelector ies) {
  Object event = ies.getEvent();
  String callID = null;
  
  if (event instanceof RequestEvent) {
    // If request event, the convergence name to callId
    Request request = ((RequestEvent) event).getRequest();
    callID = ((CallIdHeader) request.getHeader(CallIdHeader.NAME)).getCallId();
  }
  ies.setCustomName(callID);
  
  return ies;
}

代码示例来源:origin: org.mobicents.examples/call-controller2-sbbs

/**
 * This method is used to know if the it is going to be used the voice mail
 * of the same user or the voice mail of a different user.
 * 
 * @param event
 * @return TRUE: If the called user is sip:vmail@nist.gov
 */
private boolean sameUser(javax.sip.RequestEvent event) {
  boolean sameUser = false;
  Request inviteRequest = event.getRequest();
  // Checking if the called user and the caller are the same
  ToHeader toHeader = (ToHeader) inviteRequest.getHeader(ToHeader.NAME);
  SipURI toURI = (SipURI) toHeader.getAddress().getURI();
  if ((toURI.getUser().equals(USER) && toURI.getHost().equals(HOST))) {
    sameUser = true;
  }
  // Setting Same User value
  this.setSameUser(sameUser);
  return sameUser;
}

代码示例来源:origin: org.apache.camel/camel-sip

private void processPublish(RequestEvent requestEvent,
    ServerTransaction serverTransactionId) {
  try {
    Request request = requestEvent.getRequest();
    LOG.debug("SipPresenceAgentListener: Received a Publish request, sending OK");
    LOG.debug("SipPresenceAgentListener request: {}", request);
    EventHeader eventHeader = (EventHeader) requestEvent.getRequest().getHeader(EventHeader.NAME);
    Response response = sipPresenceAgent.getConfiguration().getMessageFactory().createResponse(202, request);
    sipPresenceAgent.getProvider().sendResponse(response);
    // Send notification to subscriber
    sendNotification(eventHeader, false, request.getContent());
           } catch (Exception e) {
    LOG.error("Exception thrown during publish/notify processing in the Sip Presence Agent Listener", e);
  }
}

代码示例来源:origin: org.mobicents.examples/converged-demo-callcontrol-sbb

public void execute(RequestEvent event) {
    Request request = event.getRequest();
    final String method = request.getMethod();
    if (method.equals(Request.BYE)) {
      final String callId = ((CallIdHeader) request
          .getHeader(CallIdHeader.NAME)).getCallId();
      Dialog dialog = getPeerDialog(callId);
      try {
        sipUtils.sendOk(request);
        sendRequest(dialog, Request.BYE);
      } catch (ParseException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      } catch (SipException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      setState(new UATerminationState(), callId);
    }
  }
}

代码示例来源:origin: org.mobicents.examples/call-controller2-sbbs

/**
 * Fetch audio file string for callee, used to check for recorded message.
 * @return
 */
private String getAudioFileString() {
  FromHeader fromHeader = (FromHeader) this.getInviteRequest().getHeader(
      FromHeader.NAME);
  return getAudioFileString(((SipURI) fromHeader.getAddress().getURI()).getUser());
}

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

public static void optimizeRouteHeaderAddressForInternalRoutingrequest(SipConnector sipConnector, Request request, MobicentsSipSession session,  SipFactoryImpl sipFactoryImpl, String transport) {
  RouteHeader rh = (RouteHeader) request.getHeader(RouteHeader.NAME);
  javax.sip.address.URI uri = null;
  if(rh != null) {
    uri = rh.getAddress().getURI();
  } else {
    uri = request.getRequestURI();
  }
  if(uri.isSipURI()) {
    javax.sip.address.SipURI sipUri = (javax.sip.address.SipURI) uri;
    optimizeUriForInternalRoutingRequest(sipConnector, sipUri, session, sipFactoryImpl, transport);
  }
}

代码示例来源:origin: org.mobicents.examples/converged-demo-callcontrol-sbb

/**
 * Store the client transaction in the cache since we may need to send a
 * cancel request associated with this ClientTransaction later.
 * 
 * @param The
 *            client transaction to store as "to be cancelled".
 */
private void setToBeCancelledClientTransaction(ClientTransaction ct) {
  String callId = ((CallIdHeader) ct.getRequest().getHeader(
      CallIdHeader.NAME)).getCallId();
  SessionAssociation sa = (SessionAssociation) cache.get(callId);
  if (sa != null) {
    Session session = sa.getSession(callId);
    session.setToBeCancelledClientTransaction(ct);
  }
}

代码示例来源:origin: org.mobicents.examples/converged-demo-callcontrol-sbb

private void executeRequestState(RequestEvent event) {
  String callId = ((CallIdHeader) event.getRequest().getHeader(
      CallIdHeader.NAME)).getCallId();
  SessionAssociation sa = (SessionAssociation) cache.get(callId);
  SimpleCallFlowState simpleCallFlowState = getState(sa.getState());
  simpleCallFlowState.execute(event);
}

代码示例来源:origin: org.mobicents.examples/converged-demo-callcontrol-sbb

/**
 * Accepts a response event and sends an ACK (containing the sdp from this
 * event) to the callee.
 * 
 * @param event
 */
private void sendCalleeAck(ResponseEvent event) {
  log.debug("Sending Calee ACK event ResposneEvent = " + event);
  try {
    ClientTransaction ct = event.getClientTransaction();
    final String callerCallId = ((CallIdHeader) ct.getRequest()
        .getHeader(CallIdHeader.NAME)).getCallId();
    Dialog calleeDialog = getPeerDialog(callerCallId);
    Object content = event.getResponse().getContent();
    log.debug("Building ACK content = " + content + " Dialog = "
        + calleeDialog);
    Request ackRequest = sipUtils.buildAck(calleeDialog, content);
    calleeDialog.sendAck(ackRequest);
  } catch (SipException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
}

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

public static void optimizeViaHeaderAddressForStaticAddress(SipConnector sipConnector, Request request, SipFactoryImpl sipFactoryImpl, String transport) throws ParseException, InvalidArgumentException {
    javax.sip.address.URI uri = request.getRequestURI();

    ViaHeader viaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);

    RouteHeader route = (RouteHeader) request.getHeader(RouteHeader.NAME);
    if(route != null) {
      uri = route.getAddress().getURI();
    }
    if(uri.isSipURI()) {
      javax.sip.address.SipURI sipUri = (javax.sip.address.SipURI) uri;
      String host = sipUri.getHost();
      int port = sipUri.getPort();
      if(sipFactoryImpl.getSipApplicationDispatcher().isExternal(host, port, transport)) {
        viaHeader.setHost(sipConnector.getStaticServerAddress());
        viaHeader.setPort(sipConnector.getStaticServerPort());
      }
    }
  }
}

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

public static String findRouteOrRequestUriTransport(Request request) {
  RouteHeader route = (RouteHeader) request.getHeader(RouteHeader.NAME);
  if(route != null) {
    URI uri = route.getAddress().getURI();
    return findURITransport(uri, request.getContentLength().getContentLength());
  }
  URI ruri = request.getRequestURI();
  return findURITransport(ruri, request.getContentLength().getContentLength());
}
// https://github.com/Mobicents/sip-servlets/issues/62

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

CallIdHeader callId = (CallIdHeader)request.getHeader(CallIdHeader.NAME);
String username = getHash(callId.getCallId().getBytes());
SipURI uri = (SipURI)ch.getAddress().getURI();

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

/**
 * @param proxyBranch
 * @param request
 * @param proxy
 * @param poppedURI
 */
private static void addRecordRouteHeader(
    Request request, SipFactoryImpl sipFactoryImpl,
    javax.sip.address.SipURI poppedURI) {
  try {
    SipURI recordRouteURI = (SipURI)((RecordRouteHeader)request.getHeader(RecordRouteHeader.NAME)).getAddress().getURI();
    javax.sip.address.SipURI newRecordRouteURI = (javax.sip.address.SipURI) 
      sipFactoryImpl.getAddressFactory().createURI(recordRouteURI.toString());
    newRecordRouteURI.removeParameter(MessageDispatcher.SIP_OUTBOUND_PARAM_OB);
    newRecordRouteURI.setUser(poppedURI.getUser());
    RecordRouteHeader recordRouteHeader = sipFactoryImpl.getHeaderFactory().createRecordRouteHeader(
        sipFactoryImpl.getAddressFactory().createAddress(newRecordRouteURI));
    // removes the header created when the request was cloned
    request.removeFirst(RecordRouteHeader.NAME);
    request.addFirst(recordRouteHeader);
  } catch (ParseException e) {
    logger.error("Impossible to parse the following popped URI " + poppedURI, e);
  } catch (SipException e) {
    logger.error("Impossible to add the following recordRouteHeader ", e);
  }
}

代码示例来源:origin: org.mobicents.examples/call-controller2-sbbs

Request request = txn.getRequest();
ToHeader toHeader = (ToHeader) request.getHeader(ToHeader.NAME);
String userName = ((SipURI) toHeader.getAddress().getURI())
    .getUser();

相关文章