Sun Java System Content Delivery Server Customization Guide
|
  
|
This chapter describes the Sun Java System Content Delivery Server User Management API. Use this API to create a subscriber adapter to add, delete, retrieve, update, enable, and disable users in the system.
The User Profile API consists of the following classes:
- UserManager - Abstract class that you extend to create your own subscriber adapter. This class controls the creation and status of an individual user account.
- User - Interface that you implement to manage the attributes specific for each user.
- UserDeviceManager interface - Interface that you implement to provide information about the device that the subscriber is using. This inteface can be used to protect against the subscriber paying once and downloading the content to several devices.
For information on classes or methods not described in this section, see the HTML output of the Javadoc tool for the User Profile API at $CDS_HOME/javadoc/cdsapi/index.html.
6.1 UserManager Class
The UserManager class defines methods to create, delete, or access information for a user.
6.1.1 doAccountExists()
abstract boolean doAccountExists(String uId)
Returns true if a user account already exists in the persistent storage for a given user ID.
6.1.2 doAddUser()
protected abstract boolean doAddUser(User u)
Creates a user.
6.1.3 doDisableUser()
protected abstract void doDisableUser(String uId)
Disables a user's account. Used to lock the user account.
6.1.4 doEnableUser()
protected abstract void doEnableUser(String uId)
Enables a user's account.
6.1.5 doFormatMobileId()
protected abstract String doFormatMobileId(String mobileId);
Formats the mobile ID to match the requirements of the external database. For example, use this method to remove special characters for a database that cannot handle hyphens within the ID.
6.1.6 doFormatLoginId()
protected abstract String doFormatLoginId(String loginId);
Formats the login ID to match the requirements of the external database. For example, use this method to convert the ID to lowercase for a database that requires lowercase IDs.
6.1.7 doGetAllLikeInOrder()
protected abstract void doAllLikeInOrder(String[] columns, String[] values, String[] orders, boolean isDescending, int pageNum, int recPerPage, String role)
Returns an iterator of requested objects in the order specified.
6.1.8 doGetAllUsers()
protected abstract Iterator doGetAllUsers(String role)
Returns an iterator of all the users in permanent storage based on user role.
6.1.9 doGetAllUsersContainingFirstName()
protected abstract Iterator doGetAllUsersContainingFirstName(String nameLike, String role)
Returns an iterator of all users containing the specified substring in the first name based on user role.
6.1.10 doGetAllUsersContainingId()
protected abstract Iterator doGetAllUsersContainingId(String id, String role)
Returns an iterator of all users containing the specified substring in the user ID based on user role.
6.1.11 doGetAllUsersContainingLastName()
protected abstract Iterator doGetAllUsersContainingLastName(String lastName, String role)
Returns an iterator of all users containing the specified substring in the last name based on user role.
6.1.12 doGetAllUsersContainingName()
protected abstract Iterator doGetAllUsersContainingName(String name, String role)
Returns an iterator of all users containing the specified substring in either the first name or the last name based on user role.
6.1.13 doGetAnonymousUser()
protected abstract User doGetAnonymousUser()
Returns a guest user for anonymous access to the system.
6.1.14 doGetFieldName()
protected abstract String doGetFieldName(int fieldConstant, String role)
Gets the name of the field in the external database that corresponds to a field constant based on the user role.
6.1.15 doGetUser()
protected abstract User doGetUser(String uId)
Returns the user object associated with a given user ID.
6.1.16 doGetUserByMobileId()
protected abstract User doGetUserByMobileId(String inMobileId)
Returns the user object associated with a given user mobile ID.
6.1.17 doGetUserByUniqueDeviceId()
protected abstract User doGetUserByUniqueDeviceId(String inUniqueDeviceId)
Returns the user object associated with a given user unique device ID.
6.1.18 doGetUserInstance()
protected abstract User doGetUserInstance()
Returns the instance of user class implementation being passed in the addUser method.
6.1.19 doIsActive()
protected abstract boolean doIsActive(String uId)
Returns true if the user account associated with the userId is active. Returns false if the account is not active.
6.1.20 doIsAuthenticated()
protected abstract boolean doIsAuthenticated(String userId, String inPassword)
Returns true if the user ID and password provided are allowed access.
6.1.21 doRemoveUser()
protected abstract boolean doRemoveUser(String uId)
Removes the user from persistent storage. Returns true if successful.
6.1.22 doUpdateUser()
protected abstract boolean doUpdateUser(User u)
Updates an existing user's account.
6.2 User Interface
The User interface defines common methods to get, set, or delete user attributes.
6.2.1 getActivateDate()
public Date getActivateDate()
Returns the date of the user's account is activated.
6.2.2 getAttribute()
public Object getAttribute ( String name )
Returns the value of an attribute associated with a particular user.
6.2.3 getAttribute()
public Object getAttribute ( String name, Object defaultValue )
Returns the value of a specific attribute associated with a particular user or the default value if the attribute is not found.
6.2.4 getAttributes()
public Hashtable getAttributes()
Returns a hash table containing all the attributes associated with a particular user.
6.2.5 getCity()
public String getCity()
Returns the city name.
6.2.6 getCountry()
public String getCountry()
Returns the country name.
6.2.7 getCreateDate()
public java.util.Date getCreateDate()
Returns the date the user's account is created.
6.2.8 getDeActivateDate()
public Date getDeActivateDate()
Returns the date the user's account is activated.
6.2.9 getEmail()
public String getEmail()
Returns user's email ID.
6.2.10 getFirstName()
public String getFirstName()
Returns the user's first name.
6.2.11 getGender()
public String getGender()
Returns the user's gender.
6.2.12 getLastLogin()
public java.util.Date getLastLogin()
Returns the time of the user's last login.
6.2.13 getLastName()
public String getLastName()
Returns the user's last name.
6.2.14 getLoginId()
public String getLoginId()
Returns the user's unique login ID.
6.2.15 getMiddleName()
public String getMiddleName()
Returns the user's middle name.
6.2.16 getMobileId()
public String getMobileId()
Returns the user's mobile ID.
6.2.17 getPassword()
public String getPassword()
Returns the user's unique password.
6.2.18 getPhone()
public String getPhone()
Returns the user's contact phone number.
6.2.19 getPostalCode()
public String getPostalCode()
Returns the postal code of the user's account.
6.2.20 getSalutation()
public String getSalutation()
Returns user's salutation.
6.2.21 getState()
public String getState()
Returns the state name.
6.2.22 getStreet1()
public String getStreet1()
Returns the first line of the user's street address.
6.2.23 getStreet2()
public String getStreet2()
Returns the second line of the user's street address.
6.2.24 getUniqueDeviceId()
public String getUniqueDeviceId()
Returns the user's unique device ID.
6.2.25 hasLoggedIn()
public boolean hasLoggedIn()
Returns true if the user is currently logged in to the system.
6.2.26 isConfirmed()
public boolean isConfirmed()
Returns true if the user's account is confirmed or verified.
6.2.27 isEnabled()
public boolean isEnabled()
Returns true if the user account is currently enabled and false if disabled.
6.2.28 isPrepay()
public boolean isPrepay()
Returns true if the user account is prepaid.
6.2.29 setActivateDate()
public void setActivateDate(Date aDate)
Sets the date the user's account is activated.
6.2.30 setAttribute()
public void setAttribute ( String name, Object value )
Sets the attribute associated with a particular user.
6.2.31 setAttributes()
public void setAttributes(Hashtable stuff)
Sets the list of attributes associated with a particular user.
6.2.32 setCity()
public void setCity(String city)
Sets the city name.
6.2.33 setCountry()
public void setCountry(String country)
Sets the country name.
6.2.34 setCreateDate()
public void setCreateDate(java.util.Date date)
Sets the date the user's account is created.
6.2.35 setDeActivateDate()
public void setDeActivateDate(Date daDate)
Sets the date the user's account is inactivated.
6.2.36 setEmail()
public void setEmail(String address)
Sets the user's email ID.
6.2.37 setFirstName()
public void setFirstName(String firstName)
Sets the user's first name.
6.2.38 setGender()
public void setGender(String gender)
Sets the user's gender.
6.2.39 setHasLoggedIn()
public void setHasLoggedIn(boolean value)
Sets the flag to indicate the user has logged into the system.
6.2.40 setIsEnabled()
public void setIsEnabled(boolean value)
Sets the account status to enabled.
6.2.41 setIsPrepay()
public void setIsPrepay(boolean value)
Sets the account to prepaid.
6.2.42 setLastName()
public void setLastName(String lastName)
Sets the user's last name.
6.2.43 setLoginId()
public void setLoginId(String loginName)
Sets the user's unique login ID.
6.2.44 setMiddleName()
public void setMiddleName(String name)
Sets the user's middle name.
6.2.45 setMobileId()
public void setMobileId(String mobileId)
Sets the user's mobile ID.
6.2.46 setPassword()
public void setPassword(String pass)
Sets the user's password.
6.2.47 setPhone()
public void setPhone(String phone)
Sets the user's contact phone number.
6.2.48 setPostalCode()
public void setPostalCode(String zip)
Sets the postal code for the user's address.
6.2.49 setSalutation()
public void setSalutation(String salutation)
Sets the salutation for the user (for example, Mr. or Mrs.)
6.2.50 setState()
public void setState(String state)
Sets the state for the user's address.
6.2.51 setStreet1()
public void setStreet1(String st1)
Sets the first line of the user's street address.
6.2.52 setStreet2()
public void setStreet2(String st2)
Sets the second line of the user's street address.
6.2.53 setUniqueDeviceId()
public void setUniqueDeviceId(String uniqueId)
Sets the user's unique device ID.
6.2.54 updateLastLogin()
public void updateLastLogin() throws Exception
Updates the timestamp with the time of the last login.
6.3 UserDeviceManager Interface
The UserDeviceManager interface defines a method for accessing the unique ID for a device.
6.3.1 getUniqueDeviceID()
public String getUniqueDeviceID(String inMSISDN) throws UserDeviceException
Gets the unique device ID such as the Electronic Serial Number (ESN) given the MSISDN for the device.
6.4 Using the User Profile API
The classes for the User Profile API are available in cdsapi.jar, which is found in the $CDS_HOME/deployment/deployment-name/lib/cdslib directory. The cdsapi.jar file must be in your classpath when you compile your adapter.
To make your adapter available to the Content Delivery Server, follow these steps:
1. Create a JAR file for your adapter.
2. Place the JAR file in the $CDS_HOME/deployment/deployment-name/lib/external directory.
3. Open the security.config file in the $CDS_HOME/deployment/deployment-name/conf directory.
4. Set the module.security.subscriber.usermanager property to the class name of your implementation of the User interface, for example:
module.security.subscriber.usermanager=com.sun.content.server.server.security.user.SubscriberImpl
5. Save your changes.
6. Restart the Content Delivery Server to make it aware of the new JAR file.
6.5 Sample Implementation of the User Manager API
The following example is the class definition of the MyUserMgr. It is an example of how you can inherit the UserManager class to manage your user profile system and integrate it into the Content Delivery Server User Profile framework.The following sample classes provide an example of how you can use the User Profile API to manage your user profile system and integrate it into the Content Delivery Server User Profile framework.
6.5.1 Support Files
The sample implementation of the User Profile API makes use of properties and a supporting class. The following code shows the properties used.
CODE EXAMPLE 6-1 Sample Property File
# This is a sample of typical Operator Integration properties file
# for external user manager client/server connection settings.
# SAMPLE OPERATOR CONFIGURATIONS
#
externalserveraddress=localhost
externalserverport=7779
cdsclientlogin=cds14sun
cdsclientpasswd=cds4sun1
|
The SampleExternalProxy class is used as the interface between the Content Delivery Server and the external database.
CODE EXAMPLE 6-2 Sample External Proxy
package com.sun.content.server.operator.security.adaptor;
import java.util.*;
import com.sun.content.server.service.security.*;
import com.sun.content.server.service.security.util.*;
// import external required packages to connect to the directory service
public class SampleExternalProxy
{
// Create a Client facace for serach
private ExternalClientObject externalUserMgr;
// Create an instance of External Directorory server Client Proxy
public SampleExternalProxy() throws Exception {
// User the external package to instanciate the Proxu
// You need to use the client/server setting in the
// operatorproxy.properties
// The following assume you implemented a class OperatorProxyProperties
// to read the configuration values.
String hostname = OperatorProxyProperties.EXTERNAL_SERVER_ADDRESS;
String port = OperatorProxyProperties.EXTERNAL_SERVER_PORT;
String clientLoginId = OperatorProxyProperties.CLIENT_LOGIN;
String clientPassword = OperatorProxyProperties.CLIENT_PASSWRD;
// instan
try {
externalUserMgr = new ExternalClientObject(hostname, port,
clientLoginId, clientPassword);
} catch (Exception expt) {
// process the exception
throw expt;
}
}
public boolean searchUser(String userName) {
boolean found = false;
// Use the external User manager and search function for the given string
// name
// Typically the call will look like
// found = externalUserMgr.searchUser(userName);
// You may need to catch potential exception and display the appropriate
// message
return found;
}
public SampleUserImpl createUserFromExternal(String loginId)
throw Exception {
System.out.println("DEBUG: SampleExternal Proxy--createUserFromExternal ");
System.out.println(" Creating a SampleUserImpl from External Directory...");
System.out.println(" Reference Login Id = "+loginId);
try {
// Assuming the external client has been created and connection is
// established
// The following call typically search for the UserName and return an
// External UserProfile
aUserProfileData aUPD = externalUserMgr.getUserProfileData(loginId);
String password = aUPD.getCredential();
// Create basic User information (firstname,
// middlename, lastname,
// address, etc.)
String firstName = aUPD.getFirstName();
String lastName = aUPD.getLastName();
String middleName = aUPD.getMiddleInitial();
String gender = aUPD.getGender();
String salutation = aUPD.getOccupation();
String street1 = aUPD.getStreet();
String street2 = aUPD.getStreetNumber();
String city = aUPD.getCity();
String state = aUPD.getState();
String postalcode = aUPD.getZipCode();
String country = aUPD.getCountry();
String phone = aUPD.getFixedPhone();
// Creating email information
String email = aUPD.getMailAddress();
// Creating msisdn in this case Unique Device Id ()
String uniqueDeviceId = aUPD.getMsisdn();
// Creating Status data: User Enabled/Desabled and User is
// Prepay/Non-Prepay are valued 1/0
boolean enabled = false;
if (aUPD.getStatus().equals("1"))
enabled = true;
boolean prepay = false;
if (aUPD.getPrepayType().equals("1"))
prepay = true;
// Create activation and deactivation dates if provided
Date activatedate = new Date();
Date deactivatedate = null;
// Create and return a Sample User Implementation
return new SampleUserImpl(
loginId,
password,
firstName,
lastName,
middleName,
gender,
street1,
street2,
city,
state,
postalcode,
country,
email,
phone,
activatedate,
deactivatedate,
salutation,
enabled,
uniqueDeviceId,
prepay);
} catch (Exception ex) {
// procecss exception
throw ex;
}
return null;
}
}
|
6.5.2 SampleUserImpl.java
The following code is a sample implementation of the User interface. This interface includes the fields that the Content Delivery Server uses for user profiles. If you have additional fields for your specific implementation, add the methods required to get and set those values.
CODE EXAMPLE 6-3 Sample User Implementation
package com.sun.content.server.operator.security.adaptor;
import com.sun.content.server.service.security.User;
import java.util.Date;
import java.util.Hashtable;
public class SampleUserImpl implements User
{
private Hashtable fInfo;
public SampleUserImpl() {
fInfo = new Hashtable();
setLoginId("guest");
setFirstName("guest");
setLastName("guest");
setPassword ("guest");
setCreateDate(new Date());
setActivateDate(new Date());
fInfo.put("enabled", String.valueOf(true));
setMiddleName("guest");
setEmail("guest@email.com");
setUniqueDeviceId("1231231233");
}
public SampleUserImpl(String uid, String pwd, String fname, String lname,
String mname, String gender, String street1, String street2, String city,
String state, String postalcode, String country, String email,
String phone, Date actdate,Date deactdate,String salutation, ,
boolean enabled, String uniqueDeviceId, boolean isprepay) {
fInfo = new Hashtable();
setLoginId(uid);
setPassword(pwd);
setFirstName(fname);
setLastName(lname);
setMiddleName(mname);
setGender(gender);
setStreet1(street1);
setStreet2(street2);
setCity(city);
setState(state);
setPostalCode(postalcode);
setCountry(country);
setEmail(email);
setPhone(phone);
setFixedPhone(phone);
// It is safe to check the activation date and use current date if null
if ( actdate == null ) {
setCreateDate(new Date());
setActivateDate(new Date());
}
else {
setCreateDate(actdate);
setActivateDate(actdate);
}
setDeActivateDate(deactdate);
setSalutation(salutation);
setIsEnabled(enabled);
setUniqueDeviceId(uniqueDeviceId);
setIsPrepay(isprepay);
}
public SampleUserImpl(User inUser) {
fInfo = new Hashtable();
setLoginId(inUser.getLoginId());
setFirstName(inUser.getFirstName());
setLastName(inUser.getLastName());
setMiddleName(inUser.getMiddleName());
setGender(inUser.getGender());
setStreet1(inUser.getStreet1());
setStreet2(inUser.getStreet2());
setCity(inUser.getCity());
setState(inUser.getState());
setPostalCode(inUser.getPostalCode());
setCountry(inUser.getCountry());
setEmail(inUser.getEmail());
setPhone(inUser.getPhone());
setSalutation(inUser.getSalutation());
setIsEnabled(inUser.isEnabled());
setPassword(inUser.getPassword());
setUniqueDeviceId(inUser.getUniqueDeviceId());
}
// It is sometimes useful to have the corresponding external user data as a
// hashtable
public Hashtable getExternalUserData()
{
// Create a hash table
Hashtable externalData = new Hashtable();
// Get all the external data from fInfo and update the external data
// externalData = parserUser(fInfo);
return externalData;
}
public Date getLastLogin() {
/**@todo: Implement this com.sun.content.server.service.security.User method*/
throw new java.lang.UnsupportedOperationException("Method getLastLogin()
not yet implemented.");
}
public Object getAttribute(String param1) {
/**@todo: Implement this com.sun.content.server.service.security.User method*/
throw new java.lang.UnsupportedOperationException("Method getAttribute()
not yet implemented.");
}
public Object getAttribute(String param1, Object parm2) {
/**@todo: Implement this com.sun.content.server.service.security.User method*/
throw new java.lang.UnsupportedOperationException("Method getAttribute()
not yet implemented.");
}
public Hashtable getAttributes() {
/**@todo: Implement this com.sun.content.server.service.security.User method*/
throw new java.lang.UnsupportedOperationException("Method getAttributes()
not yet implemented.");
}
public void setHasLoggedIn(boolean param1) {
/**@todo: Implement this com.sun.content.server.service.security.User method*/
throw new java.lang.UnsupportedOperationException("Method setAttribute()
not yet implemented.");
}
public boolean hasLoggedIn() {
/**@todo: Implement this com.sun.content.server.service.security.User method*/
throw new java.lang.UnsupportedOperationException("Method isConfirmed()
not yet implemented.");
}
public void setAttribute(String param1, Object parm2) {
/**@todo: Implement this com.sun.content.server.service.security.User method*/
throw new java.lang.UnsupportedOperationException("Method setAttribute()
not yet implemented.");
}
public void setAttributes(Hashtable param1) {
/**@todo: Implement this com.sun.content.server.service.security.User method*/
throw new java.lang.UnsupportedOperationException("Method setAttributes()
not yet implemented.");
}
public String getLoginId() {
return (String)fInfo.get("loginId");
}
public void setLoginId(String param1) {
if (param1 != null)
fInfo.put("loginId", param1);
}
public String getFirstName() {
return (String)fInfo.get("firstName");
}
public void setFirstName(String param1) {
if (param1 != null)
fInfo.put("firstName", param1);
}
public String getLastName() {
return (String)fInfo.get("lastName");
}
public void setLastName(String param1) {
if (param1 != null)
fInfo.put("lastName", param1);
}
public Date getCreateDate() {
return (Date)fInfo.get("createDate");
}
public void setCreateDate(Date param1) {
if (param1 != null)
fInfo.put("createDate", param1);
}
public String getEmail() {
return (String)fInfo.get("email");
}
public void setEmail(String param1) {
if (param1 != null)
fInfo.put("email", param1);
}
public boolean isConfirmed() {
/**@todo: Implement this com.sun.content.server.service.security.User method*/
throw new java.lang.UnsupportedOperationException("Method isConfirmed()
not yet implemented.");
}
public void updateLastLogin() throws java.lang.Exception {
/**@todo: Implement this com.sun.content.server.service.security.User method*/
throw new java.lang.UnsupportedOperationException("Method updateLastLogin()
not yet implemented.");
}
public String getMiddleName() {
return (String)fInfo.get("middleName");
}
public void setMiddleName(String param1) {
if (param1 != null)
fInfo.put("middleName", param1);
}
public String getGender() {
return (String)fInfo.get("gender");
}
public void setGender(String param1) {
if (param1 != null)
fInfo.put("gender", param1);
}
public String getStreet1() {
return (String)fInfo.get("street1");
}
public void setStreet1(String param1) {
if (param1 != null)
fInfo.put("street1", param1);
}
public String getStreet2() {
return (String)fInfo.get("street2");
}
public void setStreet2(String param1) {
if (param1 != null)
fInfo.put("street2", param1);
}
public String getPostalCode() {
return (String)fInfo.get("postalCode");
}
public void setPostalCode(String param1) {
if (param1 != null)
fInfo.put("postalCode", param1);
}
public String getCity() {
return (String)fInfo.get("city");
}
public void setCity(String param1) {
if (param1 != null)
fInfo.put("city", param1);
}
public String getState() {
return (String)fInfo.get("state");
}
public void setState(String param1) {
if (param1 != null)
fInfo.put("state", param1);
}
public String getCountry() {
return (String)fInfo.get("country");
}
public void setCountry(String param1) {
if (param1 != null)
fInfo.put("country", param1);
}
public String getPhone() {
return (String)fInfo.get("phone");
}
public void setPhone(String param1) {
if (param1 != null)
fInfo.put("phone", param1);
}
public Date getActivateDate() {
return (Date)fInfo.get("activateDate");
}
public void setActivateDate(Date param1) {
if (param1 != null)
fInfo.put("activateDate", param1);
}
public Date getDeActivateDate() {
return (Date)fInfo.get("deactivateDate");
}
public void setDeActivateDate(Date param1) {
if (param1 != null)
fInfo.put("deactivateDate", param1);
}
public String getSalutation() {
return (String)fInfo.get("salutation");
}
public void setSalutation(String param1) {
if (param1 != null)
fInfo.put("salutation", param1);
}
public boolean isEnabled() {
return Boolean.valueOf((String)fInfo.get("enabled")).booleanValue();
}
public void setIsEnabled(boolean param1) {
fInfo.put("enabled", String.valueOf(param1));
}
public String getPassword() {
return (String)fInfo.get("password");
}
public void setPassword(String param1) {
if (param1 != null)
fInfo.put("password", param1);
}
public String getUniqueDeviceId(){
return (String)fInfo.get("UniqueDeviceId");
}
public void setUniqueDeviceId(String uniqueId){
if (uniqueId != null)
fInfo.put("UniqueDeviceId", uniqueId);
}
public String getMobileId(){
return (String)fInfo.get("MobileId");
}
public void setMobileId(String mobileId) {
if (mobileId != null)
fInfo.put("MobileId", mobileId);
}
public boolean isPrepay() {
Boolean isprepay = (Boolean)fInfo.get("isPrepay");
return isprepay.booleanValue();
}
public void setIsPrepay(boolean param1) {
fInfo.put("isPrepay", new Boolean(param1));
}
}
|
6.5.3 SampleUserManagerImpl.java
The following code is a sample extension of the UserManager class.
CODE EXAMPLE 6-4 Example Using the UserManager Class
package com.sun.content.server.operator.security.adaptor;
import java.util.*;
//import Content Delivery Server libraries
import com.sun.content.server.service.security.*;
import com.sun.content.server.service.security.util.*;
//import here operator required packages
// .......
public class SampleUserManagerImpl extends UserManager{
private SampleExternalProxy proxy;
public SampleUserManagerImpl() throws UserProfileResourceException {
try {
init();
} catch (Exception ex) {
throw new com.sun.content.server.service.security.util.UserProfileResourceException(
"Failed to instantiate SampleUserManagerImpl ", ex);
}
}
// This method will create an External Directory Server Proxy and
// initiatlize this User Manager
private void init() throws UserProfileResourceException
{
System.out.println("Initializing External UserManager .... ");
try {
proxy = new SampleExternalProxy();
} catch (Exception ex) {
System.out.println("Fatal Error " + ex.toString());
throw new com.sun.content.server.service.security.util.UserProfileResourceException(ex.toString());
}
}
protected boolean doIsAuthenticated(String inUserId, String inPassword)
throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doIsAuthenticated --- ");
boolean isauthenticated = false;
try {
User aUser = proxy.createUserFromExternal(inUserId);
isauthenticated = ( (aUser.getLoginId()==inUserId) && (aUser.getPassword()==inPassword));
if (isauthenticated)
System.out.println("SampleUserManagerImpl.doIsAuthenticated: - User "+inUserId+" is successfully authenticated.");
else
System.out.println("SampleUserManagerImpl.doIsAuthenticated: - User "+inUserId+" : unable to authenticate (wrong login and password)");
} catch (Exception ex) {
isauthenticated = false;
System.out.println("SampleUserManagerImpl.doIsAuthenticated: - User "+inUserId+" can not authenticate (user not found)");
throw new com.sun.content.server.service.security.util.UserProfileResourceException(ex.toString());
}
return isauthenticated;
}
protected boolean doAccountExists(String userId) throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doAccountExists --- ");
// Use the External Proxy search method to check if the account exist
return proxy.searchUser(userId);
}
protected boolean doAddUser(User user) throws UserProfileResourceException{
boolean updated = false;
//This is not an allowed operation. If this is not the case add the code to
// implement it
System.out.println("SampleUserManagerImpl.doAddUser - This operation is not implemented !");
return updated;
}
protected void doDisableUser(String userId) throws UserProfileResourceException {
//This is not an allowed operation. If this is not the case add the code to
// implement it
System.out.println("SampleUserManagerImpl.doDisableUser - This operation is not implemented !");
}
protected void doEnableUser(String userId) throws UserProfileResourceException {
//This is not an allowed operation. If this is not the case add the code to
// implement it
System.out.println("SampleUserManagerImpl.doEnableUser - This operation is not implemented !");
}
protected User doGetAnonymousUser() throws UserProfileResourceException {
return new SampleUserImpl();
}
protected User doGetUser(String userId) throws UserProfileResourceException {
User aUser = null;
try {
aUser = proxy.createUserFromExternal(userId);
if (aUser != null)
System.out.println("SampleUserManagerImpl.doGetUserByUniqueDeviceId: - User with "+userId+" is found.");
else
System.out.println("SampleUserManagerImpl.doGetUserByUniqueDeviceId: - User with "+userId+" not found");
} catch (Exception ex) {
System.out.println("SampleUserManagerImpl.doGetUserByUniqueDeviceId: - User "+userId+" not found)");
throw new com.sun.content.server.service.security.util.UserProfileResourceException(ex);
}
return aUser;
}
/* This method can be implemented the same way as doGetUser. Instead of
* using the createUserFromExternal(loginId) you can extend the
* SampleExternalProxy to implement a specific
* createUserFromExternalUsingDeviceId(uniqueDeviceId).
* For now we will assume that the string loginId can be replaced by a search
* key ID and it will return the matching profile.
*/
protected User doGetUserByUniqueDeviceId(String inUniqueDeviceId)
throws UserProfileResourceException {
return doGetUser(inUniqueDeviceId);
}
// Sample implementation as doGetUser
protected User doGetUserByMobileId(String inMobileId)
throws UserProfileResourceException {
return doGetUser(inMobileId);
}
protected Iterator doGetAllUsers(String role)
throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doGetAllUsers - This operation is not implemented !");
ArrayList users = new ArrayList();
return users.iterator();
}
protected Iterator doGetAllUsersContainingLastName(String lastName,
String role) throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doGetAllUsersContainingLastName - This operation is not implemented !");
ArrayList users = new ArrayList();
return users.iterator();
}
protected Iterator doGetAllUsersContainingFirstName(String firstName, String role) throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doGetAllUsersContainingFirstName - This operation is not implemented !");
ArrayList users = new ArrayList();
return users.iterator();
}
protected Iterator doGetAllUsersContainingName(String name, String role)
throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doGetAllUsersContainingName - This operation is not implemented !");
ArrayList users = new ArrayList();
return users.iterator();
}
protected Iterator doGetAllUsersContainingId(String userId, String role)
throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doGetAllUsersContainingId - This operation is not implemented !");
ArrayList users = new ArrayList();
return users.iterator();
}
protected Iterator doGetAllLikeInOrder(String[] columns, String[] values,
String[] orders, boolean isDescending, int pageNum, int recPerPage,
String role)
throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doGetAllLikeInOrder - This operation is not implemented !");
ArrayList users = new ArrayList();
return users.iterator();
}
protected String doGetFieldName(int fieldContant, String role)
throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doGetFieldName - This operation is not implemented !");
return null;
}
protected boolean doIsActive(String userId) throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doIsActive - This operation is not implemented !");
return false;
}
protected boolean doRemoveUser(String userId)
throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doRemoveUser - This operation is not implemented !");
return false;
}
protected boolean doUpdateUser(User user)
throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doUpdateUser - This operation is not implemented !");
return false;
}
protected User doGetUserInstance() throws UserProfileResourceException {
System.out.println("SampleUserManagerImpl.doGetUserInstance - This operation is not implemented !");
return null;
}
}
|
Sun Java System Content Delivery Server Customization Guide
|
819-3213-10
|
  
|
Copyright © 2005, Sun Microsystems, Inc. All Rights Reserved.