com.waveset.adapter
Class TestResourceAdapter

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

public class TestResourceAdapter
extends ResourceAdapterBase


Nested Class Summary
 class TestResourceAdapter.AcctIter
           
 
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
static java.lang.String code_id
           
static boolean debug
           
 
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
TestResourceAdapter()
           
TestResourceAdapter(Resource res, ObjectCache cache)
           
 
Method Summary
protected static void addXmlHeader(java.lang.StringBuffer b, java.lang.String element)
          Add our standard XML header to a buffer.
 WavesetResult authenticate(java.util.HashMap loginInfo)
          Authenticates the user against the resource.
 WavesetResult checkCreateAccount(WSUser user)
           
 WavesetResult checkDeleteAccount(WSUser user)
           
 WavesetResult checkUpdateAccount(WSUser user)
           
static void clearCaches()
          Clear all caches.
 WavesetResult createAccounts(WSUser[] users)
           
 java.lang.String createIdentity(WSUser user)
          Overide ResourceAdapterBase's createIdentity to just return the user name as the identity.
 Resource createPrototypeResource()
           
 WavesetResult deleteAccounts(WSUser[] users)
           
static void flushCaches()
          Manually flush all caches.
 WSAttributes getAccountAttributes(java.lang.String accountIdentity)
          This method is obsolete.
 WSUser getAccountAttributes(WSUser src)
          Return a user object containing the known state of an existing user account, if any.
 AccountIterator getAccountIterator()
          jsl - changed this so we don't use the native HashMap iterator, but instead create a sorted list.
 java.util.List getAllAccounts()
          Get all of the accounts in this resource.
 java.lang.String getIdentity(WSUser user)
          Overload of the one in BaseResourceAdapter that auto creates one for this resource.
 WSUser getUser(WSUser user)
          Return a fully populated user from the resource if it exists.
 java.util.HashMap readUserFile(java.lang.String path)
          Read an XML user file into a map.
protected  void realCreate(WSUser user, WavesetResult result)
          Needs to be overridden by subclass if default createAccounts() implementation is used.
protected  void realDelete(WSUser user, WavesetResult result)
          Needs to be overridden by subclass if default deleteAccounts() implementation is used.
protected  void realUpdate(WSUser user, WavesetResult result)
          Needs to be overridden by subclass if default updateAccounts() implementation is used.
static void setAutoFlush(boolean b)
          Enable or disable autoflush.
static Resource staticCreatePrototypeResource()
           
 java.lang.String toXml()
          Returns the string buffer built by toXml(StringBuffer) as a String.
 WavesetResult updateAccounts(WSUser[] users)
           
static void writeUserFile(java.lang.String path, java.util.HashMap users)
          Serialize a user cache to a file.
 
Methods inherited from class com.waveset.adapter.ResourceAdapterBase
checkForNoPasswordInSchema, checkSyntax, createAccount, createObject, deleteAccount, deleteAccount, deleteObject, disableAccount, disableAccounts, dnsEqual, dnsEqual, enableAccount, enableAccounts, executeResourceAttributeJavascriptAction, fillInResourceInfo, fillInResourceInfo, getAccountIterator, getAccountIterator, getAction, getActionNotFoundErrorMessage, getActionNotFoundMessage, getActionRunAsPassword, getActionRunAsUser, getActionTimeout, getActionType, getAdapter, getAdapter, getAdapter, getAdapterProxy, getAdapterProxy, getAttrNameFromMapName, getAttrNameFromMapName, getAttrParse, getAttrTypeFromMapName, getAttrTypeFromMapName, getAUserName, getBaseContextAttrName, getBaseContextObject, getBaseContexts, getBlockSize, getContext, getExcludedAccountsRule, getFeatures, 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, listObjects, listObjectsOfType, lookupAction, lookupAction, lookupActions, namesEqual, objectClassesMatchType, println, realDisable, realEnable, restoreResourceObjectClassAttr, run, run, runResourceAttributeJavascriptAction, scan, setCache, setContext, setDisabled, setFromResource, setResource, setResourceObjectClassAttr, setResourceOptionAttrs, startConnection, startConnectionWrapper, stopConnection, supportsAccountActions, supportsAccountDisable, supportsActions, supportsCaseInsensitiveAccountIds, supportsContainerObjectTypes, supportsExcludedAccounts, supportsResourceAccount, supportsScanning, testConfiguration, updateAccount, 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

debug

public static boolean debug
Constructor Detail

TestResourceAdapter

public TestResourceAdapter(Resource res,
                           ObjectCache cache)

TestResourceAdapter

public TestResourceAdapter()
Method Detail

staticCreatePrototypeResource

public static Resource staticCreatePrototypeResource()
                                              throws WavesetException
Throws:
WavesetException

createPrototypeResource

public Resource createPrototypeResource()
                                 throws WavesetException
Specified by:
createPrototypeResource in interface ResourceAdapter
Specified by:
createPrototypeResource in class ResourceAdapterBase
Throws:
WavesetException

setAutoFlush

public static void setAutoFlush(boolean b)
Enable or disable autoflush.


flushCaches

public static void flushCaches()
                        throws WavesetException
Manually flush all caches.

Throws:
WavesetException

clearCaches

public static void clearCaches()
Clear all caches. This has to be called by some of the unit tests that yank the user files out from under the adapter.


addXmlHeader

protected static void addXmlHeader(java.lang.StringBuffer b,
                                   java.lang.String element)
Add our standard XML header to a buffer.


writeUserFile

public static void writeUserFile(java.lang.String path,
                                 java.util.HashMap users)
                          throws WavesetException
Serialize a user cache to a file. This is the persistent representation of the test resource database.

Throws:
WavesetException

readUserFile

public java.util.HashMap readUserFile(java.lang.String path)
                               throws WavesetException
Read an XML user file into a map.

Throws:
WavesetException

checkCreateAccount

public WavesetResult checkCreateAccount(WSUser user)
                                 throws WavesetException
Specified by:
checkCreateAccount in interface ResourceAdapter
Specified by:
checkCreateAccount in class ResourceAdapterBase
Throws:
WavesetException

getUser

public WSUser getUser(WSUser user)
               throws WavesetException
Return a fully populated user from the resource if it exists. Throws an informative waveset exception if the user is not found Check the user array for the user. return if found.

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

getIdentity

public java.lang.String getIdentity(WSUser user)
                             throws WavesetException
Overload of the one in BaseResourceAdapter that auto creates one for this resource. This is mostly for test convenience, we have some test files with WSUser definitions but no resource info's. Since the identities are the same as the user name, we can fake them up as we go. jsl

Overrides:
getIdentity in class ResourceAdapterBase
Throws:
WavesetException

realCreate

protected void realCreate(WSUser user,
                          WavesetResult result)
                   throws WavesetException
Description copied from class: ResourceAdapterBase
Needs to be overridden by subclass if default createAccounts() implementation is used.

Overrides:
realCreate in class ResourceAdapterBase
Throws:
WavesetException

createAccounts

public WavesetResult createAccounts(WSUser[] users)
                             throws WavesetException
Specified by:
createAccounts in interface ResourceAdapter
Overrides:
createAccounts in class ResourceAdapterBase
Throws:
WavesetException

checkUpdateAccount

public WavesetResult checkUpdateAccount(WSUser user)
                                 throws WavesetException
Specified by:
checkUpdateAccount in interface ResourceAdapter
Specified by:
checkUpdateAccount in class ResourceAdapterBase
Throws:
WavesetException

realUpdate

protected void realUpdate(WSUser user,
                          WavesetResult result)
                   throws WavesetException
Description copied from class: ResourceAdapterBase
Needs to be overridden by subclass if default updateAccounts() implementation is used.

Overrides:
realUpdate in class ResourceAdapterBase
Throws:
WavesetException

updateAccounts

public WavesetResult updateAccounts(WSUser[] users)
                             throws WavesetException
Specified by:
updateAccounts in interface ResourceAdapter
Overrides:
updateAccounts in class ResourceAdapterBase
Throws:
WavesetException

checkDeleteAccount

public WavesetResult checkDeleteAccount(WSUser user)
                                 throws WavesetException
Specified by:
checkDeleteAccount in interface ResourceAdapter
Specified by:
checkDeleteAccount in class ResourceAdapterBase
Throws:
WavesetException

realDelete

protected void realDelete(WSUser user,
                          WavesetResult result)
                   throws WavesetException
Description copied from class: ResourceAdapterBase
Needs to be overridden by subclass if default deleteAccounts() implementation is used.

Overrides:
realDelete in class ResourceAdapterBase
Throws:
WavesetException

deleteAccounts

public WavesetResult deleteAccounts(WSUser[] users)
                             throws WavesetException
Specified by:
deleteAccounts in interface ResourceAdapter
Overrides:
deleteAccounts in class ResourceAdapterBase
Throws:
WavesetException

getAccountAttributes

public WSAttributes getAccountAttributes(java.lang.String accountIdentity)
                                  throws WavesetException
Description copied from interface: ResourceAdapter
This method is obsolete. ResourceAdapterBase provides a default implementation that throws a "not implemented" WavesetException.

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

getAccountAttributes

public WSUser getAccountAttributes(WSUser src)
                            throws WavesetException
Return a user object containing the known state of an existing user account, if any. Return null without throwing an excpetion if it doesn't exist.

Throws:
WavesetException

getAllAccounts

public java.util.List getAllAccounts()
                              throws WavesetException
Get all of the accounts in this resource.

This is a temporary testing method for the extractor/loader, will be eventually replaced with some sort of iteration mechanism.

Here, we just read in our file of objects and return them in a list. The easiest thing would be to call loadResourceFile and then iterate over the hash table, but the users then get processed in an unspecified order which makes unit tests using golden files harder. Instead, we duplicate some of the logic in parseXml so that the list returned is in the same order as the file.

jsl - lobotomized this when we switched to the new static user caches. Could resurect it, but its not supposed to be used any more.

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

toXml

public java.lang.String toXml()
Returns the string buffer built by toXml(StringBuffer) as a String.


createIdentity

public java.lang.String createIdentity(WSUser user)
                                throws WavesetException
Overide ResourceAdapterBase's createIdentity to just return the user name as the identity. This way we don't have to require that an idTemplate be defined in the resource. PWD: if there is an identity template, invoke the superclass.

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

getAccountIterator

public AccountIterator getAccountIterator()
                                   throws WavesetException
jsl - changed this so we don't use the native HashMap iterator, but instead create a sorted list. This is so we can dump the contents of the "database" in a repeatable way for some of the test cases.

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