en-US.Section-Source_Block.xml Maven / Gradle / Ivy
The newest version!
<?xml version='1.0'?> <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ <!ENTITY % BOOK_ENTITIES SYSTEM "JAIN_SLEE_Example_User_Guide.ent"> %BOOK_ENTITIES; ]> <section id="source_block"> <title>Blocking Service Source</title> <para>Blocking service is simplest of services in &THIS.EXAMPLE; </para> <para> It processes incoming <acronym>SIP</acronym> <literal>INVITE</literal> request and based on callee and caller denies or allows call to happen. </para> <section id="source_block_root"> <title>Service root</title> <para>Root class of this service is <literal>org.mobicents.slee.examples.callcontrol.blocking.CallBlockingSbb</literal> </para> </section> <section id="source_block_event"> <title>Events handlers</title> <para>Call blocking service receives only one event: <acronym>SIP</acronym> INVITE request. Its responsibility is:</para> <itemizedlist> <listitem> <para>extract callee <acronym>AOR</acronym> </para> </listitem> <listitem> <para>determine list of blocked users for callees <acronym>AOR</acronym></para> </listitem> <listitem> <para>terminate call if caller <acronym>AOR</acronym> is blocked and set <acronym>ACI</acronym> variable to indicate that call has been handled </para> </listitem> </itemizedlist> <para>It is defined as follows: </para> <programlisting role="JAVA" language="Java"> public void onInvite(javax.sip.RequestEvent event, CallBlockingSbbActivityContextInterface localAci) { Request request = event.getRequest(); try { localAci.detach(this.getSbbLocalObject()); FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME); ToHeader toHeader = (ToHeader) request.getHeader(ToHeader.NAME); // From URI URI fromURI = fromHeader.getAddress().getURI(); // To URI URI toURI = toHeader.getAddress().getURI(); // In the Profile Table the port is not used ((SipURI)fromURI).removePort(); ((SipURI)toURI).removePort(); ArrayList targets = getBlockedArrayList(toURI.toString()); if (targets != null) { // Cheking whether the caller is blocked by the called user for (int i = 0; i < targets.size(); i++) { if ((targets.get(i).toString()).equalsIgnoreCase(fromURI.toString())) { log.info("########## BLOCKING ADDRESS: " + targets.get(i)); log.info("########## BLOCKING FOR URI: " + toURI); localAci.setFilteredByMe(true); // Notifiying the client that the INVITE has been blocked ServerTransaction stBlocking = (ServerTransaction) localAci.getActivity(); Response blockingResponse = getMessageFactory().createResponse( Response.FORBIDDEN, request); stBlocking.sendResponse(blockingResponse); } } } } catch (TransactionRequiredLocalException e) { log.error(e.getMessage(), e); } catch (SLEEException e) { log.error(e.getMessage(), e); } catch (ParseException e) { log.error(e.getMessage(), e); } catch (SipException e) { log.error(e.getMessage(), e); } catch (InvalidArgumentException e) { log.error(e.getMessage(), e); } } </programlisting> </section> <section id="source_block_profile"> <title>User profile access</title> <para>Call Blocking <acronym>SBB</acronym> accesses examples profile in order to determine if callee has defined caller as blocked.</para> <para>Profile is accessed in following way:</para> <programlisting role="JAVA" language="Java"> public abstract class CallBlockingSbb extends SubscriptionProfileSbb implements javax.slee.Sbb { ... /** * Attempt to find a list of Blocked Addresses (SIP URIs), but the method * returns null if the called user (sipAddress) does not block to any user. */ private ArrayList getBlockedArrayList(String sipAddress) { //sipAddress is AOR: sip:[email protected] ArrayList uris = null; CallControlProfileCMP profile = super.lookup(new Address(AddressPlan.SIP, sipAddress)); if (profile != null) { Address[] addresses = profile.getBlockedAddresses(); if (addresses != null) { uris = new ArrayList(addresses.length); for (int i = 0; i < addresses.length; i++) { String address = addresses[i].getAddressString(); try { SipURI uri = (SipURI) getAddressFactory().createURI(address); uris.add(uri); } catch (ParseException e) { log.error(e.getMessage(), e); } } } } return uris; } } </programlisting> </section> <section id="source_block_descriptor"> <title>Call Blocking <acronym>SBB</acronym> descriptor</title> <para>Descriptor contains following definitions:</para> <itemizedlist> <listitem> <para>sbb ID</para> </listitem> <listitem> <para>profile reference by profile ID</para> </listitem> <listitem> <para>sbb abstract class</para> </listitem> <listitem> <para>custom <acronym>ACI</acronym> </para> </listitem> <listitem> <para><acronym>ACI</acronym> variable alias </para> </listitem> <listitem> <para>event handler with initial event selector</para> </listitem> <listitem> <para>resource adaptor binding</para> </listitem> </itemizedlist> <programlisting language="XML" role="XML"><![CDATA[ <sbb> <description /> <sbb-name>CallBlockingSbb</sbb-name> <sbb-vendor>org.mobicents</sbb-vendor> <sbb-version>0.1</sbb-version> <profile-spec-ref> <profile-spec-name>CallControlProfileCMP</profile-spec-name> <profile-spec-vendor>org.mobicents</profile-spec-vendor> <profile-spec-version>0.1</profile-spec-version> <profile-spec-alias>CallControlProfile</profile-spec-alias> </profile-spec-ref> <sbb-classes> <sbb-abstract-class> <sbb-abstract-class-name> org.mobicents.slee.examples.callcontrol.blocking.CallBlockingSbb </sbb-abstract-class-name> </sbb-abstract-class> <sbb-activity-context-interface> <sbb-activity-context-interface-name> org.mobicents.slee.examples.callcontrol.blocking.CallBlockingSbbActivityContextInterface </sbb-activity-context-interface-name> </sbb-activity-context-interface> </sbb-classes> <event event-direction="Receive" initial-event="True"> <event-name>Invite</event-name> <event-type-ref> <event-type-name>javax.sip.message.Request.INVITE</event-type-name> <event-type-vendor>net.java.slee</event-type-vendor> <event-type-version>1.2</event-type-version> </event-type-ref> <initial-event-selector-method-name>callIDSelect</initial-event-selector-method-name> </event> <activity-context-attribute-alias> <attribute-alias-name>inviteFilteredByCallBlocking</attribute-alias-name> <sbb-activity-context-attribute-name>filteredByMe</sbb-activity-context-attribute-name> </activity-context-attribute-alias> <resource-adaptor-type-binding> <resource-adaptor-type-ref> <resource-adaptor-type-name>JAIN SIP</resource-adaptor-type-name> <resource-adaptor-type-vendor>javax.sip</resource-adaptor-type-vendor> <resource-adaptor-type-version>1.2</resource-adaptor-type-version> </resource-adaptor-type-ref> <activity-context-interface-factory-name>slee/resources/jainsip/1.2/acifactory</activity-context-interface-factory-name> <resource-adaptor-entity-binding> <resource-adaptor-object-name>slee/resources/jainsip/1.2/provider</resource-adaptor-object-name> <resource-adaptor-entity-link>SipRA</resource-adaptor-entity-link> </resource-adaptor-entity-binding> </resource-adaptor-type-binding> </sbb> ]]> </programlisting> </section> </section>