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

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

本文整理了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

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

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

  1. public int getMaxForwards() {
  2. return ((MaxForwardsHeader) ((Request) message)
  3. .getHeader(MaxForwardsHeader.NAME)).getMaxForwards();
  4. }

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

  1. /**
  2. * @param request
  3. * @return
  4. */
  5. private boolean securityCheck(Request request) {
  6. // User-Agent: sipcli/v1.8
  7. // User-Agent: friendly-scanner
  8. // To: "sipvicious" <sip:100@1.1.1.1>
  9. // From: "sipvicious" <sip:100@1.1.1.1>;tag=3336353363346565313363340133313330323436343236
  10. // From: "1" <sip:1@87.202.36.237>;tag=3e7a78de
  11. Header userAgentHeader = request.getHeader("User-Agent");
  12. Header toHeader = request.getHeader("To");
  13. Header fromHeader = request.getHeader("From");
  14. for (String blockedValue: blockedList){
  15. if(userAgentHeader != null && userAgentHeader.toString().toLowerCase().contains(blockedValue.toLowerCase())) {
  16. return false;
  17. } else if (toHeader != null && toHeader.toString().toLowerCase().contains(blockedValue.toLowerCase())) {
  18. return false;
  19. } else if (fromHeader != null && fromHeader.toString().toLowerCase().contains(blockedValue.toLowerCase())) {
  20. return false;
  21. }
  22. }
  23. return true;
  24. }

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

  1. public void execute(RequestEvent event) {
  2. Request request = event.getRequest();
  3. final String calleeCallId = ((CallIdHeader) request
  4. .getHeader(CallIdHeader.NAME)).getCallId();
  5. String method = request.getMethod();
  6. if (Request.BYE.equals(method)) {
  7. handleBye(calleeCallId, request);
  8. }
  9. }

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

  1. public void execute(RequestEvent event) {
  2. Request request = event.getRequest();
  3. final String calleeCallId = ((CallIdHeader) request
  4. .getHeader(CallIdHeader.NAME)).getCallId();
  5. String method = request.getMethod();
  6. if (Request.BYE.equals(method)) {
  7. handleBye(calleeCallId, request);
  8. }
  9. }
  10. }

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

  1. public void execute(RequestEvent event) {
  2. Request request = event.getRequest();
  3. final String calleeCallId = ((CallIdHeader) request
  4. .getHeader(CallIdHeader.NAME)).getCallId();
  5. String method = request.getMethod();
  6. if (Request.BYE.equals(method)) {
  7. handleBye(calleeCallId, request);
  8. }
  9. }
  10. }

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

  1. public InitialEventSelector callIDSelect(InitialEventSelector ies) {
  2. Object event = ies.getEvent();
  3. String callID = null;
  4. if (event instanceof RequestEvent) {
  5. // If request event, the convergence name to callId
  6. Request request = ((RequestEvent) event).getRequest();
  7. callID = ((CallIdHeader) request.getHeader(CallIdHeader.NAME)).getCallId();
  8. }
  9. ies.setCustomName(callID);
  10. return ies;
  11. }

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

  1. /**
  2. * This method is used to know if the it is going to be used the voice mail
  3. * of the same user or the voice mail of a different user.
  4. *
  5. * @param event
  6. * @return TRUE: If the called user is sip:vmail@nist.gov
  7. */
  8. private boolean sameUser(javax.sip.RequestEvent event) {
  9. boolean sameUser = false;
  10. Request inviteRequest = event.getRequest();
  11. // Checking if the called user and the caller are the same
  12. ToHeader toHeader = (ToHeader) inviteRequest.getHeader(ToHeader.NAME);
  13. SipURI toURI = (SipURI) toHeader.getAddress().getURI();
  14. if ((toURI.getUser().equals(USER) && toURI.getHost().equals(HOST))) {
  15. sameUser = true;
  16. }
  17. // Setting Same User value
  18. this.setSameUser(sameUser);
  19. return sameUser;
  20. }

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

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

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

  1. public void execute(RequestEvent event) {
  2. Request request = event.getRequest();
  3. final String method = request.getMethod();
  4. if (method.equals(Request.BYE)) {
  5. final String callId = ((CallIdHeader) request
  6. .getHeader(CallIdHeader.NAME)).getCallId();
  7. Dialog dialog = getPeerDialog(callId);
  8. try {
  9. sipUtils.sendOk(request);
  10. sendRequest(dialog, Request.BYE);
  11. } catch (ParseException e1) {
  12. // TODO Auto-generated catch block
  13. e1.printStackTrace();
  14. } catch (SipException e1) {
  15. // TODO Auto-generated catch block
  16. e1.printStackTrace();
  17. }
  18. setState(new UATerminationState(), callId);
  19. }
  20. }
  21. }

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

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

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

  1. public static void optimizeRouteHeaderAddressForInternalRoutingrequest(SipConnector sipConnector, Request request, MobicentsSipSession session, SipFactoryImpl sipFactoryImpl, String transport) {
  2. RouteHeader rh = (RouteHeader) request.getHeader(RouteHeader.NAME);
  3. javax.sip.address.URI uri = null;
  4. if(rh != null) {
  5. uri = rh.getAddress().getURI();
  6. } else {
  7. uri = request.getRequestURI();
  8. }
  9. if(uri.isSipURI()) {
  10. javax.sip.address.SipURI sipUri = (javax.sip.address.SipURI) uri;
  11. optimizeUriForInternalRoutingRequest(sipConnector, sipUri, session, sipFactoryImpl, transport);
  12. }
  13. }

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

  1. /**
  2. * Store the client transaction in the cache since we may need to send a
  3. * cancel request associated with this ClientTransaction later.
  4. *
  5. * @param The
  6. * client transaction to store as "to be cancelled".
  7. */
  8. private void setToBeCancelledClientTransaction(ClientTransaction ct) {
  9. String callId = ((CallIdHeader) ct.getRequest().getHeader(
  10. CallIdHeader.NAME)).getCallId();
  11. SessionAssociation sa = (SessionAssociation) cache.get(callId);
  12. if (sa != null) {
  13. Session session = sa.getSession(callId);
  14. session.setToBeCancelledClientTransaction(ct);
  15. }
  16. }

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

  1. private void executeRequestState(RequestEvent event) {
  2. String callId = ((CallIdHeader) event.getRequest().getHeader(
  3. CallIdHeader.NAME)).getCallId();
  4. SessionAssociation sa = (SessionAssociation) cache.get(callId);
  5. SimpleCallFlowState simpleCallFlowState = getState(sa.getState());
  6. simpleCallFlowState.execute(event);
  7. }

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

  1. /**
  2. * Accepts a response event and sends an ACK (containing the sdp from this
  3. * event) to the callee.
  4. *
  5. * @param event
  6. */
  7. private void sendCalleeAck(ResponseEvent event) {
  8. log.debug("Sending Calee ACK event ResposneEvent = " + event);
  9. try {
  10. ClientTransaction ct = event.getClientTransaction();
  11. final String callerCallId = ((CallIdHeader) ct.getRequest()
  12. .getHeader(CallIdHeader.NAME)).getCallId();
  13. Dialog calleeDialog = getPeerDialog(callerCallId);
  14. Object content = event.getResponse().getContent();
  15. log.debug("Building ACK content = " + content + " Dialog = "
  16. + calleeDialog);
  17. Request ackRequest = sipUtils.buildAck(calleeDialog, content);
  18. calleeDialog.sendAck(ackRequest);
  19. } catch (SipException e) {
  20. // TODO Auto-generated catch block
  21. e.printStackTrace();
  22. }
  23. }

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

  1. public static void optimizeViaHeaderAddressForStaticAddress(SipConnector sipConnector, Request request, SipFactoryImpl sipFactoryImpl, String transport) throws ParseException, InvalidArgumentException {
  2. javax.sip.address.URI uri = request.getRequestURI();
  3. ViaHeader viaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
  4. RouteHeader route = (RouteHeader) request.getHeader(RouteHeader.NAME);
  5. if(route != null) {
  6. uri = route.getAddress().getURI();
  7. }
  8. if(uri.isSipURI()) {
  9. javax.sip.address.SipURI sipUri = (javax.sip.address.SipURI) uri;
  10. String host = sipUri.getHost();
  11. int port = sipUri.getPort();
  12. if(sipFactoryImpl.getSipApplicationDispatcher().isExternal(host, port, transport)) {
  13. viaHeader.setHost(sipConnector.getStaticServerAddress());
  14. viaHeader.setPort(sipConnector.getStaticServerPort());
  15. }
  16. }
  17. }
  18. }

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

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

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

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

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

  1. /**
  2. * @param proxyBranch
  3. * @param request
  4. * @param proxy
  5. * @param poppedURI
  6. */
  7. private static void addRecordRouteHeader(
  8. Request request, SipFactoryImpl sipFactoryImpl,
  9. javax.sip.address.SipURI poppedURI) {
  10. try {
  11. SipURI recordRouteURI = (SipURI)((RecordRouteHeader)request.getHeader(RecordRouteHeader.NAME)).getAddress().getURI();
  12. javax.sip.address.SipURI newRecordRouteURI = (javax.sip.address.SipURI)
  13. sipFactoryImpl.getAddressFactory().createURI(recordRouteURI.toString());
  14. newRecordRouteURI.removeParameter(MessageDispatcher.SIP_OUTBOUND_PARAM_OB);
  15. newRecordRouteURI.setUser(poppedURI.getUser());
  16. RecordRouteHeader recordRouteHeader = sipFactoryImpl.getHeaderFactory().createRecordRouteHeader(
  17. sipFactoryImpl.getAddressFactory().createAddress(newRecordRouteURI));
  18. // removes the header created when the request was cloned
  19. request.removeFirst(RecordRouteHeader.NAME);
  20. request.addFirst(recordRouteHeader);
  21. } catch (ParseException e) {
  22. logger.error("Impossible to parse the following popped URI " + poppedURI, e);
  23. } catch (SipException e) {
  24. logger.error("Impossible to add the following recordRouteHeader ", e);
  25. }
  26. }

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

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

相关文章