com.waveset.adapter
Class XMLResourceAdapter

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

public class XMLResourceAdapter
extends ResourceAdapterBase


Nested Class Summary
 class XMLResourceAdapter.AcctIter
           
static class XMLResourceAdapter.ResourceCache
          Inner class holding a cache of accounts for a particular resource.
 
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 static java.util.Map _caches
          Account caches.
static java.lang.String code_id
           
static java.lang.String DISABLED_ATTRIBUTE
          The special attribute name we use to represent the disable status.
static java.lang.String RESOURCE_TYPE
           
 
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
XMLResourceAdapter()
          Create a basic addapter.
XMLResourceAdapter(Resource res, ObjectCache cache)
          Create an adapter for a particular resource, allowed to obtain objects from an object cache.
 
Method Summary
 java.lang.String accountsToXml()
           
 WavesetResult authenticate(java.util.HashMap loginInfo)
          Perform authentication with a set of credentials.
 WavesetResult checkCreateAccount(WSUser user)
          Check create request.
 WavesetResult checkDeleteAccount(WSUser user)
          Check account deletion.
 WavesetResult checkUpdateAccount(WSUser user)
          Check the ability to update an account.
static void clearCaches()
          Clear all caches.
 WavesetResult createAccounts(WSUser[] users)
          Create multiple accounts.
 java.lang.String createIdentity(WSUser user)
          Overide ResourceAdapterBase's createIdentity to just return the user name as the identity.
 Resource createPrototypeResource()
          Create the prototype resource.
 WavesetResult deleteAccounts(WSUser[] users)
          Delete multiple accounts.
 WavesetResult disableAccounts(WSUser[] users)
          Disable multiple accounts.
 WavesetResult enableAccounts(WSUser[] users)
          Enable multiple accounts.
protected  GenericObject findCachedUser(XMLResourceAdapter.ResourceCache cache, WSUser user)
           
static void flushCaches()
          Manually flush all caches.
 GenericObject getAccount(WSUser user)
          Convert a WSUser passed down from the Provisioner into a GenericObject for storage.
 WSAttributes getAccountAttributes(java.lang.String identity)
          Obsolete interface, no longer supported.
 WSUser getAccountAttributes(WSUser src)
          Obsolete interface, no longer supported.
 AccountIterator getAccountIterator()
          jsl - changed this so we don't use the native HashMap iterator, but instead create a sorted list.
 java.util.List getAllAccounts()
          Obsolete interface, no longer supported.
protected static XMLResourceAdapter.ResourceCache getCache(Resource resource)
          Return the cache for a particular resource, loading it it isn't resident.
protected  XMLResourceAdapter.ResourceCache getCachedData()
           
 GenericObject getFeatures()
          Features we support.
 java.lang.String getIdentity(WSUser user)
          Overload of the one in BaseResourceAdapter that auto creates one for this resource.
static java.lang.String getPath(Resource resource)
          Derive the file path for this resource.
 WSUser getUser(GenericObject geo)
          Convert GenericObject, expected to have been created by getAccount() above back into a WSUser.
 WSUser getUser(WSUser idUser)
          Return a fully populated user from the resource if one exists.
 void prepare(java.lang.String op)
          This will be called at the top of every adapter method.
protected  void realCreate(WSUser user, WavesetResult result)
          Create a new account.
protected  void realDelete(WSUser user, WavesetResult result)
          Delete an acocunt.
protected  void realDisable(WSUser user, WavesetResult result)
          Disable an account
protected  void realEnable(WSUser user, WavesetResult result)
          Enable an account
protected  void realUpdate(WSUser user, WavesetResult result)
          Update one account.
protected  void removeCachedUser(XMLResourceAdapter.ResourceCache cache, WSUser user)
           
static void setAutoFlush(boolean b)
          Enable or disable autoflush.
 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.
 WavesetResult updateAccounts(WSUser[] users)
          Update multiple accounts.
 
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, 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, restoreResourceObjectClassAttr, run, run, runResourceAttributeJavascriptAction, scan, setCache, setContext, setDisabled, setFromResource, setResourceObjectClassAttr, setResourceOptionAttrs, startConnection, startConnectionWrapper, stopConnection, supportsAccountActions, supportsActions, 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

RESOURCE_TYPE

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

DISABLED_ATTRIBUTE

public static final java.lang.String DISABLED_ATTRIBUTE
The special attribute name we use to represent the disable status. This should be moved to ResourceAdapterBase when we're ready to represent disable status uniformly as an attribute rather than a ResourceInfo flag.

See Also:
Constant Field Values

_caches

protected static java.util.Map _caches
Account caches. This is static so we don't have to read the user file every time, but we have to maintain multiple maps since there may be a different one for each resource used with the adapter.

The map is indexed by resource file path, the value is a Map of GenericObject objects.

Constructor Detail

XMLResourceAdapter

public XMLResourceAdapter()
Create a basic addapter.


XMLResourceAdapter

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

Method Detail

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
Specified by:
createPrototypeResource in class ResourceAdapterBase
Throws:
WavesetException

getFeatures

public GenericObject getFeatures()
Features we support. ACCOUNT_PASSWORD is the default,

Specified by:
getFeatures in interface ResourceAdapter
Overrides:
getFeatures in class ResourceAdapterBase
Returns:
Features supported by this resource adapter.
See Also:
ResourceAdapter.Features

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.


getPath

public static java.lang.String getPath(Resource resource)
                                throws WavesetException
Derive the file path for this resource. This is used as the cache key rather than resource name so we can test resource attribute overrides. Since the only meaningful attribute to override is the path, we use that to select caches, simmilar to how overriding the "host" might work.

Throws:
WavesetException

getCache

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

Throws:
WavesetException

getCachedData

protected XMLResourceAdapter.ResourceCache getCachedData()
                                                  throws WavesetException
Throws:
WavesetException

findCachedUser

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

removeCachedUser

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

accountsToXml

public java.lang.String accountsToXml()
                               throws WavesetException
Throws:
WavesetException

getAccount

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

Throws:
WavesetException

getUser

public WSUser getUser(GenericObject geo)
Convert GenericObject, expected to have been created by getAccount() above back into a WSUser.


prepare

public void prepare(java.lang.String op)
             throws WavesetException
This will be called at the top of every adapter method. Here it does nothing, but it is intended as an insertion point for subclasses to do something interesting before each operation. Currently used by SimulateResourceAdapter to make the resource methods "feel more natural".

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. Here, we can assume that that the WSUser name is the identity.

Since we call this in every method, this seems to be a good place to check for the forced error.

Overrides:
getIdentity in class ResourceAdapterBase
Throws:
WavesetException

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

getUser

public WSUser getUser(WSUser idUser)
               throws WavesetException
Return a fully populated user from the resource if one exists. The identity of the desired account is supplied via the given WSUser. This "idUser" must contain a ResourceInfo with a accountId already calculated, or the WSUser must contain all the attributes required for the identity template.

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

checkCreateAccount

public WavesetResult checkCreateAccount(WSUser user)
                                 throws WavesetException
Check create request. We decided after some discussion to silently ignore a create request if the account already exists. The Provisioner should be catching this. Here all we need to do is check the "connection" to the resource, which for us is a noop. The Resource page "Test" button invokes this method (although David Penick wishes we had a separate test() method). We should at least confirm that the file exists and is writable.

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

createAccounts

public WavesetResult createAccounts(WSUser[] users)
                             throws WavesetException
Create multiple accounts.

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

checkUpdateAccount

public WavesetResult checkUpdateAccount(WSUser user)
                                 throws WavesetException
Check the ability to update an account. I think we decided that update can throw if there is no account. Provisioner is supposed to always check for existing accounts and convert the operation into a create.

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

realUpdate

protected void realUpdate(WSUser user,
                          WavesetResult result)
                   throws WavesetException
Update one account.

Overrides:
realUpdate in class ResourceAdapterBase
Throws:
WavesetException

updateAccounts

public WavesetResult updateAccounts(WSUser[] users)
                             throws WavesetException
Update multiple accounts.

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

checkDeleteAccount

public WavesetResult checkDeleteAccount(WSUser user)
                                 throws WavesetException
Check account deletion. We're only supposed to check connectivity. If the account doesn't exist, we ignore it silently.

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 an acocunt.

Overrides:
realDelete in class ResourceAdapterBase
Throws:
WavesetException

deleteAccounts

public WavesetResult deleteAccounts(WSUser[] users)
                             throws WavesetException
Delete multiple accounts.

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

realDisable

protected void realDisable(WSUser user,
                           WavesetResult result)
                    throws WavesetException
Disable an account

Overrides:
realDisable in class ResourceAdapterBase
Throws:
WavesetException

disableAccounts

public WavesetResult disableAccounts(WSUser[] users)
                              throws WavesetException
Disable multiple accounts.

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

realEnable

protected void realEnable(WSUser user,
                          WavesetResult result)
                   throws WavesetException
Enable an account

Overrides:
realEnable in class ResourceAdapterBase
Throws:
WavesetException

enableAccounts

public WavesetResult enableAccounts(WSUser[] users)
                             throws WavesetException
Enable multiple accounts.

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

authenticate

public WavesetResult authenticate(java.util.HashMap loginInfo)
                           throws WavesetException
Perform authentication with a set of credentials. Get the expected credential names from what the resource believes is should have don't assume that we use what the XMLResourceAdapter prototype specifies. This allows us to more easily simulate resources by leaving the Resource definition alone, and just changing the implementation class to XmlResourceAdapter or SimulatedResourceAdapter.

Specified by:
authenticate in interface ResourceAdapter
Specified by:
authenticate 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 ResourceAdapterBase

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 ResourceAdapterBase

setResource

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

getAccountAttributes

public WSAttributes getAccountAttributes(java.lang.String identity)
                                  throws WavesetException
Obsolete interface, no longer supported.

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

getAccountAttributes

public WSUser getAccountAttributes(WSUser src)
                            throws WavesetException
Obsolete interface, no longer supported.

Throws:
WavesetException

getAllAccounts

public java.util.List getAllAccounts()
                              throws WavesetException
Obsolete interface, no longer supported.

Specified by:
getAllAccounts in interface ResourceAdapter
Overrides:
getAllAccounts 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