Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * JBoss, Home of Professional Open Source
  * Copyright 2011, Red Hat, Inc. and individual contributors
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.mobicents.servlet.sip.example;
This examle shows Call Blocking Capabilities. It makes the sip servlet acts as a UAS. Based on the from header it blocks the call if it founds the address in its hard coded black list.

Author(s):
Jean Deruelle
public class CallBlockingSipServlet extends SipServlet implements SipServletListener {
	private static final long serialVersionUID = 1L;
	private static Logger logger = Logger.getLogger(CallBlockingSipServlet.class);
	List<StringblockedUris = null;

Creates a new instance of CallBlockingSipServlet
	public void init(ServletConfig servletConfigthrows ServletException {
		.info("the call blocking sip servlet has been started");
		super.init(servletConfig);
		.add("sip:blocked-sender@sip-servlets.com");
		.add("sip:blocked-sender@127.0.0.1");
	}
	protected void doInvite(SipServletRequest requestthrows ServletException,
		.info("Got request:\n"
request.toString());
		String fromUri = request.getFrom().getURI().toString();
		.info(fromUri);
		if(.contains(fromUri)) {
			.info(fromUri + " has been blocked !");
			sipServletResponse.send();		
else {
			.info(fromUri + " has not been blocked, we proxy the request");
			request.getProxy().proxyTo(request.getRequestURI());
		}
	}
	protected void doBye(SipServletRequest reqthrows ServletException,
		.info("Call Blocking doesn't handle BYE requests");
	}
		.info("the call blocking sip servlet has been initialized");
	}
New to GrepCode? Check out our FAQ X