public void addFirst(Header header) throws SipException, NullPointerException { if (header == null) throw new NullPointerException("null arg!"); try { this.attachHeader((SIPHeader) header, false, true); } catch (SIPDuplicateHeaderException ex) { throw new SipException("Cannot add header - header already exists"); } }
public void addLast(Header header) throws SipException, NullPointerException { if (header == null) throw new NullPointerException("null arg!"); try { this.attachHeader((SIPHeader) header, false, false); } catch (SIPDuplicateHeaderException ex) { throw new SipException("Cannot add header - header already exists"); } }
public Request createRequest(String method) throws SipException { if (method.equals(Request.ACK) || method.equals(Request.PRACK)) { throw new SipException( "Invalid method specified for createRequest:" + method); } if (lastResponseTopMostVia != null) return this.createRequest(method, this.lastResponseTopMostVia .getTransport()); else throw new SipException("Dialog not yet established -- no response!"); }
@Override public void start() throws ProviderDoesNotExistException, SipException { super.start(); String mBeanName=JAIN_SIP_MBEAN_NAME + stackName; try { oname = new ObjectName(mBeanName); if (getMBeanServer() != null && !getMBeanServer().isRegistered(oname)) { getMBeanServer().registerMBean(this, oname); } } catch (Exception e) { logger.logError("Could not register the stack as an MBean under the following name", e); throw new SipException("Could not register the stack as an MBean under the following name " + mBeanName + ", cause: " + e.getMessage(), e); } }
@Override public void start() throws ProviderDoesNotExistException, SipException { try { sipCache.start(); } catch (Exception e) { throw new SipException("Unable to start the SipCache", e); } if(loadBalancerHeartBeatingService != null) { loadBalancerHeartBeatingService.start(); } super.start(); }
public StringBuilder encodeBody(StringBuilder encoding) { // StringBuilder encoding = new StringBuilder(); /* * no need to check for the presence of icid-value. According to the * spec above this is a mandatory field. if it does not exist, then we * should throw an exception * * JvB 26/5: fix for issue #159, check for quotes around icid value * * Aayush: 29th November 2011 : Added fix for P-Charging-Vector header's parameters to accept quoted string values. */ gov.nist.core.NameValue nv = getNameValue( ParameterNamesIms.ICID_VALUE ); if(nv!=null) this.parameters.encode(encoding); else try { throw new SipException("icid-value is mandatory"); } catch (SipException e) { e.printStackTrace(); } return encoding; }
private ActivityContextInterface getPeerDialog(ActivityContextInterface aci) throws SipException { final ActivityContextInterface incomingDialogAci = getIncomingDialog(); if (aci.equals(incomingDialogAci)) { return getOutgoingDialog(); } if (aci.equals(getOutgoingDialog())) { return incomingDialogAci; } throw new SipException("could not find peer dialog"); }
private void forwardResponse(DialogActivity in, DialogActivity out, ClientTransaction ct, Response receivedResponse) throws SipException { // Find the original server transaction that this response // should be forwarded on. final ServerTransaction st = in.getAssociatedServerTransaction(ct); // could be null if (st == null) throw new SipException( "could not find associated server transaction"); if (tracer.isInfoEnabled()) { tracer.info("Forwarding response " + receivedResponse.getStatusCode() + " to dialog " + out); } // Copy the response across, setting the appropriate headers for the // dialog final Response outgoingResponse = out.createResponse(st, receivedResponse); // Forward response upstream. try { st.sendResponse(outgoingResponse); } catch (InvalidArgumentException e) { tracer.severe("Failed to send response:\n" + outgoingResponse, e); throw new SipException("invalid response", e); } }
public void sendResponse(Response response) throws SipException { if (!sipStack.isAlive()) throw new SipException("Stack is stopped"); SIPResponse sipResponse = (SIPResponse) response; Via via = sipResponse.getTopmostVia(); if (via == null) throw new SipException("No via header in response!"); SIPServerTransaction st = (SIPServerTransaction) sipStack.findTransaction((SIPMessage)response, true); if ( st != null && st.getInternalState() != TransactionState._TERMINATED && this.isAutomaticDialogSupportEnabled()) { throw new SipException("Transaction exists -- cannot send response statelessly"); .getListeningPoint(transport); if (listeningPoint == null) throw new SipException( "whoopsa daisy! no listening point found for transport " + transport); messageChannel.sendMessage(sipResponse); } catch (IOException ex) { throw new SipException(ex.getMessage());
@Override public void send(SIPRequest ackRequest) throws SipException, IOException { hop = sipStack.getNextHop(ackRequest); if (hop == null) throw new SipException("No route!"); if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) logger.logDebug("hop = " + hop); ListeningPointImpl lp = (ListeningPointImpl) sipProvider .getListeningPoint(hop.getTransport()); if (lp == null) throw new SipException( "No listening point for this provider registered at " + hop); InetAddress inetAddress = InetAddress.getByName(hop.getHost()); MessageChannel messageChannel = lp.getMessageProcessor() .createMessageChannel(inetAddress, hop.getPort()); messageChannel.sendMessage(ackRequest); }
public void sendReliableProvisionalResponse(Response relResponse) throws SipException { if (!this.isServer()) { throw new SipException("Not a Server Dialog"); throw new SipException( "Cannot send 100 as a reliable provisional response"); throw new SipException( "Response code is not a 1xx response - should be in the range 101 to 199 "); throw new SipException( "Badly formatted response -- To tag mandatory for Reliable Provisional Response");
@Override public void start() throws ProviderDoesNotExistException, SipException { super.start(); String mBeanName=JAIN_SIP_MBEAN_NAME + stackName; try { oname = new ObjectName(mBeanName); if (getMBeanServer() != null && !getMBeanServer().isRegistered(oname)) { getMBeanServer().registerMBean(this, oname); } } catch (Exception e) { getStackLogger().logError("Could not register the stack as an MBean under the following name", e); throw new SipException("Could not register the stack as an MBean under the following name " + mBeanName + ", cause: " + e.getMessage(), e); } try { if(getStackLogger().isLoggingEnabled(StackLogger.TRACE_INFO)) { getStackLogger().logInfo("Adding notification listener for logging mbean \"" + LOG4J_SERVICE_MBEAN_NAME + "\" to server " + getMBeanServer()); } getMBeanServer().addNotificationListener(new ObjectName(LOG4J_SERVICE_MBEAN_NAME), this, null, null); } catch (Exception e) { getStackLogger().logWarning("Could not register the stack as a Notification Listener of " + LOG4J_SERVICE_MBEAN_NAME + " runtime changes to log4j.xml won't affect SIP Stack Logging"); } }
throw new SipException("Stack is stopped."); throw new SipException(" Error - AUTOMATIC_DIALOG_SUPPORT is on"); throw new SipException("Dialog cannot be created for this method " + transaction.getRequest().getMethod()); if (response != null) { if (response.getStatusCode() != 100) throw new SipException( "Cannot set dialog after response has been sent"); dialog = sipStack.getDialog(dialogId); if (dialog != null) { throw new SipException("Dialog already exists!"); } else { dialog = sipStack.createDialog(sipTransaction); throw new SipException( "Cannot call this method after response is received!");
throw new SipException("Not a Server Dialog!"); SIPRequest request = this.originalRequest; if (!request.getMethod().equals(Request.INVITE)) throw new SipException("Bad method"); list = request.getHeaders(RequireHeader.NAME); if (list == null || !optionPresent(list, "100rel")) { throw new SipException( "No Supported/Require 100rel header in the request");
throw new SipException( "Exception rethrown as SipException in sendRequest", e);
public void sendRequest(Request request) throws SipException { if (!sipStack.isAlive()) throw new SipException("Stack is stopped."); throw new SipException("could not determine next hop!"); SIPRequest sipRequest = (SIPRequest) request; throw new SipException("Invalid SipRequest -- no via header!"); logger.logDebug("Could not create a message channel for " + hop.toString() + " listeningPoints = " + this.listeningPoints); throw new SipException( "Could not create a message channel for " + hop.toString()); throw new SipException( "IO Exception occured while Sending Request", ex);
/** * This timer task is used to garbage collect the dialog after some time. * */ class DialogDeleteIfNoAckSentTask extends SIPStackTimerTask implements Serializable { private long seqno; public DialogDeleteIfNoAckSentTask(long seqno) { this.seqno = seqno; } public void runTask() { if (SIPDialog.this.highestSequenceNumberAcknowledged < seqno) { /* * Did not send ACK so we need to delete the dialog. B2BUA NOTE: * we may want to send BYE to the Dialog at this point. Do we * want to make this behavior tailorable? */ dialogDeleteIfNoAckSentTask = null; if (!SIPDialog.this.isBackToBackUserAgent) { if (logger.isLoggingEnabled()) logger.logError( "ACK Was not sent. killing dialog " + dialogId); if (((SipProviderImpl) sipProvider).getSipListener() instanceof SipListenerExt) { raiseErrorEvent(SIPDialogErrorEvent.DIALOG_ACK_NOT_SENT_TIMEOUT); } else { delete(); }
throw new SipException("Attempt to create CANCEL for " + this.getMethod());
public Request createPrack(Response relResponse) throws DialogDoesNotExistException, SipException { if (this.getState() == null || this.getState().equals(DialogState.TERMINATED)) throw new DialogDoesNotExistException( "Dialog not initialized or terminated"); if ((RSeq) relResponse.getHeader(RSeqHeader.NAME) == null) { throw new SipException("Missing RSeq Header"); } try { SIPResponse sipResponse = (SIPResponse) relResponse; SIPRequest sipRequest = this.createRequest(Request.PRACK, sipResponse.getTopmostVia().getTransport()); String toHeaderTag = sipResponse.getTo().getTag(); sipRequest.setToTag(toHeaderTag); RAck rack = new RAck(); RSeq rseq = (RSeq) relResponse.getHeader(RSeqHeader.NAME); rack.setMethod(sipResponse.getCSeq().getMethod()); rack.setCSequenceNumber((int) sipResponse.getCSeq().getSeqNumber()); rack.setRSequenceNumber(rseq.getSeqNumber()); sipRequest.setHeader(rack); if (this.proxyAuthorizationHeader != null) { sipRequest.addHeader(proxyAuthorizationHeader); } return (Request) sipRequest; } catch (Exception ex) { InternalErrorHandler.handleException(ex); return null; } }
return hop; } else { throw new SipException("First Route not a SIP URI");