Cisco Service Control Subscriber Manager Java API Programmer Guide

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "Cisco Service Control Subscriber Manager Java API Programmer Guide"

Transcription

1 Cisco Service Control Subscriber Manager Java API Programmer Guide Release 3.8.x December 21, 2012 Americas Headquarters Cisco Systems, Inc. 170 West Tasman Drive San Jose, CA USA Tel: NETS (6387) Fax: Text Part Number:

2 THE SPECIFICATIONS AND INFORMATION REGARDING THE PRODUCTS IN THIS MANUAL ARE SUBJECT TO CHANGE WITHOUT NOTICE. ALL STATEMENTS, INFORMATION, AND RECOMMENDATIONS IN THIS MANUAL ARE BELIEVED TO BE ACCURATE BUT ARE PRESENTED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. USERS MUST TAKE FULL RESPONSIBILITY FOR THEIR APPLICATION OF ANY PRODUCTS. THE SOFTWARE LICENSE AND LIMITED WARRANTY FOR THE ACCOMPANYING PRODUCT ARE SET FORTH IN THE INFORMATION PACKET THAT SHIPPED WITH THE PRODUCT AND ARE INCORPORATED HEREIN BY THIS REFERENCE. IF YOU ARE UNABLE TO LOCATE THE SOFTWARE LICENSE OR LIMITED WARRANTY, CONTACT YOUR CISCO REPRESENTATIVE FOR A COPY. The Cisco implementation of TCP header compression is an adaptation of a program developed by the University of California, Berkeley (UCB) as part of UCB s public domain version of the UNIX operating system. All rights reserved. Copyright 1981, Regents of the University of California. NOTWITHSTANDING ANY OTHER WARRANTY HEREIN, ALL DOCUMENT FILES AND SOFTWARE OF THESE SUPPLIERS ARE PROVIDED AS IS WITH ALL FAULTS. CISCO AND THE ABOVE-NAMED SUPPLIERS DISCLAIM ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THOSE OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. IN NO EVENT SHALL CISCO OR ITS SUPPLIERS BE LIABLE FOR ANY INDIRECT, SPECIAL, CONSEQUENTIAL, OR INCIDENTAL DAMAGES, INCLUDING, WITHOUT LIMITATION, LOST PROFITS OR LOSS OR DAMAGE TO DATA ARISING OUT OF THE USE OR INABILITY TO USE THIS MANUAL, EVEN IF CISCO OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Cisco and the Cisco logo are trademarks or registered trademarks of Cisco and/or its affiliates in the U.S. and other countries. To view a list of Cisco trademarks, go to this URL: Third-party trademarks mentioned are the property of their respective owners. The use of the word partner does not imply a partnership relationship between Cisco and any other company. (1110R) Any Internet Protocol (IP) addresses and phone numbers used in this document are not intended to be actual addresses and phone numbers. Any examples, command display output, network topology diagrams, and other figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses or phone numbers in illustrative content is unintentional and coincidental Cisco Systems, Inc. All rights reserved.

3 CONTENTS About this Guide xi Introduction xi Document Revision History xii Organization xiii Related Documentation xiii Conventions xiv Obtaining Documentation and Submitting a Service Request xv CHAPTER 1 Getting Started 1-1 Introduction 1-1 The Java API 1-2 Introduction 1-2 Platforms 1-2 Package Content 1-2 Installing the Java API 1-4 Cisco Service Control Subscriber Manager Setup 1-4 Installing on a UNIX Platform 1-4 Installing on a Windows Platform 1-4 Compiling and Running a Program That Uses API 1-5 CHAPTER 2 General API Concepts 2-1 Introduction 2-1 Blocking API and the Nonblocking API 2-2 Blocking API 2-2 Nonblocking API 2-2 API Initialization 2-3 API Construction 2-3 Constructor that Accepts a LEG Name 2-3 Blocking API Example 2-3 Setup Operations 2-3 Blocking API Setup 2-4 Nonblocking API Setup 2-4 Connecting to the Cisco Service Control Subscriber Manager 2-4 iii

4 Contents API Finalization 2-5 Subscriber Name Format 2-5 Network ID Mappings 2-6 Specifying IP Address Mapping 2-6 Specifying IPv6 Address Mapping 2-7 Specifying IP Range Mapping 2-7 Specifying Private IP Address or Private IP Range over VPN Mapping 2-7 Specifying VLAN Tag Mapping 2-8 Subscriber Domains 2-9 Subscriber Properties 2-9 Custom Properties 2-10 DisconnectListener Interface 2-10 DisconnectListener Interface Example 2-10 Exceptions 2-11 Practical Tips 2-11 CHAPTER 3 Blocking API 3-1 Introduction 3-1 Multithreading Support 3-2 ReplyTimeout and OperationTimeout Exception 3-3 Cisco Service Control Subscriber Manager Blocking API Methods 3-4 login 3-5 Syntax 3-5 Description 3-5 Parameters 3-5 RPC Exception Error Codes 3-6 Return Value 3-6 Examples 3-6 logoutbyname 3-8 Syntax 3-8 Description 3-9 Parameters 3-9 Return Value 3-9 RPC Exception Error Codes 3-9 Examples 3-9 logoutbynamefromdomain 3-10 Syntax 3-10 Description 3-10 iv

5 Contents Parameters 3-10 Return Value 3-10 RPC Exception Error Codes 3-11 Example 3-11 logoutbymapping 3-11 Syntax 3-11 Description 3-12 Parameters 3-12 Return Value 3-12 RPC Exception Error Codes 3-12 Example 3-12 logincable 3-13 Syntax 3-13 Description 3-13 Parameters 3-13 Return Value 3-14 RPC Exception Error Codes 3-14 Examples 3-14 logoutcable 3-16 Syntax 3-16 Description 3-16 Parameters 3-16 Return Value 3-16 RPC Exception Error Codes 3-16 Example 3-16 addsubscriber 3-17 Syntax 3-17 Description 3-17 Example 3-18 Parameters 3-18 Return Value 3-18 RPC Exception Error Codes 3-18 Examples 3-19 removesubscriber 3-19 Syntax 3-19 Description 3-19 Parameters 3-19 Return Value 3-19 RPC Exception Error Codes 3-20 Example 3-20 v

6 Contents removeallsubscribers 3-20 Syntax 3-20 Description 3-20 Return Value 3-20 RPC Exception Error Codes 3-20 getnumberofsubscribers 3-21 Syntax 3-21 Description 3-21 Return Value 3-21 RPC Exception Error Codes 3-21 getnumberofsubscribersindomain 3-21 Syntax 3-21 Description 3-22 Parameters 3-22 Return Value 3-22 RPC Exception Error Codes 3-22 getsubscriber 3-22 Syntax 3-22 Description 3-22 Parameters 3-23 Return Value 3-23 RPC Exception Error Codes 3-23 Example 3-23 subscriberexists 3-25 Syntax 3-25 Description 3-25 Parameters 3-25 Return Value 3-25 RPC Exception Error Codes 3-25 subscriberloggedin 3-25 Syntax 3-26 Description 3-26 Parameters 3-26 Return Value 3-26 RPC Exception Error Codes 3-26 getsubscribernamebymapping 3-26 Syntax 3-27 Description 3-27 Parameters 3-27 Return Value 3-27 vi

7 Contents RPC Exception Error Codes 3-27 getsubscribernames (all) 3-28 Syntax 3-28 Description 3-28 Parameters 3-28 Return Value 3-28 RPC Exception Error Codes 3-29 Example 3-29 getsubscribernames (filter by property) 3-29 Syntax 3-29 Description 3-30 Parameters 3-30 Return Value 3-30 RPC Exception Error Codes 3-30 getsubscribernamesindomain 3-30 Syntax 3-31 Description 3-31 Parameters 3-31 Return Value 3-31 RPC Exception Error Codes 3-31 getsubscribernameswithprefix 3-31 Syntax 3-32 Description 3-32 Parameters 3-32 Return Value 3-32 RPC Exception Error Codes 3-32 getsubscribernameswithsuffix 3-32 Syntax 3-33 Description 3-33 Parameters 3-33 Return Value 3-33 RPC Exception Error Codes 3-33 getdomains 3-33 Syntax 3-34 Description 3-34 Return Value 3-34 RPC Exception Error Codes 3-34 setpropertiestodefault 3-34 Syntax 3-34 Description 3-34 vii

8 Contents Parameters 3-35 Return Value 3-35 RPC Exception Error Codes 3-35 removecustomproperties 3-35 Syntax 3-35 Description 3-35 Parameters 3-36 Return Value 3-36 RPC Exception Error Codes 3-36 Quota Manager Blocking API Methods 3-37 addsubscriberquota 3-37 Syntax 3-37 Description 3-37 Parameters 3-37 RPC Exception Error Codes 3-38 setsubscriberquota 3-38 Syntax 3-38 Description 3-38 Parameters 3-38 RPC Exception Error Codes 3-39 replenishsubscriberquota 3-39 Syntax 3-39 Description 3-39 Parameters 3-39 RPC Exception Error Codes 3-39 getsubscriberquotainformation 3-40 Syntax 3-40 Description 3-40 Parameters 3-40 Return Value 3-40 RPC Exception Error Codes 3-41 getsubscriberquotaprofileid 3-41 Syntax 3-41 Description 3-42 Parameters 3-42 Return Value 3-42 RPC Exception Error Codes 3-42 getbreachedsubscribernames 3-42 Syntax 3-42 Description 3-42 viii

9 Contents Parameters 3-43 Return Value 3-43 RPC Exception Error Codes 3-43 getpenaltysubscribernames 3-43 Syntax 3-43 Description 3-43 Parameters 3-43 Return Value 3-44 RPC Exception Error Codes 3-44 Blocking API Code Examples 3-45 Getting Number of Subscribers 3-45 Adding a Subscriber, Printing Information, and Removing a Subscriber 3-46 Getting Subscriber Quota Information 3-47 CHAPTER 4 Nonblocking API 4-1 Introduction 4-1 Reliability Support 4-2 Reliable Mode 4-2 Nonreliable Mode 4-2 Autoreconnect Support 4-3 Multithreading Support 4-3 ResultHandler Interface 4-4 ResultHandler Interface Example 4-4 Nonblocking API Construction 4-6 Nonblocking API Syntax 4-6 Nonblocking API Arguments 4-6 Nonblocking API Examples 4-6 Nonblocking API Initialization 4-8 Nonblocking API Initialization Syntax 4-8 Nonblocking API Initialization Parameters 4-8 Nonblocking API Initialization Example 4-8 Nonblocking API Methods 4-9 login 4-9 Syntax 4-9 logoutbyname 4-10 Syntax 4-10 logoutbynamefromdomain 4-10 Syntax 4-10 logoutbymapping 4-10 ix

10 Contents Syntax 4-10 logincable 4-10 Syntax 4-11 logoutcable 4-11 Syntax 4-11 Nonblocking API Code Examples 4-12 Login and Logout 4-12 APPENDIX A List of Error Codes A-1 Introduction A-1 List of Error Codes A-1 x

11 About this Guide Revised: December 21, 2012, Introduction This document describes the Cisco Service Control Subscriber Manager Java API. You use the Cisco Service Control Subscriber Manager Java API to update, query, and configure the Cisco Service Control Subscriber Manager. The API has of two parts, which you can use separately or together without restriction: Cisco Service Control Subscriber Manager Nonblocking Java API High-performance API with low visibility to errors and other operation results. Supports automatic integrations with operations support (OSS) systems and authentication, authorization, and accounting (AAA) systems. Cisco Service Control Subscriber Manager Blocking Java API Supports user-interface applications for accessing and managing the Cisco Service Control Subscriber Manager. Note A set of APIs with the same functionality is also available for the C/C++ environment. This document is for networking or computer technicians who are responsible for configuring the Cisco Service Control Subscriber Manager. It is also intended for operators who manage Cisco Service Control Engine (Cisco SCE) platforms. xi

12 About this Guide Document Revision History The following Document Revision History table records the changes made to this document. Table 1 Document Revision History Cisco Service Control Revision Release and Date Release December 21, 2012 OL Release 3.8.x September 17, 2012 Change Summary Updated for Release Added new mapping type in the Network ID Mappings section on page 6. First version of this document (new for the Release 3.8.x train). xii

13 About this Guide Organization This guide contains the following sections. Table 2 Document Organization Section Title Description Chapter 1 Getting Started Describes the platforms on which you can use the Java API. This chapter also describes how to install, compile, and run the Java API component. Chapter 2 General API Concepts Describes various concepts that pertain to working with the Cisco Service Control Subscriber Manager Java API. Chapter 3 Blocking API Describes the features and operation of the blocking API and provides code examples. Chapter 4 Nonblocking API Describes the features and operation of the nonblocking API and provides code examples. Appendix A List of Error Codes Lists error codes that are used in the Java API. Related Documentation Use this document in conjunction with all the Cisco Service Control Subscriber Manager user, API, and reference guides. xiii

14 About this Guide Conventions This document uses the following conventions. Table 3 Conventions Convention bold font italic font Indication Commands and keywords and user-entered text appear in bold font. Document titles, new or emphasized terms, and arguments for which you supply values are in italic font. [ ] Elements in square brackets are optional. {x y z Required alternative keywords are grouped in braces and separated by vertical bars. [ x y z ] Optional alternative keywords are grouped in brackets and separated by vertical bars. string A nonquoted set of characters. Do not use quotation marks around the string or the string will include the quotation marks. courier font Terminal sessions and information the system displays appear in courier font. < > Nonprinting characters such as passwords are in angle brackets. [ ] Default responses to system prompts are in square brackets.!, # An exclamation point (!) or a pound sign (#) at the beginning of a line of code indicates a comment line. Note Means reader take note. Tip Means the following information will help you solve a problem. Caution Means reader be careful. In this situation, you might perform an action that could result in equipment damage or loss of data. Timesaver Means the described action saves time. You can save time by performing the action described in the paragraph. Warning Means reader be warned. In this situation, you might perform an action that could result in bodily injury. xiv

15 About this Guide Obtaining Documentation and Submitting a Service Request For information on obtaining documentation, submitting a service request, and gathering additional information, see the monthly What s New in Cisco Product Documentation, which also lists all new and revised Cisco technical documentation, at: Subscribe to What s New in Cisco Product Documentation as a Really Simple Syndication (RSS) feed and set content to be delivered directly to your desktop using a reader application. The RSS feeds are a free service and Cisco currently supports RSS version 2.0. xv

16 About this Guide xvi

17 CHAPTER 1 Getting Started Revised: December 21, 2012, Introduction This chapter identifies the platforms on which you can use the Java API. The chapter also describes how to install, compile, and run the API. This chapter consists of the following sections: The Java API, page 1-2 Installing the Java API, page 1-4 Compiling and Running a Program That Uses API, page

18 The Java API Chapter 1 Getting Started The Java API The following sections provide information about the Java API: Introduction, page 1-2 Platforms, page 1-2 Package Content, page 1-2 Introduction The Java API enables you to update, query, and configure the Cisco Service Control Subscriber Manager. The API has two parts, which you can use separately or together without restriction. Cisco Service Control Subscriber Manager Nonblocking Java API High-performance API with low visibility to errors and other operation results. This API supports automatic integrations with OSS/AAA systems. Cisco Service Control Subscriber Manager Blocking Java API Supports user-interface applications that enable you to access and manage the Cisco Service Control Subscriber Manager. Platforms The Cisco Service Control Subscriber Manager Java API was developed and tested on a Windows platform, but it is operable on any platform that supports Java Version 5.0. Package Content For brevity, <installdir> refers to the installation directory, sm-java-api-vvv.bb. The <installdir>/javadoc folder contains the API JAVADOC documentation. The <installdir>lib folder contains the smapi.jar file, which is the API executable. It also contains additional JAR files that are required to operate the API. Table 1-1 provides the layout of the installation directory. Table 1-1 Layout of Installation Directory Path Name Description <installdir> README API readme file <installdir>/javadoc index.html Index of all API specifications (API specification files, and so API specification documents on.) <installdir>/lib smapi.jar Cisco Service Control Subscriber Manager API executable 1-2

19 Chapter 1 Getting Started Package Content Table 1-1 Layout of Installation Directory (continued) Path Name Description asn1rt.jar Utility jar used by the API jdmkrt.jar Utility jar used by the API log4j.jar Utility jar used by the API log4j.properties Property file needed for the API logging functionalities xerces.jar Utility jar used by the API jce-jdk jar Provides an implementation of the Java Cryptography Extension API 1-3

20 Installing the Java API Chapter 1 Getting Started Installing the Java API The Java API is part of the Cisco Service Control Subscriber Manager Login Event Generator (LEG) distribution file and is located in the SM_API directory. The Cisco Service Control Subscriber Manager Java API is packaged in a UNIX tar file. The API is compiled with log4j 1.2. You can extract the Java API by using the UNIX tar utility or most Windows compression utilities: Cisco Service Control Subscriber Manager Setup, page 1-4 Installing on a UNIX Platform, page 1-4 Installing on a Windows Platform, page 1-4 Cisco Service Control Subscriber Manager Setup The API connects to the Proprietary Remote Procedure Call (PRPC) server on the Cisco Service Control Subscriber Manager. To enable the API to operate, the following conditions must be met: The Cisco Service Control Subscriber Manager must be operating, and reachable from the machine that hosts the API. The PRPC server must be started. The PRPC server is a proprietary RPC protocol designed by Cisco. For more information about the PRPC server, see the Cisco Service Control Management Suite Subscriber Manager User Guide. Installing on a UNIX Platform Note The abbreviations vvv and bb represent the Cisco Service Control Subscriber Manager Java API version and build number. To install Cisco Service Control Subscriber Manager Java API: Step 1 Step 2 Step 3 Step 4 Extract the Cisco Service Control Subscriber Manager LEG distribution file. Locate the Cisco Service Control Subscriber Manager Java API distribution tar, sm-java-api-dist.tar. Extract the Cisco Service Control Subscriber Manager Java API distribution tar and obtain sm-java-api-vvv.bb.tar. #>tar -xvf sm-java-api-dist.tar Extract the Cisco Service Control Subscriber Manager Java API package tar. #>tar -xvf sm-java-api-vvv.bb.tar Installing on a Windows Platform Use a zip extractor (such as WinZip). 1-4

21 Chapter 1 Getting Started Compiling and Running a Program That Uses API Compiling and Running a Program That Uses API To compile and run a program that uses the Cisco Service Control Subscriber Manager Java API, smapi.jar must be in the CLASSPATH. For example, if the program source is in SMApiProgram.java, use the following command to compile the program: #>javac -classpath smapi.jar SMApiProgram.java After compiling the program, use the following command to run the program: #>java -cp.;<installdir>/lib/smapi.jar SMApiProgram 1-5

22 Compiling and Running a Program That Uses API Chapter 1 Getting Started 1-6

23 CHAPTER 2 General API Concepts Revised: December 21, 2012, Introduction This chapter describes the concepts that pertain to working with the Cisco Service Control Subscriber Manager Java API. This chapter consists of the following sections: Blocking API and the Nonblocking API, page 2-2 API Initialization, page 2-3 API Finalization, page 2-5 Subscriber Name Format, page 2-5 Network ID Mappings, page 2-6 Subscriber Domains, page 2-9 Subscriber Properties, page 2-9 Custom Properties, page 2-10 DisconnectListener Interface, page 2-10 Exceptions, page 2-11 Practical Tips, page

24 Blocking API and the Nonblocking API Chapter 2 General API Concepts Blocking API and the Nonblocking API This section describes the differences between the Blocking API and the Nonblocking API. Blocking API, page 2-2 Nonblocking API, page 2-2 Blocking API In a Blocking API operation, which is the most common, every method returns after its operation is performed. The Cisco Service Control Subscriber Manager Blocking Java API provides a wide range of operations. It contains most of the functionality of the Nonblocking API and many functions that the Nonblocking API does not provide. The Blocking API does not support reliability and autoreconnect functionality. Nonblocking API In a Nonblocking Java API operation, every method returns immediately, even before the completion of its operation. The operation results are either returned to an observer object (listener) or not returned at all. The Nonblocking API method is preferred when the operation is lengthy and involves I/O. When the operation is performed in a separate thread, the calling program can continue performing other tasks, which improves the overall system performance. The Cisco Service Control Subscriber Manager Nonblocking Java API contains a small number of nonblocking operations. The API supports the retrieval of operation results by using a result listener. The Cisco Service Control Subscriber Manager Nonblocking Java API supports two modes reliable and nonreliable. For more information about the reliability modes, see the Reliability Support section on page

25 Chapter 2 General API Concepts API Initialization API Initialization To initialize the API, you must complete three tasks: Construct the API by using one of its constructors. For details, see the API Construction section on page 2-3. Perform the API-specific setup operations. For details, see the Setup Operations section on page 2-3. Connect the API to the Cisco Service Control Subscriber Manager. For details, see the Connecting to the Cisco Service Control Subscriber Manager section on page 2-4. API Construction Blocking and Nonblocking APIs have two constructors: An Empty constructor A Constructor that accepts a Login Event Generator (LEG) name as a parameter. Constructor that Accepts a LEG Name Blocking API Example Set the LEG name if you intend to turn on the Cisco Service Control Subscriber Manager LEG failure processing options in the Cisco Service Control Subscriber Manager. For more information about the LEG software components and SM-LEG failure handling, see the Cisco Service Control Management Suite Subscriber Manager User Guide. The Cisco Service Control Subscriber Manager uses the LEG name when recovering from a connection failure. A constant string that identifies the API is appended to the LEG name as follows: For blocking API.B.SM-API.J For nonblocking API.NB.SM-API.J If the provided LEG name is my-leg version-1.0, the actual LEG name is my-leg version-1.0.b.sm-api.j. If no name is set, the LEG uses the hostname of the machine as the prefix of the name. Additional constructors are available for the Nonblocking API. For more information, see the Nonblocking API Construction section on page 4-6. Setup Operations The setup operations differ for the two APIs. Both APIs support setting a disconnect listener, which is described in detail in the DisconnectListener Interface section on page Blocking API Setup, page 2-4 Nonblocking API Setup, page

26 Connecting to the Cisco Service Control Subscriber Manager Chapter 2 General API Concepts Blocking API Setup To set up the Blocking API, you must set an operation timeout value. For more information, see Chapter 3, Blocking API. Nonblocking API Setup To set up the Nonblocking API, you must set a disconnect listener. For more details, see Chapter 4, Nonblocking API. Connecting to the Cisco Service Control Subscriber Manager To connect to the Cisco Service Control Subscriber Manager, use one of the following connect methods. Use the following method to connect to the Cisco Service Control Subscriber Manager by using the default remote procedure call (RPC) TCP port (14374): connect(string host) Use the following method to allow the caller to set the TCP port to which the API connects: connect(string host, int port) For both methods, the host parameter can be either an IP address or a reachable hostname. At any time during the API operation, you can check if the API is connected by using the isconnected method. 2-4

27 Chapter 2 General API Concepts API Finalization API Finalization To free the resources of both the server and the client, use the disconnect method. Use a finally statement in your main class, as follows: public static void main(string [] args) throws Exception { SMNonBlockingApi smnbapi = new SMNonBlockingApi(); try {... finally { smnbapi.disconnect(); Subscriber Name Format Most methods of both APIs require the subscriber name as an input parameter. A subscriber name can contain up to 64 characters. You can use all printable characters with an ASCII code between 32 and 126 (inclusive), except for 34 ("), 39 ('), and 96 (`). 2-5

28 Network ID Mappings Chapter 2 General API Concepts Network ID Mappings A network ID mapping is a network identifier that the Service Control Engine (SCE) device can map to a specific subscriber record. A typical example of a network ID mapping (or simply, mapping) is an IP address. Currently, the Cisco Service Control solution supports IP address, IP range, private IP address over VPN, private IP range over VPN, and VLAN mappings. Both Blocking and Nonblocking APIs contain operations that accept mappings as a parameter, such as the following: The addsubscriber operation (Blocking API) The login method (Blocking or Nonblocking API) When passing mappings to an API method, the caller is requested to provide two parameters: The java.lang.string mapping identifier or array of mapping types The short mapping type or array of mapping types When passing arrays, the mappingtypes array must contain either the same number of elements as the mappings array or a single element. If the mappingtypes array contains a single element, all the mappings have the same type, specified by this single element. Note Only one mapping type is allowed in a call to any of the APIs. APIs supports the following subscriber mapping types: IP addresses or IP ranges (From Cisco Service Control Subscriber Manager, Release 3.8.5) IPv6 address Private IP addresses or private IP ranges over VPN VLAN tags (From Cisco Service Control Subscriber Manager, Release 3.8.5) IPv6 addresses or IPv6 prefix For additional information, see the Cisco Service Control Management Suite Subscriber Manager User Guide. Specifying IP Address Mapping The string format of an IP address is the commonly used decimal notation: IP-Address=[0-255].[0-255].[0-255].[0-255] Example: The mapping type of an IP address is provided in the com.pcube.management.api.smapiconstants interface: com.pcube.management.api.smapiconstants.mapping_type_ip specifies a single IP mapping that matches the mapping identifier with the same index in the mapping identifier array. com.pcube.management.api.smapiconstants.all_ip_mappings specifies that all the entries in the mapping identifier array are IP mappings. 2-6

29 Chapter 2 General API Concepts Specifying IPv6 Address Mapping Specifying IPv6 Address Mapping The string format of an IP address is the commonly used hexadecimal colon-separated notation: IPV6-Address=[0000-FFFF]:[0000-FFFF]:[0000-FFFF]:[0000-FFFF]:[0000-FFFF]:[0000-FFFF]:[0000 -FFFF]:[0000-FFFF]/[32-64] Note The prefix value of all IPv6 addresses should be between 32 and 64. Only the first 64-bit of the IPv6 address is considered. The mapping type of an IP address is provided in the com.pcube.management.api.smapiconstants interface: com.pcube.management.api.smapiconstants.mapping_type_ipv6 specifies a single IP mapping that matches the mapping identifier with the same index in the mapping identifier array. com.pcube.management.api.smapiconstants.all_ipv6_mappings specifies that all entries in the mapping identifier array are IPv6 mappings. Example: 2001:db8:85a3::8a2e:370:7334/64 Specifying IP Range Mapping The string format of an IP range is an IPv4 address in decimal notation and a decimal specifying the number of 1s in a bit mask: IP-Range=[0-255].[0-255].[0-255].[0-255]/[0-32] Examples: /32 is an IP range with a complete mask, that is, a regular IP address /24 is an IP range with a 24-bit mask, that is, all the addresses ranging between and Note The mapping type of an IP range is identical to the mapping type of the IP address. Specifying Private IP Address or Private IP Range over VPN Mapping The string format of an IPv4 address and an IP range are described in the Specifying IP Address Mapping section on page 2-6 and in the Specifying IP Range Mapping section on page 2-7. When the network ID mapping uses an IP address or range over VPN, the string format includes the VPN name. Examples: is an IP address over the VPN named VPN1. is an IP range with a 24-bit mask, that is, all of the addresses in the range from to over the VPN named VPN2. 2-7

30 Specifying VLAN Tag Mapping Chapter 2 General API Concepts Note The mapping type of an IP address or IP range over VPN is identical to the mapping type of the IP address. Specifying VLAN Tag Mapping The string format for VLAN tag mapping is VLAN-tag = 0 to The value is a decimal in the specified range. The com.pcube.management.api.smapiconstants interface also provides the mapping type: com.pcube.management.api.smapiconstants.mapping_type_vpn specifies a single VLAN mapping that matches the mapping identifier with the same index in the mapping identifier array. com.pcube.management.api.smapiconstants.all_vpn_mappings specifies that all the entries in the mapping identifiers array are VLAN mappings. Note The SMApiConstants.TYPE_VLAN and SMApiConstants.ALL_VLAN_MAPPINGS constants are deprecated. You should use the SMApiConstants.TYPE_VPN and SMApiConstants.ALL_VPN_MAPPINGS constants instead. 2-8

31 Chapter 2 General API Concepts Subscriber Domains Subscriber Domains The Cisco Service Control Management Suite Subscriber Manager User Guide defines the domain concept. Briefly, a domain identifies for the Cisco Service Control Subscriber Manager the Cisco SCE devices to which it updates subscriber records. A domain name is a type of String. During system installation, the network administrator determines the system domain names, which, therefore, vary between installations. The APIs include methods that specify the domain to which a subscriber belongs. The APIs also provide methods that enable queries about system domain names. If an API operation specifies a domain name that does not exist in the Cisco Service Control Subscriber Manager domain repository, it is considered an error and RpcErrorException is returned. The Cisco Service Control Subscriber Manager automatic domain roaming feature enables you to move subscribers between domains by calling the login method for a subscriber with an updated domain parameter as described in the login section on page 3-5. Note Automatic domain roaming is not backward compatible with previous versions of the Cisco Service Control Subscriber Manager API. Previous versions did not permit changing the domain of the subscriber. Subscriber Properties Several operations manipulate subscriber properties. A subscriber property is a key/value pair that affects the way the Cisco SCE analyzes and reacts to network traffic generated by the subscriber. For information about properties, see the Cisco Service Control Management Suite Subscriber Manager User Guide and the Cisco Service Control Application for Broadband User Guide. The latter provides application-specific information; it lists the subscriber properties that exist in the application running on your system, the allowed value set, and the significance of each property value. To format subscriber properties for Java API operations, use the String arrays propertykeys and propertyvalues. Note The arrays must be of the same length, and NULL entries are forbidden. Each key in the keys array has a matching entry in the values array; the value for propertykeys[j] resides in propertyvalues[j]. The mapping type of an IP range is identical to the mapping type of the IP address. Example: If the property keys array is {"packageid","monitor" and the property values array is {"5","1", the properties are packageid=5, monitor=1. 2-9

32 Custom Properties Chapter 2 General API Concepts Custom Properties Some operations manipulate custom properties. Custom properties are similar to subscriber properties, but do not affect how the SCE analyzes and manipulates the subscriber traffic. The application management modules use custom properties to store additional information for each subscriber. To format custom properties, use the String arrays custompropertykeys and custompropertyvalues. This formatting is the same as in the subscriber properties formatting described in the Subscriber Properties section on page 2-9. DisconnectListener Interface Both APIs (Blocking and Nonblocking) enable you to set a disconnect listener. The disconnect listener is an interface with a single method: public interface DisconnectListener { /** * called when the connection with the server is down. */ public void connectionisdown(); Implement this interface to be notified when the API is disconnected from the Cisco Service Control Subscriber Manager. To set a disconnect listener, use the setdisconnectlistener method. DisconnectListener Interface Example The following example is a basic implementation of a disconnect listener that prints a message to stdout and exits: import com.pcube.management.framework.rpc.disconnectlistener; public class MyDisconnectListener implements DisconnectListener { public void connectionisdown(){ System.out.println("Message: connection is down."); System.exit(0); 2-10

33 Chapter 2 General API Concepts Exceptions Exceptions The same Java class, com.pcube.management.framework.rpc.rpcerrorexception, provides all of the functional errors of the Cisco Service Control Subscriber Manager Java API. This is contrary to the normal Java usage. This approach was chosen because of the cross-language nature of the Cisco Service Control Subscriber Manager API. It enables all Cisco Service Control Subscriber Manager API implementations (Java, C, and C++) to appear similar. Each exception provides the following information: Unique error code (long) Informative message (java.lang.string) Server-side stack trace (java.lang.string) The error code can be interpreted by using com.pcube.management.api.smapiconstants. See Appendix A, List of Error Codes for details about error codes and their significance. Note Several types of errors can occur only if you use the Blocking API. These are operational errors that are related to operation-timeout handling. These errors are described in Chapter 3, Blocking API. Practical Tips When implementing the code that integrates the API with your application, consider the following practical tips: Connect to the Cisco Service Control Subscriber Manager once and maintain an open API connection to the Cisco Service Control Subscriber Manager at all times, using the API many times. Establishing a connection is a timely procedure, which allocates resources on the Cisco Service Control Subscriber Manager side and the API client side. Share the API connection between your threads. It is best to have one connection per LEG. Multiple connections require more resources on the Cisco Service Control Subscriber Manager side and client side. Do not implement synchronization of the calls to the API. The client automatically synchronizes calls to the API. Place the API clients (LEGs) in the same order as the Cisco Service Control Subscriber Manager machine processor number. If the LEG application has bursts of login operations, enlarge the internal buffer size accordingly to hold these bursts (Nonblocking API). During the integration, set the Cisco Service Control Subscriber Manager logon_logging_enabled configuration parameter to enable viewing the API operations in the Cisco Service Control Subscriber Manager log. Setting this parameter enables you to troubleshoot the integration, if any problems arise. Use the debug mode for the LEG application that logs the return values of the nonblocking operations. Use the automatic reconnect feature to improve the resiliency of the connection to the Cisco Service Control Subscriber Manager. In cluster setups, connect the API by using the virtual IP address of the cluster and not the management IP address of one of the machines. 2-11

34 Practical Tips Chapter 2 General API Concepts 2-12

35 CHAPTER 3 Blocking API Revised: December 21, 2012, Introduction This chapter introduces the Reply Timeout, a feature unique to the Blocking API. The chapter also lists all the operations of the Blocking API, and provides code examples. Note If you need to develop only an automatic integration, skip this chapter and go directly to Chapter 4, Nonblocking API. This chapter consists of the following sections: Multithreading Support, page 3-2 ReplyTimeout and OperationTimeout Exception, page 3-3 Cisco Service Control Subscriber Manager Blocking API Methods, page 3-4 Quota Manager Blocking API Methods, page 3-37 Blocking API Code Examples, page

36 Multithreading Support Chapter 3 Blocking API Multithreading Support The Blocking API supports an unlimited number of threads calling its methods simultaneously. Note In a multithreaded scenario for the Blocking API, the order of invocation is not guaranteed. Example: Thread-0 calls operation-0 at time-0, and thread-1 calls operation-1 at time-1, where time-1 is later than time-0. In this example, it is possible that operation-1 might be performed before operation-0, as shown in Figure 3-1 (the vertical scale is time): Figure 3-1 Multithreading Support Thread 0 : Thread 1 : SM Blocking API : op-0 : operation op-1 : operation op-1 : result op-0 : result The Cisco Service Control Subscriber Manager allocates five threads to manage each API instance. Develop a multithreaded application that uses the API with several threads in the order of the five threads. Implementing with more threads might result in longer delays for the calling threads. 3-2

37 Chapter 3 Blocking API ReplyTimeout and OperationTimeout Exception ReplyTimeout and OperationTimeout Exception A blocking operation returns only when the operation result is retrieved from the Cisco Service Control Subscriber Manager. If a networking malfunction or other error prevents the operation result from being retrieved, the caller waits indefinitely. The Cisco Service Control Subscriber Manager API provides a means of working around this situation. The reply timeout feature (the setreplytimeout method) enables the caller to set a timeout. It will generate com.pcube.management.framework.rpc.operationtimeoutexception when a reply does not return within the timeout period. Calling the setreplytimeout method with a long value sets a reply timeout. The reply timeout is interpreted in milliseconds. A zero value indicates that the operation should wait (freeze, stop responding) until a result arrives or indefinitely, if no result arrives. There is an alternative way to release a method call that is blocking the caller, who is waiting for a result to arrive. Call the interrupt method of the calling thread; java.lang.interruptedexception will then be returned to the caller. 3-3

38 Cisco Service Control Subscriber Manager Blocking API Methods Chapter 3 Blocking API Cisco Service Control Subscriber Manager Blocking API Methods This section lists the methods of the Cisco Service Control Subscriber Manager Blocking API. The description of each method includes its syntax, input parameters, and return values. The Blocking API is a superset of the Nonblocking API. Except for differences in return values and result handling, identical operations in both APIs have the same functions and syntax structure. All the methods generate java.lang.illegalstateexception when called before the API establishes a connection with the Cisco Service Control Subscriber Manager. The Blocking API methods are classified as follows: Dynamic IP and property allocation Use the following methods to integrate the Cisco Service Control Subscriber Manager API with an authentication, authorization, and accounting (AAA) system. These methods are not designed to add or remove subscribers from the database. Instead, they modify dynamic parameters (such as IP addresses) of the existing subscribers: login, page 3-5 logoutbyname, page 3-8 logoutbynamefromdomain, page 3-10 logoutbymapping, page 3-11 logincable, page 3-13 logoutcable, page 3-16 Static or Manual Subscriber configuration Use the following methods for a GUI: addsubscriber, page 3-17 removesubscriber, page 3-19 removeallsubscribers, page 3-20 setpropertiestodefault, page 3-34 removecustomproperties, page 3-35 Use the following methods for simple read-only operations, performed independently in the subscriber awareness mode: getnumberofsubscribers, page 3-21 getnumberofsubscribersindomain, page 3-21 getsubscriber, page 3-22 subscriberexists, page 3-25 subscriberloggedin, page 3-25 getsubscribernamebymapping, page 3-26 getsubscribernames (all), page 3-28 getsubscribernames (filter by property), page 3-29 getsubscribernamesindomain, page 3-30 getsubscribernameswithprefix, page 3-31 getsubscribernameswithsuffix, page 3-32 getdomains, page

39 Chapter 3 Blocking API login You can mix methods from different categories in a single application. The classification is presented only for clarity. login The following sections provide information about the login operation: Syntax, page 3-5 Description, page 3-5 Parameters, page 3-5 RPC Exception Error Codes, page 3-6 Return Value, page 3-6 Examples, page 3-6 Syntax The login syntax is as follows: public void login(string subscribername, String[] mappings, short[] mappingtypes, String[] propertykeys, String[] propertyvalues, String domain, boolean ismappingadditive, int autologouttime) throws InterruptedException, OperationTimeoutException, RpcErrorException Description The login method adds or modifies a domain, mappings, and possibly properties of a subscriber that already exists in the Cisco Service Control Subscriber Manager database. The login method can be called with partial data; for example, it might provide mappings or properties only, and put NULL ++++ in the unchanged fields. If another subscriber with the same (or conflicting) mappings already exists in the same domain, the conflicting mappings are removed from the other subscriber and assigned to the new subscriber. If the subscriber does not exist in the Cisco Service Control Subscriber Manager database, the login method creates it with the data provided. Parameters The parameters of the login method are as follows: subscribername See the description of subscriber name formatting in the Subscriber Name Format section on page 2-5. mappings See the description of mappings and mapping types in the Network ID Mappings section on page 2-6. If no mappings are specified, and the ismappingadditive parameter is TRUE, the previous mappings are retained. If no such mappings exist, the operation fails. mappingtypes See the description of mappings and mapping types in the Network ID Mappings section on page

40 login Chapter 3 Blocking API RPC Exception Error Codes Return Value propertykeys See the description of property keys in the Subscriber Properties section on page 2-9. propertyvalues See the description of property values in the Subscriber Properties section on page 2-9. domain See the description of subscriber domains in the Subscriber Domains section on page 2-9. If domain is NULL, but the subscriber already has a domain, the existing domain is retained. If the domain is different from the domain that was previously assigned to the subscriber, the subscriber is removed automatically from the Cisco SCEs of the previous domain and moved to the SCEs of the new domain. ismappingadditive TRUE Adds the mappings provided by this call to the subscriber record. FALSE Overrides the mappings provided by this call with mappings that already exist in the subscriber record. autologouttime Applies only to the mappings provided as arguments to this method. Positive value (N) Automatically logs out the mappings (similar to calling a logout method) after N seconds. 0 value Maintains the current expiration time for the given mappings. Negative value Disables any expiration time set for the given mappings. The following list presents the error codes the login method might return: ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME ERROR_CODE_BAD_SUBSCRIBER_MAPPING ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION ERROR_CODE_DATABASE_EXCEPTION ERROR_CODE_UNKNOWN This error can be caused by the following parameter settings: NULL value for the domain parameter for the subscriber that does not exist or does not have a domain Invalid values for the propertyvalues parameter For a description of error codes, see Appendix A, List of Error Codes. None. Examples To add the IP address to an existing subscriber named alpha without affecting existing mappings: login( 3-6

41 Chapter 3 Blocking API login "alpha", // subscriber name new String[]{" ", SMApiConstants.ALL_IP_MAPPINGS, null, null, "subscribers", // domain true, // ismappingadditive is true -1); // autologouttime set to infinite To add the IP address overriding previous mappings: login( "alpha", // subscriber name new String[]{" ", SMApiConstants.ALL_IP_MAPPINGS, null, null, "subscribers", // domain false, // ismappingadditive is false -1); // autologouttime set to infinite To extend the auto logout time of , which was previously assigned to alpha: login( "alpha", //the previously assigned IP new String[]{" ", SMApiConstants.ALL_IP_MAPPINGS, null, null, "subscribers", // domain false, // ismappingadditive 300); // autologouttime set to 300 seconds To modify a dynamic property of alpha (for example, package ID): login( "alpha", null, null, new String[]{"packageId", // property key new String[]{"10", // property value "subscribers", // domain false, -1); To add the IP address to an existing subscriber named alpha without affecting existing mappings and to modify a dynamic property of alpha (for example, package ID): login( "alpha", new String[]{" ", SMApiConstants.ALL_IP_MAPPINGS, new String[]{"packageId", // property key new String[]{"10", // property value "subscribers", // domain true, // ismappingadditive is set to true -1); To add the IPv6 address 2000:2001:2002:abcd::/64 to an existing subscriber named alpha without affecting existing mappings: login( "alpha", // subscriber name new String[]{"2000:2001:2002:abcd::/64", SMApiConstants.ALL_IPV6_MAPPINGS, null, null, "subscribers", // domain true, // ismappingadditive is true -1); // autologouttime set to infinite 3-7

42 logoutbyname Chapter 3 Blocking API To add the IPv6 address 2000:2001:2002:abcd::/64 overriding previous mappings: login( "alpha", // subscriber name new String[]{"2000:2001:2002:abcd::/64", SMApiConstants.ALL_IPV6_MAPPINGS, null, null, "subscribers", // domain false, // ismappingadditive is false -1); // autologouttime set to infinite To extend the auto logout time of 2000:2001:2002:abcd::/64 that was previously assigned to alpha: login( "alpha", //the previously assigned IP new String[]{"2000:2001:2002:abcd::/64", SMApiConstants.ALL_IPV6_MAPPINGS, null, null, "subscribers", // domain false, // ismappingadditive 300); // autologouttime set to 300 seconds To add the IPv6 address 2000:2001:2002:abcd::/64 to an existing subscriber named alpha without affecting the existing mappings, and to modify a dynamic property of alpha,for example, package ID: login( "alpha", new String[]{"2000:2001:2002:abcd::/64", SMApiConstants.ALL_IPV6_MAPPINGS, new String[]{"packageId", // property key new String[]{"10", // property value "subscribers", // domain true, // ismappingadditive is set to true -1); logoutbyname Syntax The following sections provide information about the logoutbyname operation: Syntax, page 3-8 Description, page 3-9 Parameters, page 3-9 Return Value, page 3-9 RPC Exception Error Codes, page 3-9 Examples, page 3-9 The logoutbyname syntax is as follows: public boolean logoutbyname(string subscribername, String[] mappings, short[] mappingtypes) throws InterruptedException, OperationTimeoutException, RpcErrorException 3-8

43 Chapter 3 Blocking API logoutbyname Description The logoutbyname method locates the subscriber in the database and removes mappings from it. If the subscriber does not exist, the logoutbyname operation does not do anything. Parameters The parameters of the logoutbyname method are as follows: subscribername See the description of subscriber name formatting in the Subscriber Name Format section on page 2-5. mappings See the description of mappings in the Network ID Mappings section on page 2-6. If no mappings are specified, all subscriber mappings are removed. mappingtypes See the description of mapping types in the Network ID Mappings section on page 2-6. Return Value RPC Exception Error Codes Examples TRUE If the subscriber was found and the subscriber mappings were removed from the subscriber database FALSE If the subscriber was not found in the subscriber database The following list presents the error codes the logoutbyname method might return: ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST ERROR_CODE _BAD_SUBSCRIBER_MAPPING ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION ERROR_CODE_DOMAIN_NOT_FOUND ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN ERROR_CODE_DATABASE_EXCEPTION For a description of error codes, see Appendix A, List of Error Codes. To remove IP address of subscriber alpha: boolean isexist = logoutbyname( "alpha", new String[]{" ", SMApiConstants.ALL_IP_MAPPINGS); To remove all IP addresses of subscriber alpha: boolean isexist = logoutbyname("alpha", null, null); 3-9

44 logoutbynamefromdomain Chapter 3 Blocking API logoutbynamefromdomain Syntax The following sections provide information about the logoutbynamefromdomain operation: Syntax, page 3-10 Description, page 3-10 Parameters, page 3-10 Return Value, page 3-10 RPC Exception Error Codes, page 3-11 Example, page 3-11 The logoutbynamefromdomain syntax is as follows: public boolean logoutbynamefromdomain(string subscribername, String[] mappings, short[] mappingtypes, String domain) throws InterruptedException, OperationTimeoutException, RpcErrorException Description The logoutbynamefromdomain similar to logoutbyname, but this method also enables the caller to provide the name of the domain to which the subscriber belongs. When the subscriber domain is known, use this method to improve performance. Parameters Return Value The parameters of the logoutbynamefromdomain method are as follows: subscribername See the description of subscriber name formatting in the Subscriber Name Format section on page 2-5. mappings See the description of mappings in the Network ID Mappings section on page 2-6. If no mappings are specified, all subscriber mappings are removed. mappingtypes See the description of mapping types in the Network ID Mappings section on page 2-6. domain See the description of subscriber domains in the Subscriber Domains section on page 2-9. The operation fails if either of the following conditions exists: Domain is null, but the subscriber exists in the database and belongs to a domain. Domain specified is incorrect. TRUE If the subscriber was found and removed from the subscriber database FALSE If the subscriber was not found in the subscriber database 3-10