public Object extract(Object input) { return ((SipServletRequest) input).getMethod(); } }
public Object extract(Object input) { if (inputType == REQUEST) { return ((SipServletRequest) input).getRequestURI(); } else { return ((Address) input).getURI(); } } }
public Object extract(Object input) { return ((SipServletRequest) input).getFrom(); } }
private void terminate() { final SipSession sipSession = initialInvite.getSession(); final SipServletRequest bye = sipSession.createRequest("BYE"); try { bye.send(); } catch(final IOException exception) { logger.error(exception); } server.destroyMediaSession(session); }
SipURI to, String proxyUsername, String proxyPassword, DaoManager storage, SipFactory sipFactory, boolean callToSipUri, final boolean patchForNat) { request.getSession().setAttribute("lastRequest", request); if (logger.isInfoEnabled()) { logger.info("B2BUA (p2p proxy for DID and SIP URIs) - : Got request:\n" + request.getRequestURI().toString()); logger.info(String.format("B2BUA: Proxying a session from %s to %s", from, to)); final SipSession incomingSession = request.getSession(); Address fromAddress = sipFactory.createAddress(from, fromClient.getFriendlyName()); Address toAddress = sipFactory.createAddress(to, to.getUser()); outRequest = sipFactory.createRequest(request.getApplicationSession(), request.getMethod(), fromAddress, toAddress); } else { outRequest = sipFactory.createRequest(request.getApplicationSession(), request.getMethod(), from, to); outRequest.setRequestURI(to); logger.info("Request: " + request.getMethod() + " content exists: " + request.getContent() != null+ " content type: " + request.getContentType()); final String initialIpBeforeLB = request.getHeader("X-Sip-Balancer-InitialRemoteAddr"); String initialPortBeforeLB = request.getHeader("X-Sip-Balancer-InitialRemotePort"); if (initialIpBeforeLB != null) { if (initialPortBeforeLB == null) if (request.getContent() != null) { final byte[] sdp = request.getRawContent(); String offer = null; if (request.getContentType().equalsIgnoreCase("application/sdp") && patchForNat) {
sipServletRequest.setRequestURI(requestURI); } else { sipServletRequest.setRequestURI(requestURI); stringBuffer.append(". Press 1 to confirm and 2 to decline."); sipServletRequest.getSession().setAttribute("speechUri", java.net.URI.create("data:" + URLEncoder.encode("ts("+ stringBuffer +")", "UTF-8"))); sipServletRequest.setContentLength(sdpOffer.length); sipServletRequest.setContent(sdpOffer, "application/sdp"); sipServletRequest.getSession().setAttribute("customerName", customerName); sipServletRequest.getSession().setAttribute("customerPhone", customerPhone); sipServletRequest.getSession().setAttribute("amountOrder", amount); sipServletRequest.getSession().setAttribute("orderId", orderId); sipServletRequest.getSession().setAttribute("connection", conn); sipServletRequest.getSession().setAttribute("mediaGroup", mg); sipServletRequest.getSession().setAttribute("mediaSession", mediaSession); sipServletRequest.getSession().setAttribute("orderApproval", true); sipServletRequest.getSession().setAttribute("caller", (String)Contexts.getApplicationContext().get("caller.sip")); sipServletRequest.getSession().setAttribute("callerDomain", (String)Contexts.getApplicationContext().get("caller.domain")); sipServletRequest.getSession().setAttribute("callerPassword", (String)Contexts.getApplicationContext().get("caller.password")); sipServletRequest.send(); mg.getSignalDetector().addListener(new DTMFListener(mg, sipServletRequest.getSession(), MMSUtil.audioFilePath)); conn.join(Direction.DUPLEX, mg); } catch (UnsupportedOperationException uoe) {
@Override public synchronized void dial() throws CallException { assertState(QUEUED); // Try to negotiate media with a packet relay end point. try { relayEndpoint = session.getPacketRelayEndpoint(); userAgentConnection = session.createConnection(relayEndpoint); userAgentConnection.addObserver(this); userAgentConnection.connect(ConnectionMode.SendRecv); block(1); if(!MgcpConnection.HALF_OPEN.equals(userAgentConnection.getState())) { throw new Exception(mmsTimedOutException()); } final byte[] offer = patchMedia(server.getExternalAddress(), userAgentConnection.getLocalDescriptor().toString().getBytes()); initialInvite.setContent(offer, "application/sdp"); initialInvite.send(); } catch(final Exception exception) { cleanup(); setState(FAILED); fireStatusChanged(); final StringBuilder buffer = new StringBuilder(); buffer.append("There was an error while dialing out from "); buffer.append(initialInvite.getFrom().toString()).append(" to "); buffer.append(initialInvite.getTo().toString()); throw new CallException(exception); } }
/** * * Extracts the User SIP identity from a request header * * @param request * @param useTo Whether or not to use the To field in the SIP header * @return */ public static String getUserSipId(final SipServletRequest request, boolean useTo) { final SipURI toUri; final String toUser; if (useTo) { toUri = (SipURI) request.getTo().getURI(); toUser = toUri.getUser(); } else { toUri = (SipURI) request.getRequestURI(); toUser = toUri.getUser(); } return toUser; }
final MobicentsSipSession sessionImpl = (MobicentsSipSession) session; final SipServletRequestImpl newSubsequentServletRequest = (SipServletRequestImpl) session.createRequest(origRequest.getMethod()); if(origRequest.getContent() != null && origRequest.getContentType() != null) { newSubsequentServletRequest.setContentLength(origRequest.getContentLength()); newSubsequentServletRequest.setContent(origRequest.getContent(), origRequest.getContentType());
logger.debug("headerName=" + headerName + " headerVal=" + message.getHeader(headerName)); javax.servlet.sip.URI reqURI = message.getRequestURI(); if(logger.isDebugEnabled()) { logger.debug("ReqURI="+reqURI.toString()+" msgReqURI="+message.getRequestURI()); message.setRequestURI(reqURI); if(logger.isDebugEnabled()) { logger.debug("ReqURI="+reqURI.toString()+" msgReqURI="+message.getRequestURI()); String headerVal = message.getHeader(headerName); message.pushRoute((SipURI)uri); if(logger.isDebugEnabled()) { logger.debug("added ROUTE parVal =" + uri.toString()); StringBuilder sb = new StringBuilder(); try { String headerVal = message.getHeader(headerName); if (headerVal != null && !headerVal.isEmpty()) { if (entry.getValue() instanceof ArrayList) { message.setHeader(headerName, headerVal + sb.toString()); } else { message.addHeader(headerName, sb.toString()); logger.debug("headerName=" + headerName + " headerVal=" + message.getHeader(headerName));
CallDetailRecord callRecord = records.getCallDetailRecord((Sid) request.getSession().getAttribute(CDR_SID)); SipServletResponse clonedResponse = linkedRequest.createResponse(response.getStatus()); SipURI originalURI = null; try { CallDetailRecord callRecord = records.getCallDetailRecord((Sid) linkedRequest.getSession().getAttribute(CDR_SID)); Sid organizationSid = daoManager.getAccountsDao().getAccount(callRecord.getAccountSid()).getOrganizationSid(); logger.info("CDR found! Updating"); if (!linkedRequest.getMethod().equalsIgnoreCase("BYE")) { if (response.getStatus() == 100 || response.getStatus() == 180 || response.getStatus() == 183) { callRecord = callRecord.setStatus(CallStateChanged.State.RINGING.name());
public synchronized void trying(final SipServletRequest request) throws CallException { assertState(IDLE); final SipServletResponse trying = request.createResponse(SipServletResponse.SC_TRYING); try{ trying.send(); fireStatusChanged(); if(request.getContentLength() == 0 || !"application/sdp".equalsIgnoreCase(request.getContentType())) { final SipServletResponse response = request.createResponse(SipServletResponse.SC_BAD_REQUEST); response.send(); throw new CallException("The remote client did not send an SDP offer with their INVITE request."); final byte[] offer = patchMedia(request.getInitialRemoteAddr(), request.getRawContent()); final ConnectionDescriptor remoteDescriptor = new ConnectionDescriptor(new String(offer)); userAgentConnection = session.createConnection(relayEndpoint, remoteDescriptor);
public Object extract(Object input) { return ((SipServletRequest) input).getTo(); } }
if(origRequest.getMaxForwards() == 0) { throw new TooManyHopsException(); newRequest, origRequest.getSession().getServletContext()); final FromHeader newFromHeader = (FromHeader) newRequest.getHeader(FromHeader.NAME); newFromHeader.removeParameter("tag"); null, null, JainSipUtils.DIALOG_CREATING_METHODS.contains(newRequest.getMethod())); final String method = origRequest.getMethod();
sipFactory.createRequest(sipApplicationSession, "INVITE", fromAddress, toAddress); URI requestURI = sipFactory.createURI(toAddr); sipServletRequest.setRequestURI(requestURI); sipServletRequest.getSession().setAttribute("SecondPartyAddress", fromAddress); sipServletRequest.getSession().setAttribute("HelpCall", Boolean.TRUE); sipServletRequest.send();
/** * Invoked by the server (via the service method) to handle incoming INFO requests. * The default implementation is empty and must be overridden by subclasses to do something useful. */ protected void doInfo(javax.servlet.sip.SipServletRequest req) throws javax.servlet.ServletException, java.io.IOException{ if (req.isInitial()) notHandled(req); }
/** * Check if a client is authenticated. If so, return true. Otherwise request authentication and return false; * @param request * @param storage * @param organizationSid * @return * @throws IOException */ public static boolean checkAuthentication(SipServletRequest request, DaoManager storage, Sid organizationSid) throws IOException { // Make sure we force clients to authenticate. final String authorization = request.getHeader("Proxy-Authorization"); final String method = request.getMethod(); if (authorization == null || !CallControlHelper.permitted(authorization, method, storage, organizationSid)) { if (logger.isDebugEnabled()) { String msg = String.format("Either authorization header is null [if(authorization==null) evaluates %s], or CallControlHelper.permitted() method failed, will send \"407 Proxy Authentication required\"", authorization==null); logger.debug(msg); } authenticate(request, storage.getOrganizationsDao().getOrganization(organizationSid).getDomainName()); return false; } else { return true; } }
public void onEvent(PlayerEvent event) { try { logger.info("ENDING CALL "); Player player = event.getSource(); MediaGroup mg = player.getContainer(); if (event.isSuccessful() && (PlayerEvent.PLAY_COMPLETED == event.getEventType())) { MediaSession session =(MediaSession)sipSession.getAttribute("mediaSession"); session.release(); Thread.sleep(1500); SipServletRequest byeRequest = sipSession.createRequest("BYE"); byeRequest.send(); } } catch (Exception e) { logger.error("Error", e); } }
/** * * @param req * @throws IOException */ private void notImplemented(SipServletRequest req) throws IOException { SipServletResponse resp = req.createResponse(501, "Request not implemented"); resp.send(); } }