cc/td/doc/product/rtrmgmt/csrc/101/ur
hometocprevnextglossaryfeedbacksearchhelp

Table of Contents

Creating Page Extensions

Creating Page Extensions

Page extensions are custom-developed Java classes that are called from the User Registrar Subscriber code. They provide a mechanism for enhancing the subscriber's experience, as well as better supporting CSRC integration with existing systems, such as e-mail servers. Each page extension has a corresponding Java interface that must be implemented in a Java class.

Because you enable page extensions on a per-locale basis, you can use different Java classes for each locale in a given CSRC installation.

This chapter describes the different Java classes and provides a step-by-step example of creating a page extension.

Understanding Page Extensions

Page extensions use defined Java interfaces to control the affect of the subscriber's self-provisioning experience. These interfaces allow you to determine the appropriate locale to present to the subscriber, and help the user choose a user name or host name. You can also use these interfaces to allow the user to skip some of the User Registrar Subscriber pages.

Locale Lookup

When a new subscriber connects to User Registrar Subscriber, the locale for the subscriber is undetermined. If you have not enabled any other logic, User Registrar uses the global default locale.

Enabling the Locale Lookup page extension allows User Registrar to determine a locale from the modem's and computer's current IP addresses. For example, if you had two locales, a university and a residential neighborhood, you could have User Registrar differentiated between the modems in a university on one subnet and the residential modems on another subnet.

The Locale Lookup page extension code takes effect before any other page is executed including the select_locale page. While the select_locale page allows the user to select a locale, the select_locale template still needs to be accessed from one of the locales making the locale lookup critical to proper behavior. For more information about the select_locale page, see the "Subscriber Selection of a Locale" section.

ILocaleLookup Java Interface

Example 5-1 shows the ILocaleLookup interface.


Example 5-1: ILocaleLookup
ILocaleLookup Java Interface
 
public interface com.cisco.csrc.ursub.ILocaleLookup
{
  public String getLocale(String computerIP, String modemIP);
}
 

The getLocale() method returns null if you are using the global default locale. If the page extension can determine an appropriate locale given the computer and modem IP addresses, the method returns a string containing the name of the locale.

For example, if the getLocale() method determines that the English language should be used, the string returned would be en. If this method returns an illegal or unknown locale name, the behavior is the same as if it had returned null.

ILocaleLookup Example Class

Example 5-2 shows a sample ILocaleLookup class.


Example 5-2: Sample LocaleLookup
public class SampleLocaleLookup
  implements com.cisco.csrc.ursub.ILocaleLookup
{
  public String getLocale(String computerIP, String modemIP)
  {
    // check if this is the university subnet.
    if (modemIP.startsWith("123.123."))
      return "University";
 
    // if no particular locale is found, use the default.
    return null;
  }
}
 

This example class determines if the subscriber is accessing User Registrar Subscriber from a university subnet. If it is, User Registrar uses the University locale, otherwise the class instructs User Registrar to display the default locale.

Tips While the class could return en (or whatever the configured default is) by returning null, the code leaves the default behavior controlled in User Registrar Administrator and thereby does not require a code change if the locale default is changed.

Locale Choices

When a subscriber first accesses User Registrar Subscriber, the first page displayed is select_locale if multiple locales and the Use Select Locale options are enabled.The Locale Choices page extension allows you to display a subset of available locales. For example, residential customers should only be given the choice between Residential_English and Residential_Spanish even though University is also a valid locale.The Locale Choices page extension allows you to limit the choices for the residential subscribers to the two desired locales.

ILocaleChoices Java Interface

Example 5-3 shows the ILocaleChoices interface.


Example 5-3: ILocaleChoices
ILocaleChoices Java Interface
 
public interface com.cisco.csrc.ursub.ILocaleChoices
{
  public String[] getLocaleChoices(String computerIP, String modemIP);
}
 

This class returns null if all the locales should be displayed to the subscriber, otherwise it returns a string array containing a list of locale names to be presented. User Registrar ignores the names on the list that are not in the system's locale list.

ILocaleChoices Example Class

Example 5-4 shows a sample ILocaleChoices class. It limits the available locales to Residential_English and Residential_Spanish. The assumption is that the LocaleLookup page extension has already defined that this is a residential subscriber.


Example 5-4: Sample ILocaleChoices
public class ResidentialLocaleChoices 
    implements com.cisco.csrc.ursub.ILocaleChoices
{
  public String[] getLocale(String computerIP, String modemIP)
  {
    return new String[] 
      { "Residential_English", "Residential_Spanish" };
  }
}

Username Lookup

When a subscriber begins the self-registration process, User Registrar displays the choose_username page. This page prompts the subscriber for a username and password. You can use the Username Lookup page extension to offer a suggestion for a username and password. For example, subscribers' username and password may correspond to their account number and PIN.


Note If you have enabled the
Skip username selection option, you must use this page extension because it is the only way to provide a username and password for a subscriber.
Tips Enabling a Username Lookup page extension that defaults the username and password to the respective values and then enabling Skip username selection, causes User Registrar to skip the choose_username page and thus, subscribers need know only their account number and PIN for initial registration and account maintenance.

IUsernameLookup Java Interface

Example 5-5 shows the IUsernameLookup interface.


Example 5-5: IUsernameLookup
public interface com.cisco.csrc.ursub.IUsernameLookup
{
  public String[] getUsername(
      ICWAFObject accountobj, ICWAFObject subscriberobj,
      ICWAFObject modemobj, ICWAFObject computerobj);             
}
 

The getUsername() method returns null if no username and password selections are available. If the page extension can find an appropriate suggestion, this method returns a two-element string array containing the username in the first element and the password in the second.

IUsernameLookup Example Class

Example 5-6 shows a sample IUsernameLookup class.


Example 5-6: Sample UsernameLookup
public class SampleUsernameLookup 
  implements com.cisco.csrc.ursub.IUsernameLookup
{
  public String[] getUsername(
      ICWAFObject accountobj, ICWAFObject subscriberobj,
      ICWAFObject modemobj, ICWAFObject computerobj)
  {
    // build a string array for the results.
    String values[] = new String[2];
 
    // populate the account number and PIN in the array.
    values[0] = accountobj.getAttr("AccountNumber");
    values[1] = accountobj.getAttr("PIN");
 
    // return the values.
    return values;
  }
}
 

This sample class returns the account number and PIN of the subscriber as suggestions for the username and password. If User Registrar cannot find an appropriate suggestion, the code returns null.

You can call the getAttr() method on any of the input objects and it can access any of the attributes listed in the application schema. For multivalued attributes, use getAttrList() which returns a string array of values. Both getAttr() and getAttrList() return null if the object does not have the desired value set. Calling getAttr() or getAttrList() on an invalid attribute causes a Java exception to be thrown. If you are unfamiliar with exception catching, review a standard Java reference manual.

Username Checking

When the subscriber clicks Accept on the choose_username page, you can have the Username Check page extension perform additional validation and uniqueness checking on the supplied values.

For example, you could use the Username Check page extension to verify username uniqueness in an external e-mail server or you could use this page extension to provide a textual message containing a list of suggestions for alternative usernames.


Note If you have enabled the Skip username selection option, User Registrar does not call the Username Check page extension.

IUsernameCheck Java Interface

Example 5-7 shows the IUsernameCheck interface.


Example 5-7: IUsernameCheck Interface
public interface com.cisco.csrc.ursub.IUsernameCheck
{
  public String isValidUsername(String username);
}
 

The isValidUsername() method returns null if the username is valid. If the username is unacceptable, the method displays to the subscriber explaining why the username is not available. For instance, the method could check for profanity in usernames and then when detected, return a message stating that the username is inappropriate.

IUsernameCheck Example Class

Example 5-8 shows a sample IUserCheck class.


Example 5-8: Sample IUserCheck
public class SampleIUsernameCheck 
  implements com.cisco.csrc.ursub.IUsernameCheck
{
  public String isValidUsername(String username)
  {
    // check if the username is valid.
    if (username.equalsIgnoreCase("root") ||
        username.equalsIgnoreCase("webmaster"))
      return "You may not select '"+username+"' as a username.";
 
    // if the username passed all the checks, return null.
    return null;
  }
}
 

This sample class checks for certain special usernames and ensures that they are not selected. If a reserved name is selected, the code returns an error message explaining that the selected username is not available. When the username passes all of the checks, the code returns null to allow the subscriber to select the desired username.

Hostname Lookup

The activate_device page prompts subscribers for a hostname and description for their computer. You can use the Hostname Lookup page extension to offer a suggestion for a username and password. In addition, if you have enabled the Skip hostname selection, you must use the Hostname Lookup page extension because it is the only way to provide a hostname and description for a subscriber's computer.

For example, you could use the Hostname Lookup page extension to automatically generate a hostname from the computer's MAC address.

Tips By enabling a page extension that defaults the hostname and password to their respective values and then enabling Skip hostname selection, you could have subscribers skip the entire activate_device section and the subscriber would not need to understand what choosing a computer name means.

IHostnameLookup Java Interface

Example 5-9 show the IHostname Lookup interface.


Example 5-9: IHostname Lookup
public interface com.cisco.csrc.ursub.IHostnameLookup
{
  public STring[] getHostname(
      ICWAFObject accountobj, ICWAFObject subscriberobj,
      ICWAFObject modemobj, ICWAFObject computerobj);             
}
 

The getHostname() method returns null if no hostname and description selections are available. If the page extension is able to find an appropriate suggestion, this method returns a two-element string array containing the hostname in the first element, and the description in the second.

IHostnameLookup Example Class

Example 5-10 shows a sample IHostname Lookup class.


Example 5-10: Sample HostnameLookup
public class SampleHostnameLookup
  implements com.cisco.csrc.ursub.IHostnameLookup
{
  public String[] getHostname(
      ICWAFObject accountobj, ICWAFObject subscriberobj,
      ICWAFObject modemobj, ICWAFObject computerobj)
  {
    // build a string array for the results.
    String values[] = new String[2];
 
    // populate the hostname and description in the array.
    values[0] = "comp-"+prepareHostname(modemobj.getAttr("MACAddress"));
    values[1] = "acc-"+accountobj.getAttr("AccountNumber");
  }
 
  // simple helper method that strips out illegal characters
  public String prepareHostname(String macaddr)
  {
    // create a buffer to use when stripping out the bad characters.
    StringBuffer work = new StringBuffer();
    
    // check each character in the mac address.
    for (int i=0; i<macaddr.length(); i++)
    {
      // check if this is a valid character.
      char c = macaddr.charAt(i);
      switch (c)
      {
        // check for illegal hostname characters.
        case ':': break;
        case ',': break;
        // if it isn't a bad character, add to the hostname.
        default:  buf.append(c);
      }
    }
 
    // return the processed string.
    return work.toString();
  }
}

This sample class returns a generated hostname and description that is based on the current computer's MAC address and subscriber's account number. The hostname is the MAC address with any illegal characters removed. The description is the account number of the subscriber. The getAttr() method can be called on any of the input objects and can access the attributes listed in the application schema.

For multivalued attributes, use getAttrList(), which returns a string array of values. Both getAttr() and getAttrList() return null if the object does not have the desired value set. Calling getAttr() or getAttrList() on an invalid attribute causes a Java exception to be thrown. If you are unfamiliar with exception catching, review a standard Java reference manual.

Hostname Checking

When a subscriber clicks Accept on the activate_device or update_device pages, you can have the Hostname Check page extension perform additional validation and uniqueness checking on the supplied values.

For example, you could use the Hostname Check page extension to verify hostname uniqueness in an external name server or have it provide a textual message containing a list of suggestions for alternative hostnames.


Note If you have enabled the Skip hostname selection option, User Registrar will not call this page extension.

IHostnameCheck Java Interface

Example 5-11 shows the IHostnameCheck interface.


Example 5-11: IHostnameCheck
public interface com.cisco.csrc.ursub.IHostnameCheck
{
  public String isValidHostname(String hostname);
}
 

The isValidHostname() method returns null if the hostname is valid. If the hostname is unacceptable, the method displays a message to the subscriber explaining why the username is not available.

Tips You could use the IHostname Check page extension to check for profanity in the hostnames and then, when detected, return a message stating that the hostname is inappropriate.

IHostnameCheck Example Class

Example 5-12 shows a sample IHostname Check class.


Example 5-12: Sample Hostname Check
public class SampleHostnameCheck
  implements com.cisco.csrc.ursub.IHostnameCheck
{
  public String isValidHostname(String hostname)
  {
    // check if the hostname is valid.
    if (hostname.equalsIgnoreCase("www") ||
        hostname.equalsIgnoreCase("mail"))
      return "You may not select '"+hostname+"' as a computer name.";
 
    // if the hostname passed all the checks, return null.
    return null;
  }
}
 

This sample class checks for certain special hostnames and ensures that they are not selected. If a reserved name is selected, the code returns an error message explaining that the selected hostname is not available. When the hostname passes all of the checks, the code returns null to allow the subscriber to select the desired hostname.

Writing Page Extensions

A page extension is logic you can configure to seamlessly integrate with User Registrar Subscriber. Each page extension has a corresponding Java interface that controls how is it called in the UI.

For example, the Username Check page extension is used to provide additional username uniqueness checking when subscribers are registering with the system. The Java interface contains a single method isValidUsername() that determines whether a username is available. When developing page extensions, you must compile a new Java class for each instance.

To compile and enable a page extension, do the following:

    1. Install the Java Development Kit (first-time only)

    2. Write the new page extension.

    3. Compile the new page extension.

    4. Enable the page extension through User Registrar Administrator


hometocprevnextglossaryfeedbacksearchhelp
Posted: Fri Oct 22 08:26:39 PDT 1999
Copyright 1989-1999©Cisco Systems Inc.