public void addAuthHeader(SipServletResponse challengeResponse, String username, String password) { addAuthHeader(challengeResponse, username, password, false); }
@Override public void removeAttribute(String name) { checkReadOnly(); super.removeAttribute(name); }
protected SipServletRequestImpl(Request request, SipFactoryImpl sipFactoryImpl, MobicentsSipSession sipSession, Transaction transaction, Dialog dialog, boolean createDialog) { super(request, sipFactoryImpl, transaction, sipSession, dialog); this.createDialog = createDialog; routingState = checkRoutingState(this, dialog); if(RoutingState.INITIAL.equals(routingState)) { isInitial = true; } isFinalResponseGenerated = false; }
/** * {@inheritDoc} */ public Proxy getProxy() throws TooManyHopsException { checkReadOnly(); final MobicentsSipSession session = getSipSession(); if (session.getB2buaHelper() != null ) throw new IllegalStateException("Cannot proxy request"); return getProxy(true); }
public void pushRoute(SipURI uri) { checkReadOnly(); javax.sip.address.SipURI sipUri = ((SipURIImpl) uri).getSipURI(); sipUri.setLrParam(); pushRoute(sipUri); }
public void send(Hop hop) throws IOException { final Request request = (Request) super.message; final String requestMethod = getMethod(); final MobicentsSipSession session = getSipSession(); final String sessionTransport = session.getTransport(); final SipNetworkInterfaceManager sipNetworkInterfaceManager = sipFactoryImpl.getSipNetworkInterfaceManager(); getSipSession().setRequestsPending(0); Transaction tx = inviteTransactionToCancel; if(logger.isDebugEnabled()) { checkViaHeaderAddition(hop); checkViaHeaderUpdateOrForStaticExternalAddressUsage(matchingListeningPoint, hop); addDnsRoute(hop, request); sendAck(transport, sipConnector, matchingListeningPoint); return; if(isInitial()) { addInfoForRoutingBackToContainer(routerInfo, session.getSipApplicationSession().getKey().getId(), session.getKey().getApplicationName()); addDNSRoute = false; if(isInitial() || dialog == null) { addDnsRoute(hop, request); getSipSession().getSipApplicationSession().getSipContext().getSipManager().dumpSipSessions();
public SipServletResponse createResponse(final int statusCode, final String reasonPhrase, boolean validate, boolean hasBeenReceived) { checkReadOnly(); final Transaction transaction = getTransaction(); if(RoutingState.CANCELLED.equals(routingState)) { throw new IllegalStateException("Cannot create a response for the invite, a CANCEL has been received and the INVITE was replied with a 487!"); final Request request = (Request) this.getMessage(); final Response response = SipFactoryImpl.messageFactory.createResponse( statusCode, request); response.setReasonPhrase(reasonPhrase); final MobicentsSipSession session = getSipSession(); final String requestMethod = getMethod(); if((statusCode > Response.TRYING || !isInitial()) && statusCode <= Response.SESSION_NOT_ACCEPTABLE) { final ToHeader toHeader = (ToHeader) response .getHeader(ToHeader.NAME); if(session != null && session.getCopyRecordRouteHeadersOnSubsequentResponses() && !isInitial() && Request.INVITE.equals(requestMethod)) { validate ? (ServerTransaction) transaction : transaction, session, getDialog(), hasBeenReceived, false); newSipServletResponse.setOriginalRequest(this); if(!Request.PRACK.equals(requestMethod) && statusCode >= Response.OK &&
public void setRoutingDirective(SipApplicationRoutingDirective directive, SipServletRequest origRequest) throws IllegalStateException { checkReadOnly(); SipServletRequestImpl origRequestImpl = (SipServletRequestImpl) origRequest; final MobicentsSipSession session = getSipSession(); directive == SipApplicationRoutingDirective.CONTINUE)){ if(origRequestImpl == null || !origRequestImpl.isInitial()) { if(logger.isDebugEnabled()) { logger.debug("directive to set : " + directive); logger.debug("Original Request Routing State : " + origRequestImpl.getRoutingState()); } else { session.setStateInfo(origRequestImpl.getSipSession().getStateInfo()); currentApplicationName = origRequestImpl.getCurrentApplicationName(); origRequestImpl.setLinkedRequest(this); setLinkedRequest(origRequestImpl);
public void addAuthHeader(SipServletResponse challengeResponse, String username, String password, boolean cacheCredentials) { checkReadOnly(); SipServletResponseImpl challengeResponseImpl = (SipServletResponseImpl) challengeResponse; removeStaleAuthHeaders(wwwAuthHeader); addChallengeResponse(wwwAuthHeader, username, password, this.getRequestURI().toString()); getSipSession().getSipSessionSecurity().addCachedAuthInfo(wwwAuthHeader.getRealm(), new AuthInfoEntry(response.getStatusCode(), username, password)); removeStaleAuthHeaders(proxyAuthHeader); String uri = proxyAuthHeader.getParameter("uri"); if(uri == null) uri = this.getRequestURI().toString(); addChallengeResponse(proxyAuthHeader, username, password, uri); getSipSession().getSipSessionSecurity().addCachedAuthInfo(proxyAuthHeader.getRealm(), new AuthInfoEntry(response.getStatusCode(), username, password));
@Override public void send() throws IOException { checkReadOnly(); checkMessageState(); final Request request = (Request) super.message; final String requestMethod = getMethod(); final SipApplicationDispatcher sipApplicationDispatcher = sipFactoryImpl.getSipApplicationDispatcher(); final MobicentsSipSession session = getSipSession(); final DNSServerLocator dnsServerLocator = sipApplicationDispatcher.getDNSServerLocator(); Hop hop = null; uriToResolve = resolveSipOutbound(uriToResolve); send(hop);
checkReadOnly(); final MobicentsSipSession session = getSipSession(); if (session.getB2buaHelper() != null ) throw new IllegalStateException("Cannot proxy request"); if(mfHeader.getMaxForwards()<=0) { try { this.createResponse(Response.TOO_MANY_HOPS, "Too many hops").send(); } catch (IOException e) { throw new RuntimeException("could not send the Too many hops response out !", e); MobicentsProxy proxy = session.getProxy(); boolean createNewProxy = false; if(isInitial() && proxy != null && proxy.getOriginalRequest() == null) { createNewProxy = true;
.removeParameter("tag"); final MobicentsSipSession originalSession = origRequestImpl.getSipSession(); final MobicentsSipApplicationSession appSession = originalSession .getSipApplicationSession(); JainSipUtils.DIALOG_CREATING_METHODS.contains(newRequest.getMethod())); newSipServletRequest.setRoutingDirective(SipApplicationRoutingDirective.CONTINUE, origRequest); newSipServletRequest.addHeaderInternal(ContactHeader.NAME, contactHeaderValue, true); ListIterator<ContactHeader> contactHeaders = newSipServletRequest.getMessage().getHeaders(ContactHeader.NAME); while (contactHeaders.hasNext()) { final URI contactURI = contactHeaders.next().getAddress().getURI();
public B2buaHelper getB2buaHelper() { checkReadOnly(); final MobicentsSipSession session = getSipSession(); if (session.getProxy() != null) throw new IllegalStateException("Proxy already present"); MobicentsB2BUAHelper b2buaHelper = session.getB2buaHelper(); if (b2buaHelper != null) return b2buaHelper; b2buaHelper = new B2buaHelperImpl(); b2buaHelper.setMobicentsSipFactory(sipFactoryImpl); b2buaHelper.setSipManager(session.getSipApplicationSession().getSipContext().getSipManager()); if(JainSipUtils.DIALOG_CREATING_METHODS.contains(getMethod())) { this.createDialog = true; // flag that we want to create a dialog for outgoing request. } session.setB2buaHelper(b2buaHelper); return b2buaHelper; }
public SipServletRequest createCancel() { checkReadOnly(); if (!((Request) message).getMethod().equals(Request.INVITE)) { throw new IllegalStateException( "Cannot create CANCEL for non invite " + message); } if (super.getTransaction() == null || super.getTransaction() instanceof ServerTransaction) throw new IllegalStateException("No client transaction found! " + super.getTransaction()); if(RoutingState.FINAL_RESPONSE_SENT.equals(routingState) || lastFinalResponse != null) { if(lastFinalResponse != null) { throw new IllegalStateException("final response already sent : " + lastFinalResponse); } else { throw new IllegalStateException("final response already sent!"); } } try { Request cancelRequest = ((ClientTransaction) getTransaction()) .createCancel(); SipServletRequestImpl newRequest = (SipServletRequestImpl) sipFactoryImpl.getMobicentsSipServletMessageFactory().createSipServletRequest( cancelRequest, getSipSession(), null, getTransaction().getDialog(), false); newRequest.inviteTransactionToCancel = super.getTransaction(); return newRequest; } catch (SipException ex) { throw new IllegalStateException("Could not create cancel", ex); } }
ContactHeader contactHeader) throws ParseException { Request newRequest = (Request) newSipServletRequest.getMessage(); for (String contactHeaderValue : contactHeaderSet) { newSipServletRequest.addHeaderInternal(ContactHeader.NAME, contactHeaderValue, true);
public void addAuthHeader(SipServletResponse challengeResponse, AuthInfo authInfo, boolean cacheCredentials) { checkReadOnly(); AuthInfoImpl authInfoImpl = (AuthInfoImpl) authInfo; removeStaleAuthHeaders(wwwAuthHeader); "Cannot add authorization header. No credentials for the following realm: " + wwwAuthHeader.getRealm()); addChallengeResponse(wwwAuthHeader, authInfoEntry.getUserName(), authInfoEntry.getPassword(), this.getRequestURI().toString()); getSipSession().getSipSessionSecurity().addCachedAuthInfo(wwwAuthHeader.getRealm(), authInfoEntry); removeStaleAuthHeaders(proxyAuthHeader); "No credentials for the following realm: " + proxyAuthHeader.getRealm()); addChallengeResponse(proxyAuthHeader, authInfoEntry.getUserName(), authInfoEntry.getPassword(), this.getRequestURI().toString()); getSipSession().getSipSessionSecurity().addCachedAuthInfo(proxyAuthHeader.getRealm(), authInfoEntry);
/** * {@inheritDoc} */ public void pushRoute(Address address) { checkReadOnly(); if(address.getURI() instanceof TelURL) { throw new IllegalArgumentException("Cannot push a TelUrl as a route !"); } javax.sip.address.SipURI sipUri = (javax.sip.address.SipURI) ((AddressImpl) address) .getAddress().getURI(); pushRoute(sipUri); }
@Override public void setAcceptLanguage(Locale locale) { checkReadOnly(); super.setAcceptLanguage(locale); }
public void addAuthHeader(SipServletResponse challengeResponse, AuthInfo authInfo) { addAuthHeader(challengeResponse, authInfo, false); }
@Override public void setHeader(String name, String value) { checkReadOnly(); super.setHeader(name, value); }