com.waveset.adapter
Class SiteminderExampleTableResourceAdapter

java.lang.Object
  extended bycom.waveset.adapter.ResourceAdapterBase
      extended bycom.waveset.adapter.JdbcResourceAdapter
          extended bycom.waveset.adapter.SiteminderExampleTableResourceAdapter
All Implemented Interfaces:
ResourceAdapter

public class SiteminderExampleTableResourceAdapter
extends JdbcResourceAdapter


Nested Class Summary
static class SiteminderExampleTableResourceAdapter.TableAccountIterator
          The implementation of the AccountIterator returned by getAccountIterator.
 
Nested classes inherited from class com.waveset.adapter.ResourceAdapterBase
ResourceAdapterBase.SimpleAccountIterator
 
Nested classes inherited from class com.waveset.adapter.ResourceAdapter
ResourceAdapter.ActionResult, ResourceAdapter.Features, ResourceAdapter.ObjectType
 
Field Summary
protected  SiteminderUtil _smu
           
static java.lang.String code_id
           
static java.lang.String DEFAULT_DRIVER
          The default value for the RA_DRIVER resource attribute.
static java.lang.String DEFAULT_TEMPLATE
          The default connect URL template.
static java.lang.String DISABLEDPWDFLAG
           
static java.lang.String EMAIL
           
static java.lang.String FIRST_NAME
           
static java.lang.String GROUPS
           
protected static java.lang.String GROUPS_SCHEMA
           
static java.lang.String LAST_NAME
           
protected static java.lang.String MEMBERS_SCHEMA
           
static java.lang.String MILEAGE
           
static java.lang.String PIN
           
static java.lang.String RA_DISABLEDPWDFLAG
           
static java.lang.String RA_GROUPS
          The optional group(s) to assign to accounts created by this adapter.
static java.lang.String RA_GROUPS_TABLE
           
static java.lang.String RA_MEMBERS_TABLE
           
static java.lang.String RA_PASSWORD_ATTR
           
static java.lang.String RA_USERS_TABLE
           
static java.lang.String TELE_NUM
           
static java.lang.String USERID
           
protected static java.lang.String USERS_SCHEMA
           
 
Fields inherited from class com.waveset.adapter.JdbcResourceAdapter
RA_DATABASE, RA_DRIVER, RA_HOST, RA_PASSWORD, RA_PORT, RA_QUOTING, RA_URL_PREFIX, RA_URL_TEMPLATE, RA_USER
 
Fields inherited from class com.waveset.adapter.ResourceAdapterBase
_cache, _context, _excludedAccountsRule, _excludedAccountsRuleInited, _listAllObjectsAttrParse, _listAllObjectsAttrParseName, _listUserAttrParse, _listUserAttrParseName, _listUserGroupsAttrParse, _listUserGroupsAttrParseName, _resource, _thread, _trace, displayInfoCode, RA_BLOCKCOUNT, RA_LOGIN_ACTION, RA_LOGOFF_ACTION, RA_MULTI_VALUED_ATTRS, RA_TEST_MODE
 
Fields inherited from interface com.waveset.adapter.ResourceAdapter
CHANGE_PASSWORD_LOCATION, DISABLE, ENABLE, EXPIRE_PASSWORD, GUID, IGNORE_ATTR, NEW_ACCOUNT_ID, OP_DAYS_INACTIVE, OP_DISABLED, OP_DORMANT, OP_EXPIRED, OP_EXPIREDPWD, OP_INACTIVE, OP_LOCKED, OP_NO_PASSWORD_SET, OP_NOOWNERSHIP, OP_NOPASSWORDREQ, OP_NUMINACTIVEDAYS, OP_NUMPWDAYS, OP_PWNUMDAYS, RA_BASE_CTX, RA_DISPLAY_NAME_ATTR, RA_NEW_OBJECT_ID, RA_NEW_OBJECT_NAME, RA_OBJECT_ATTRIBUTES, RA_OBJECT_CLASS, RA_OBJECT_ID, RA_OBJECT_TYPE, RA_OP_TYPE, RA_RENAME_OP, RA_REQUESTOR, RA_SAVEAS_OP, RA_SEARCH_ATTRIBUTE_NAMES, RA_SEARCH_ATTRS_TO_GET, RA_SEARCH_CONTEXT, RA_SEARCH_FILTER, RA_SEARCH_RUN_AS_PASSWORD, RA_SEARCH_RUN_AS_USER, RA_SEARCH_SCOPE, RA_SEARCH_SCOPE_OBJECT, RA_SEARCH_SCOPE_ONE_LEVEL, RA_SEARCH_SCOPE_SUBTREE, RA_SEARCH_TIME_LIMIT, RESET_PASSWORD, SYSTEM_ATTRIBUTES, UNLOCK, WS_USER_PASSWORD
 
Constructor Summary
SiteminderExampleTableResourceAdapter()
          Create an adapater instance, without a resource.
SiteminderExampleTableResourceAdapter(Resource res, ObjectCache cache)
          Create an adapter instance for a resource.
 
Method Summary
 void addAttributeValue(java.lang.StringBuffer b, WSUser user, java.lang.String attname)
          Helper method for building the values() list for an insert statement from account attributes.
 void addQuoted(java.lang.StringBuffer b, java.lang.String s)
          Add a quoted string to a SQL statement we're building in a buffer.
 WavesetResult authenticate(java.util.HashMap loginInfo)
          Authenticates the user against the resource.
 WSUser buildUser(java.lang.String accountId)
          Build the base user object given an id.
 WavesetResult checkCreateAccount(WSUser user)
          Check to see if an account can be created.
 WavesetResult checkDeleteAccount(WSUser user)
          Check account deletion.
 void checkSchema()
           
protected  void checkTable(java.sql.Connection con, java.lang.String name, java.lang.String schema)
           
 WavesetResult checkUpdateAccount(WSUser user)
          Check the ability to perform an account update.
 void createGroup(java.lang.String id, java.lang.String name)
           
 Resource createPrototypeResource()
          Create the prototype instance.
 AccountIterator getAccountIterator()
          Return an iterator that will iterate over all the accounts on a resource.
 java.lang.String getColumn(java.sql.ResultSet result, int col)
          Get a string from a result set, trimming trailing blanks.
 java.util.List getGroupIds(java.sql.Connection con, java.util.List names)
          Given a list of group names, create a list of the corresponding group ids.
 java.util.List getGroupNames(java.sql.Connection con, java.util.List ids)
          Given a list of group ids, create a list of the corresponding group names.
 WSUser getUser(WSUser idUser)
          Public adapter method to get the current user information.
 java.util.List getUserIds(java.sql.Connection con, java.util.List names)
          Given a list of user names, create a list of the corresponding user ids.
 java.util.List listObjects(java.lang.String objectType, java.util.Map options)
          Default implementation calls older method ResourceAdapterBase.listAllObjects(String, Map, String, EncryptedData), which does not support newer options (such as "searchContext" or "searchFilter").
protected  java.lang.String modifyDisabledFlag(java.sql.Connection con, WSUser user, java.lang.String action, WavesetResult result)
          Modifies/Adds Siteminder User Disabled Flag Attribute
protected  void realCreate(WSUser user, WavesetResult result)
          Create a new account.
protected  void realDelete(WSUser user, WavesetResult result)
          Delete the account for real.
protected  void realDisable(WSUser user, WavesetResult result)
          Sets Disabled attribute that is mapped to Siteminder Disabled Flag and ResourceInfo Disabled 'true'
protected  void realEnable(WSUser user, WavesetResult result)
          Sets Disabled attribute that is mapped to Siteminder Disabled Flag and ResourceInfo Disabled 'false'
protected  void realUpdate(WSUser user, WavesetResult result)
          Perform the actual account update.
 void startConnection()
          Needs to be overridden by subclass if default createAccounts() implementation is used.
static Resource staticCreatePrototypeResource()
          Create the prototype instance.
 void stopConnection()
          Needs to be overridden by subclass if default createAccounts() implementation is used.
 boolean supportsAccountDisable()
          Whether the resource can enable and disable accounts.
 
Methods inherited from class com.waveset.adapter.JdbcResourceAdapter
addAttributeValue, attributeRequiresQuotingInSQL, closeConnection, closeResult, closeStatement, decodeCommaList, dumpResult, encodeCommaList, execProcedure, execProcedure, execSql, execSql, execSql, flushResults, flushResultsQuietly, formatTemplateUrl, formatUrl, formatUrl, getConnection, getConnection, getConnection, getConnectionString, getConnectionUrl, getConnectionUrl, getEncryptedResourceAttribute, getResourceAttribute, mergeCommaLists, mergeStringLists, println, queryInt, queryString, setDebug
 
Methods inherited from class com.waveset.adapter.ResourceAdapterBase
checkForNoPasswordInSchema, checkSyntax, createAccount, createAccounts, createIdentity, createObject, deleteAccount, deleteAccount, deleteAccounts, deleteObject, disableAccount, disableAccounts, dnsEqual, dnsEqual, enableAccount, enableAccounts, executeResourceAttributeJavascriptAction, fillInResourceInfo, fillInResourceInfo, getAccountAttributes, getAccountIterator, getAccountIterator, getAction, getActionNotFoundErrorMessage, getActionNotFoundMessage, getActionRunAsPassword, getActionRunAsUser, getActionTimeout, getActionType, getAdapter, getAdapter, getAdapter, getAdapterProxy, getAdapterProxy, getAllAccounts, getAttrNameFromMapName, getAttrNameFromMapName, getAttrParse, getAttrTypeFromMapName, getAttrTypeFromMapName, getAUserName, getBaseContextAttrName, getBaseContextObject, getBaseContexts, getBlockSize, getContext, getExcludedAccountsRule, getFeatures, getIdentity, getListAllObjectsAttrParse, getListUserAttrParse, getListUserGroupsAttrParse, getObject, getOptionalBooleanResAttrVal, getOptionalBooleanResAttrVal, getOptionalEncryptedResAttrVal, getOptionalResAttrVal, getOptionalStringResAttrVal, getRequiredResAttr, getRequiredResAttr, getRequiredResAttrVal, getRequiredResAttrVal, getRequiredResAttrVals, getRequiredUserAttributeNames, getResAttrValActionOnUser, getResAttrVals, getResource, getResourceAccounts, getResourceInfo, getResourceObjectAttrValNameAttr, getResourceObjectClassAttr, getResourceObjectTypePrefix, getSchemaMap, getUser, getWSAttrByMapName, getWSAttrByMapName, getWSAttrFromMap, handleActionResult, handleJavascriptActionResult, isAccountAttributeSecret, isExcludedAccount, isExcludedAccount, isFeatureEnabled, isSupported, isTestMode, listAllObjects, listAllObjects, listObjects, listObjectsOfType, lookupAction, lookupAction, lookupActions, namesEqual, objectClassesMatchType, println, restoreResourceObjectClassAttr, run, run, runResourceAttributeJavascriptAction, scan, setCache, setContext, setDisabled, setFromResource, setResource, setResourceObjectClassAttr, setResourceOptionAttrs, startConnectionWrapper, supportsAccountActions, supportsActions, supportsCaseInsensitiveAccountIds, supportsContainerObjectTypes, supportsExcludedAccounts, supportsResourceAccount, supportsScanning, testConfiguration, updateAccount, updateAccounts, updateObject, updateResourceAccount, updateResourceIdentity, vmStoreBoot, vmStoreGet, vmStoreInit, vmStoreLatch, vmStorePut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

DEFAULT_DRIVER

public static final java.lang.String DEFAULT_DRIVER
The default value for the RA_DRIVER resource attribute. We will be using a Sybase database in this example.

See Also:
Constant Field Values

DEFAULT_TEMPLATE

public static final java.lang.String DEFAULT_TEMPLATE
The default connect URL template.

See Also:
Constant Field Values

RA_GROUPS

public static final java.lang.String RA_GROUPS
The optional group(s) to assign to accounts created by this adapter. Groups are defined as both a resource attribute and an account attribute in this example. If a group list is specified in the resource attribute, then all users will have at least the specified groups. If a group list is also specified in the account attribute, the two lists will be merged.

See Also:
Constant Field Values

_smu

protected SiteminderUtil _smu

RA_USERS_TABLE

public static final java.lang.String RA_USERS_TABLE
See Also:
Constant Field Values

RA_GROUPS_TABLE

public static final java.lang.String RA_GROUPS_TABLE
See Also:
Constant Field Values

RA_MEMBERS_TABLE

public static final java.lang.String RA_MEMBERS_TABLE
See Also:
Constant Field Values

RA_DISABLEDPWDFLAG

public static final java.lang.String RA_DISABLEDPWDFLAG
See Also:
Constant Field Values

RA_PASSWORD_ATTR

public static final java.lang.String RA_PASSWORD_ATTR
See Also:
Constant Field Values

USERID

public static final java.lang.String USERID
See Also:
Constant Field Values

FIRST_NAME

public static final java.lang.String FIRST_NAME
See Also:
Constant Field Values

LAST_NAME

public static final java.lang.String LAST_NAME
See Also:
Constant Field Values

EMAIL

public static final java.lang.String EMAIL
See Also:
Constant Field Values

TELE_NUM

public static final java.lang.String TELE_NUM
See Also:
Constant Field Values

DISABLEDPWDFLAG

public static final java.lang.String DISABLEDPWDFLAG
See Also:
Constant Field Values

PIN

public static final java.lang.String PIN
See Also:
Constant Field Values

MILEAGE

public static final java.lang.String MILEAGE
See Also:
Constant Field Values

GROUPS

public static final java.lang.String GROUPS
See Also:
Constant Field Values

USERS_SCHEMA

protected static final java.lang.String USERS_SCHEMA
See Also:
Constant Field Values

GROUPS_SCHEMA

protected static final java.lang.String GROUPS_SCHEMA
See Also:
Constant Field Values

MEMBERS_SCHEMA

protected static final java.lang.String MEMBERS_SCHEMA
See Also:
Constant Field Values
Constructor Detail

SiteminderExampleTableResourceAdapter

public SiteminderExampleTableResourceAdapter(Resource res,
                                             ObjectCache cache)
Create an adapter instance for a resource.


SiteminderExampleTableResourceAdapter

public SiteminderExampleTableResourceAdapter()
Create an adapater instance, without a resource.

Method Detail

staticCreatePrototypeResource

public static Resource staticCreatePrototypeResource()
                                              throws WavesetException
Create the prototype instance.

Throws:
WavesetException

createPrototypeResource

public Resource createPrototypeResource()
                                 throws WavesetException
Create the prototype instance.

Specified by:
createPrototypeResource in interface ResourceAdapter
Specified by:
createPrototypeResource in class ResourceAdapterBase
Throws:
WavesetException

startConnection

public void startConnection()
                     throws WavesetException
Description copied from class: ResourceAdapterBase
Needs to be overridden by subclass if default createAccounts() implementation is used.

Overrides:
startConnection in class ResourceAdapterBase
Throws:
WavesetException

stopConnection

public void stopConnection()
                    throws WavesetException
Description copied from class: ResourceAdapterBase
Needs to be overridden by subclass if default createAccounts() implementation is used.

Overrides:
stopConnection in class ResourceAdapterBase
Throws:
WavesetException

checkCreateAccount

public WavesetResult checkCreateAccount(WSUser user)
                                 throws WavesetException
Check to see if an account can be created. We ping the server and see if the user already exists.

Specified by:
checkCreateAccount in interface ResourceAdapter
Specified by:
checkCreateAccount in class ResourceAdapterBase
Throws:
WavesetException

realCreate

protected void realCreate(WSUser user,
                          WavesetResult result)
                   throws WavesetException
Create a new account.

Overrides:
realCreate in class ResourceAdapterBase
Throws:
WavesetException

addAttributeValue

public void addAttributeValue(java.lang.StringBuffer b,
                              WSUser user,
                              java.lang.String attname)
Helper method for building the values() list for an insert statement from account attributes. It simply checks for null values, and converts the null to space.


addQuoted

public void addQuoted(java.lang.StringBuffer b,
                      java.lang.String s)
Add a quoted string to a SQL statement we're building in a buffer. Can't insert a null, so insert a space.

Overrides:
addQuoted in class JdbcResourceAdapter

getGroupIds

public java.util.List getGroupIds(java.sql.Connection con,
                                  java.util.List names)
                           throws WavesetException
Given a list of group names, create a list of the corresponding group ids. For simplicity, this will be done with a sequence of queries, in practice you would try to build a more complex SQL statement to do as much of this as possible in one query. If a group does not exist, leave null at that position in the returned list so we can use them as maps into each other.

Throws:
WavesetException

getGroupNames

public java.util.List getGroupNames(java.sql.Connection con,
                                    java.util.List ids)
                             throws WavesetException
Given a list of group ids, create a list of the corresponding group names.

Throws:
WavesetException

getUserIds

public java.util.List getUserIds(java.sql.Connection con,
                                 java.util.List names)
                          throws WavesetException
Given a list of user names, create a list of the corresponding user ids.

Throws:
WavesetException

checkUpdateAccount

public WavesetResult checkUpdateAccount(WSUser user)
                                 throws WavesetException
Check the ability to perform an account update. The account must exist.

Specified by:
checkUpdateAccount in interface ResourceAdapter
Specified by:
checkUpdateAccount in class ResourceAdapterBase
Throws:
WavesetException

realUpdate

protected void realUpdate(WSUser user,
                          WavesetResult result)
                   throws WavesetException
Perform the actual account update.

The account ID cannot be changed.

Password changes are indiciated with a non-null password stored in the ResourceInfo object for this resource.

Extended account attribute changes are indicated with non-null attribute values in the user. If an attribute value is null, it means that the current value is to be kept, not cleared. To clear a value, the attribute value in the user must be the empty string.

We currently do not have a way to flag changes in the email value, other than reading the current user object and comparing.

Changes to group membership require that we read the current group list so we can determine which memberships to add, and which to remove.

Attribute changes will be collected in a Map which will then be used to construct a SQL update statement.

Overrides:
realUpdate in class ResourceAdapterBase
Throws:
WavesetException

checkDeleteAccount

public WavesetResult checkDeleteAccount(WSUser user)
                                 throws WavesetException
Check account deletion. We don't care if the account doesn't exist, just make sure the server is accessable.

Specified by:
checkDeleteAccount in interface ResourceAdapter
Specified by:
checkDeleteAccount in class ResourceAdapterBase
Throws:
WavesetException

realDelete

protected void realDelete(WSUser user,
                          WavesetResult result)
                   throws WavesetException
Delete the account for real.

Overrides:
realDelete in class ResourceAdapterBase
Throws:
WavesetException

getColumn

public java.lang.String getColumn(java.sql.ResultSet result,
                                  int col)
                           throws java.sql.SQLException
Get a string from a result set, trimming trailing blanks.

Throws:
java.sql.SQLException

buildUser

public WSUser buildUser(java.lang.String accountId)
Build the base user object given an id.


getUser

public WSUser getUser(WSUser idUser)
               throws WavesetException
Public adapter method to get the current user information.

Specified by:
getUser in interface ResourceAdapter
Overrides:
getUser in class ResourceAdapterBase
Throws:
WavesetException

getAccountIterator

public AccountIterator getAccountIterator()
                                   throws WavesetException
Return an iterator that will iterate over all the accounts on a resource.

Specified by:
getAccountIterator in interface ResourceAdapter
Overrides:
getAccountIterator in class ResourceAdapterBase
Throws:
WavesetException

authenticate

public WavesetResult authenticate(java.util.HashMap loginInfo)
                           throws WavesetException
Description copied from interface: ResourceAdapter
Authenticates the user against the resource. If authentication is successful, the authenticated id will be returned. If more info is required to complete authentication the result will contain the required info

Specified by:
authenticate in interface ResourceAdapter
Specified by:
authenticate in class ResourceAdapterBase
Throws:
WavesetException

supportsAccountDisable

public boolean supportsAccountDisable()
Whether the resource can enable and disable accounts.

Specified by:
supportsAccountDisable in interface ResourceAdapter
Overrides:
supportsAccountDisable in class ResourceAdapterBase
Returns:
boolean if Account Disable supported

modifyDisabledFlag

protected java.lang.String modifyDisabledFlag(java.sql.Connection con,
                                              WSUser user,
                                              java.lang.String action,
                                              WavesetResult result)
                                       throws WavesetException
Modifies/Adds Siteminder User Disabled Flag Attribute

Parameters:
user - the user to Disable
Returns:
none
Throws:
WavesetException

realEnable

protected void realEnable(WSUser user,
                          WavesetResult result)
                   throws WavesetException
Sets Disabled attribute that is mapped to Siteminder Disabled Flag and ResourceInfo Disabled 'false'

Overrides:
realEnable in class ResourceAdapterBase
Parameters:
user - the user to Enable
Returns:
none
Throws:
WavesetException - if ENABLED fails

realDisable

protected void realDisable(WSUser user,
                           WavesetResult result)
                    throws WavesetException
Sets Disabled attribute that is mapped to Siteminder Disabled Flag and ResourceInfo Disabled 'true'

Overrides:
realDisable in class ResourceAdapterBase
Parameters:
user - the user to Disable
Returns:
none
Throws:
WavesetException - if DISABLED fails

listObjects

public java.util.List listObjects(java.lang.String objectType,
                                  java.util.Map options)
                           throws WavesetException
Description copied from class: ResourceAdapterBase
Default implementation calls older method ResourceAdapterBase.listAllObjects(String, Map, String, EncryptedData), which does not support newer options (such as "searchContext" or "searchFilter").

Each ResourceAdapter subclass should override this default implementation as soon as possible with an implementation that supports the options specified in {#listObjects(ObjectType, Map)}.

Specified by:
listObjects in interface ResourceAdapter
Overrides:
listObjects in class ResourceAdapterBase
Throws:
WavesetException

createGroup

public void createGroup(java.lang.String id,
                        java.lang.String name)
                 throws WavesetException
Throws:
WavesetException

checkSchema

public void checkSchema()
                 throws WavesetException
Throws:
WavesetException

checkTable

protected void checkTable(java.sql.Connection con,
                          java.lang.String name,
                          java.lang.String schema)
                   throws WavesetException
Throws:
WavesetException