com.waveset.adapter
Class SimulatedResourceAdapter

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

public class SimulatedResourceAdapter
extends XMLResourceAdapter


Nested Class Summary
static class SimulatedResourceAdapter.ExtendedResourceCache
           
static class SimulatedResourceAdapter.ResourceObjects
          A class maintaining a collection of "resource objects" managed by a particular resource.
static class SimulatedResourceAdapter.State
           
 
Nested classes inherited from class com.waveset.adapter.XMLResourceAdapter
XMLResourceAdapter.AcctIter, XMLResourceAdapter.ResourceCache
 
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 CLASS
           
static java.lang.String code_id
           
static java.lang.String INVALID_PORT
          Special value for the "port" resource attribute we will recognize and throw an exception.
static java.lang.String RESOURCE_TYPE
           
 
Fields inherited from class com.waveset.adapter.XMLResourceAdapter
_caches, DISABLED_ATTRIBUTE
 
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
SimulatedResourceAdapter()
          Create a basic addapter.
SimulatedResourceAdapter(Resource res, ObjectCache cache)
          Create an adapter for a particular resource, allowed to obtain objects from an object cache.
 
Method Summary
 WavesetResult createObject(java.lang.String type, java.lang.String id, java.util.Map attributes, java.util.Map options)
          Why pass a Map of attributes here, should pass in a GenericObject like we returned from getObject.
 Resource createPrototypeResource()
          Create the prototype resource.
protected  GenericObject findCachedUser(XMLResourceAdapter.ResourceCache cache, WSUser user)
           
 GenericObject getAccount(WSUser user)
          Convert a WSUser passed down from the Provisioner into a GenericObject for storage.
protected static XMLResourceAdapter.ResourceCache getCache(Resource resource, boolean caseInsensitive)
          Return the cache for a particular resource, loading it it isn't resident.
protected  XMLResourceAdapter.ResourceCache getCachedData()
           
 GenericObject getFeatures()
          Features we support.
static GenericObject getNativeAccount(Resource res, java.lang.String accountId)
          Return the internal representation of an account.
 GenericObject getObject(java.lang.String type, java.lang.String objectId, java.util.Map attrsToGet, java.util.Map options)
          In attrsToGet, suggest just passing a List rather than a Map.
 GenericObject getObjectSchema(java.lang.String type, java.lang.String scope)
          Return the schema of objects we support.
 java.util.List getResourceAccounts(java.util.List attributes)
           
static SimulatedResourceAdapter.State getState(Resource resource)
           
static SimulatedResourceAdapter.State getState(java.lang.String name)
          Special static method to return the State for a particular resource, which can then be modified at runtime.
 WSUser getUser(GenericObject geo)
          Convert GenericObject, expected to have been created by getAccount() above back into a WSUser.
 java.util.ArrayList listAllObjects(java.lang.String type, java.util.Map options, java.lang.String runAsUser, EncryptedData runAsPassword)
          This method will return a list of object names of the specified object type.
static void nativeDelete(Resource res, java.lang.String accountId)
          Delete an account on a resource without Lighthouse awareness.
static void nativeDisable(Resource res, java.lang.String accountId)
           
static void nativeEnable(Resource res, java.lang.String accountId)
           
static void nativeUpdate(Resource res, GenericObject account)
          Update an account on a resource, the object should have been obtained with getNativeAccount.
 void prepare(java.lang.String op)
          Overload of the one in XMLResourceAdapter that inserts our simulations.
 void println(java.lang.String msg)
           
protected  void realCreate(WSUser user, WavesetResult result)
          Create a new account.
 void removeAllAccounts()
          Removes all users from the resource.
protected  void removeCachedUser(XMLResourceAdapter.ResourceCache cache, WSUser user)
           
 WavesetResult run(ResourceAction resAction, java.util.Map args)
          Run an arbitrary resource action.
 void setResource(Resource res)
           
static Resource staticCreatePrototypeResource()
          Create the prototype Resource.
 boolean supportsAccountDisable()
          Indicates whether or not this resource supports account disable.
 boolean supportsCaseInsensitiveAccountIds()
          This method will return whether the resource adapter supports case insensitive account Ids or not.
 boolean supportsResourceAccount()
          Returns true if the resource adapter supports modifications to the resource account.
 WavesetResult updateObject(java.lang.String type, java.lang.String id, java.util.Map attributes, java.util.Map options)
          Why pass a Map of attributes here, should pass in a GenericObject like we returned from getObject.
 WavesetResult updateResourceAccount(GenericObject account)
           
 
Methods inherited from class com.waveset.adapter.XMLResourceAdapter
accountsToXml, authenticate, checkCreateAccount, checkDeleteAccount, checkUpdateAccount, clearCaches, createAccounts, createIdentity, deleteAccounts, disableAccounts, enableAccounts, flushCaches, getAccountAttributes, getAccountAttributes, getAccountIterator, getAllAccounts, getCache, getIdentity, getPath, getUser, realDelete, realDisable, realEnable, realUpdate, setAutoFlush, updateAccounts
 
Methods inherited from class com.waveset.adapter.ResourceAdapterBase
checkForNoPasswordInSchema, checkSyntax, createAccount, createObject, deleteAccount, deleteAccount, deleteObject, disableAccount, dnsEqual, dnsEqual, enableAccount, 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, getListAllObjectsAttrParse, getListUserAttrParse, getListUserGroupsAttrParse, getObject, getOptionalBooleanResAttrVal, getOptionalBooleanResAttrVal, getOptionalEncryptedResAttrVal, getOptionalResAttrVal, getOptionalStringResAttrVal, getRequiredResAttr, getRequiredResAttr, getRequiredResAttrVal, getRequiredResAttrVal, getRequiredResAttrVals, getRequiredUserAttributeNames, getResAttrValActionOnUser, getResAttrVals, getResource, getResourceInfo, getResourceObjectAttrValNameAttr, getResourceObjectClassAttr, getResourceObjectTypePrefix, getSchemaMap, getUser, getWSAttrByMapName, getWSAttrByMapName, getWSAttrFromMap, handleActionResult, handleJavascriptActionResult, isAccountAttributeSecret, isExcludedAccount, isExcludedAccount, isFeatureEnabled, isSupported, isTestMode, listAllObjects, listObjects, listObjects, listObjectsOfType, lookupAction, lookupAction, lookupActions, namesEqual, objectClassesMatchType, println, restoreResourceObjectClassAttr, run, runResourceAttributeJavascriptAction, scan, setCache, setContext, setDisabled, setFromResource, setResourceObjectClassAttr, setResourceOptionAttrs, startConnection, startConnectionWrapper, stopConnection, supportsAccountActions, supportsActions, supportsContainerObjectTypes, supportsExcludedAccounts, supportsScanning, testConfiguration, updateAccount, updateObject, 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

CLASS

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

RESOURCE_TYPE

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

INVALID_PORT

public static final java.lang.String INVALID_PORT
Special value for the "port" resource attribute we will recognize and throw an exception. Useful to simulate misconfigured resources without having to add a forcedError attribute.

See Also:
Constant Field Values
Constructor Detail

SimulatedResourceAdapter

public SimulatedResourceAdapter()
Create a basic addapter.


SimulatedResourceAdapter

public SimulatedResourceAdapter(Resource res,
                                ObjectCache cache)
Create an adapter for a particular resource, allowed to obtain objects from an object cache.

Method Detail

setResource

public void setResource(Resource res)
Specified by:
setResource in interface ResourceAdapter
Overrides:
setResource in class XMLResourceAdapter

staticCreatePrototypeResource

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

Throws:
WavesetException

createPrototypeResource

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

Specified by:
createPrototypeResource in interface ResourceAdapter
Overrides:
createPrototypeResource in class XMLResourceAdapter
Throws:
WavesetException

getFeatures

public GenericObject getFeatures()
Features we support. Inherit what XmlResourceAdapter gives us, but optionally take out rename. UPDATE: For more flexibility, allow the full feature list to be specified as a resource attribute.

Specified by:
getFeatures in interface ResourceAdapter
Overrides:
getFeatures in class XMLResourceAdapter

supportsAccountDisable

public boolean supportsAccountDisable()
Description copied from interface: ResourceAdapter
Indicates whether or not this resource supports account disable. If it does not, the provisioning engine will attempt to simulate disable by generating random passwords. If we end up with more of these "can you do this" methods, we might want to generalize it into a more extensible way to describe features and levels of support.

Specified by:
supportsAccountDisable in interface ResourceAdapter
Overrides:
supportsAccountDisable in class XMLResourceAdapter

supportsResourceAccount

public boolean supportsResourceAccount()
                                throws WavesetException
Returns true if the resource adapter supports modifications to the resource account.

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

supportsCaseInsensitiveAccountIds

public boolean supportsCaseInsensitiveAccountIds()
Description copied from class: ResourceAdapterBase
This method will return whether the resource adapter supports case insensitive account Ids or not. By default it will always return true since most resources do not allow case sensitive user names. However, for those that do, they should override this method implementation in their respective resource adapter class to return false.

Specified by:
supportsCaseInsensitiveAccountIds in interface ResourceAdapter
Overrides:
supportsCaseInsensitiveAccountIds in class XMLResourceAdapter

getCache

protected static XMLResourceAdapter.ResourceCache getCache(Resource resource,
                                                           boolean caseInsensitive)
                                                    throws WavesetException
Return the cache for a particular resource, loading it it isn't resident.

Throws:
WavesetException

getCachedData

protected XMLResourceAdapter.ResourceCache getCachedData()
                                                  throws WavesetException
Overrides:
getCachedData in class XMLResourceAdapter
Throws:
WavesetException

findCachedUser

protected GenericObject findCachedUser(XMLResourceAdapter.ResourceCache cache,
                                       WSUser user)
                                throws WavesetException
Overrides:
findCachedUser in class XMLResourceAdapter
Throws:
WavesetException

removeCachedUser

protected void removeCachedUser(XMLResourceAdapter.ResourceCache cache,
                                WSUser user)
                         throws WavesetException
Overrides:
removeCachedUser in class XMLResourceAdapter
Throws:
WavesetException

getState

public static SimulatedResourceAdapter.State getState(java.lang.String name)
Special static method to return the State for a particular resource, which can then be modified at runtime. Used by some of the unit tests that want to start with a normal resource, but change it later. This was originally written to require the resource path name since that's what we normally use to key the resource map. This is however somewhat inconvenient and nonobvious for the tests so allow just the resource name to be supplied too.


getState

public static SimulatedResourceAdapter.State getState(Resource resource)
                                               throws WavesetException
Throws:
WavesetException

prepare

public void prepare(java.lang.String op)
             throws WavesetException
Overload of the one in XMLResourceAdapter that inserts our simulations.

Overrides:
prepare in class XMLResourceAdapter
Throws:
WavesetException

println

public void println(java.lang.String msg)

realCreate

protected void realCreate(WSUser user,
                          WavesetResult result)
                   throws WavesetException
Description copied from class: XMLResourceAdapter
Create a new account.

Overrides:
realCreate in class XMLResourceAdapter
Throws:
WavesetException

nativeDelete

public static void nativeDelete(Resource res,
                                java.lang.String accountId)
                         throws WavesetException
Delete an account on a resource without Lighthouse awareness.

Throws:
WavesetException

nativeDisable

public static void nativeDisable(Resource res,
                                 java.lang.String accountId)
                          throws WavesetException
Throws:
WavesetException

nativeEnable

public static void nativeEnable(Resource res,
                                java.lang.String accountId)
                         throws WavesetException
Throws:
WavesetException

getNativeAccount

public static GenericObject getNativeAccount(Resource res,
                                             java.lang.String accountId)
                                      throws WavesetException
Return the internal representation of an account. This may be modified and passed back to nativeUpdate to simulate native account modifications.

Throws:
WavesetException

nativeUpdate

public static void nativeUpdate(Resource res,
                                GenericObject account)
                         throws WavesetException
Update an account on a resource, the object should have been obtained with getNativeAccount.

Throws:
WavesetException

getObjectSchema

public GenericObject getObjectSchema(java.lang.String type,
                                     java.lang.String scope)
                              throws WavesetException
Return the schema of objects we support.

Throws:
WavesetException

listAllObjects

public java.util.ArrayList listAllObjects(java.lang.String type,
                                          java.util.Map options,
                                          java.lang.String runAsUser,
                                          EncryptedData runAsPassword)
                                   throws WavesetException
Description copied from interface: ResourceAdapter
This method will return a list of object names of the specified object type. If you need to be able to specify which attrs to return, use listObjects instead

Specified by:
listAllObjects in interface ResourceAdapter
Overrides:
listAllObjects in class ResourceAdapterBase
Parameters:
type - - a type of object that is either well-known or is meaningful to the resource. Every resource is expected to recognize certain values. For example, listAllObjects(ObjectType.ACCOUNT, null, null, null) should return a list of all account names.
options - - a map of options
runAsUser - - (optional) if specified, connect as this user to list all objects of the specified type.
runAsPassword - - (optional) if specified, connect with this password to list all objects of the specified type.
Returns:
a list of all object names of a specified type.
Throws:
WavesetException

getObject

public GenericObject getObject(java.lang.String type,
                               java.lang.String objectId,
                               java.util.Map attrsToGet,
                               java.util.Map options)
                        throws WavesetException
In attrsToGet, suggest just passing a List rather than a Map. You should need only the map keys, not the values. This would allow you to pass in a list containing complex path expressions if necessary.

Throws:
WavesetException

createObject

public WavesetResult createObject(java.lang.String type,
                                  java.lang.String id,
                                  java.util.Map attributes,
                                  java.util.Map options)
                           throws WavesetException
Why pass a Map of attributes here, should pass in a GenericObject like we returned from getObject.

Throws:
WavesetException

updateObject

public WavesetResult updateObject(java.lang.String type,
                                  java.lang.String id,
                                  java.util.Map attributes,
                                  java.util.Map options)
                           throws WavesetException
Why pass a Map of attributes here, should pass in a GenericObject like we returned from getObject.

Throws:
WavesetException

run

public WavesetResult run(ResourceAction resAction,
                         java.util.Map args)
                  throws WavesetException
Run an arbitrary resource action.

Specified by:
run in interface ResourceAdapter
Overrides:
run in class ResourceAdapterBase
Parameters:
resAction - The action to execute
args - Additional args, can be null.
Returns:
A WavesetResult.
Throws:
WavesetException

getResourceAccounts

public java.util.List getResourceAccounts(java.util.List attributes)
                                   throws WavesetException
Specified by:
getResourceAccounts in interface ResourceAdapter
Overrides:
getResourceAccounts in class ResourceAdapterBase
Throws:
WavesetException

updateResourceAccount

public WavesetResult updateResourceAccount(GenericObject account)
                                    throws WavesetException
Specified by:
updateResourceAccount in interface ResourceAdapter
Overrides:
updateResourceAccount in class ResourceAdapterBase
Throws:
WavesetException

getAccount

public GenericObject getAccount(WSUser user)
                         throws WavesetException
Description copied from class: XMLResourceAdapter
Convert a WSUser passed down from the Provisioner into a GenericObject for storage.

Overrides:
getAccount in class XMLResourceAdapter
Throws:
WavesetException

getUser

public WSUser getUser(GenericObject geo)
Description copied from class: XMLResourceAdapter
Convert GenericObject, expected to have been created by getAccount() above back into a WSUser.

Overrides:
getUser in class XMLResourceAdapter

removeAllAccounts

public void removeAllAccounts()
                       throws WavesetException
Removes all users from the resource. Mainly useful for junit tests

Throws:
WavesetException