com.waveset.adapter
Class SQLServerResourceAdapter

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

public class SQLServerResourceAdapter
extends JdbcResourceAdapter


Nested Class Summary
static class SQLServerResourceAdapter.SQLServerAccountIterator
          The implementation of the AccountIterator returned by getAccountIterator.
static class SQLServerResourceAdapter.SQLServerAccountIterator2
          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
static java.lang.String AA_ROLES
          The current role(s) assigned to this account.
static java.lang.String code_id
           
static java.lang.String DEFAULT_DRIVER
          The default driver.
static java.lang.String DEFAULT_TEMPLATE
          The default URL template
static int ERR_INVALID_USER
          SQL Server error code indicating that a user does not exist.
static java.lang.String RA_DELETE_OWNER
          Enables use of the sp_changeobjectowner to reassign objects owned by a user when it is deleted.
static java.lang.String RA_ROLES
          The optional role(s) to assign to accounts.
static java.lang.String TYPE_NAME
           
 
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
SQLServerResourceAdapter()
          Create an adapater instance, without a resource.
SQLServerResourceAdapter(Resource res, ObjectCache cache)
          Create an adapter instance for a resource.
 
Method Summary
 WavesetResult authenticate(java.util.HashMap loginInfo)
          Check to see if a user account and password is valid.
 WSUser buildUser(java.lang.String id)
          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.
 WavesetResult checkUpdateAccount(WSUser user)
          Check the ability to perform an account update.
 Resource createPrototypeResource()
          Create the prototype instance.
 void createRole(java.lang.String name)
           
 void execSQL(java.lang.String stmt)
          Execute a SQL statement.
 WSAttributes getAccountAttributes(java.lang.String accountIdentity)
          Deprecated method, use getUser instead.
 AccountIterator getAccountIterator()
          Return an iterator that will iterate over all the accounts on a resource.
 WSUser getUser(WSUser user)
          Public adapter method to get the current user information.
 java.util.ArrayList listAllObjects(java.lang.String objectType, java.util.Map options, java.lang.String runAsUser, EncryptedData runAsPassword)
          This method will return a list of object names of the specified object type.
protected  void realCreate(WSUser user, WavesetResult result)
          Create the account for real.
protected  void realDelete(WSUser user, WavesetResult result)
          Delete the account for real.
protected  void realUpdate(WSUser user, WavesetResult result)
          Do the account update for real.
 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.
 
Methods inherited from class com.waveset.adapter.JdbcResourceAdapter
addAttributeValue, addQuoted, 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, 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, listObjects, listObjects, listObjectsOfType, lookupAction, lookupAction, lookupActions, namesEqual, objectClassesMatchType, println, realDisable, realEnable, restoreResourceObjectClassAttr, run, run, runResourceAttributeJavascriptAction, scan, setCache, setContext, setDisabled, setFromResource, setResource, setResourceObjectClassAttr, setResourceOptionAttrs, startConnectionWrapper, supportsAccountActions, supportsAccountDisable, 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

TYPE_NAME

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

code_id

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

RA_ROLES

public static final java.lang.String RA_ROLES
The optional role(s) to assign to accounts. NOTE: In the interest of reducing the number of resource attributes, we're no longer exposing this. Account attribute AA_ROLES must be used instead. The code is still in place to support this, but it is no longer in the prototype.

See Also:
Constant Field Values

AA_ROLES

public static final java.lang.String AA_ROLES
The current role(s) assigned to this account.

See Also:
Constant Field Values

RA_DELETE_OWNER

public static final java.lang.String RA_DELETE_OWNER
Enables use of the sp_changeobjectowner to reassign objects owned by a user when it is deleted.

See Also:
Constant Field Values

DEFAULT_DRIVER

public static final java.lang.String DEFAULT_DRIVER
The default driver.

See Also:
Constant Field Values

DEFAULT_TEMPLATE

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

See Also:
Constant Field Values

ERR_INVALID_USER

public static final int ERR_INVALID_USER
SQL Server error code indicating that a user does not exist.

See Also:
Constant Field Values
Constructor Detail

SQLServerResourceAdapter

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


SQLServerResourceAdapter

public SQLServerResourceAdapter()
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 check for the existance of the user.

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 the account for real.

Overrides:
realCreate in class ResourceAdapterBase
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
Do the account update for real.

This will get complex when we support roles. Role modifications are not updates to the user object, we have to update the membership lists of each affected role.

Overrides:
realUpdate in class ResourceAdapterBase
Throws:
WavesetException

checkDeleteAccount

public WavesetResult checkDeleteAccount(WSUser user)
                                 throws WavesetException
Check account deletion. We don't care if the count 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. We want to tolerate cases where the user and/or login object do not actually exist, but we need to propagate errors deleting them if they do. This requires that we query before deleting since there doesn't appear to be a reliable way to test error return codes. Invoking sp_revokedbaccess with an invalid user yields SQLState "S1000", vendor code 15008, text "User 'foo' does not exist in the current database." But I don't think we can test vendor codes, since we might use a different JDBC driver someday. If the vendor code came from SQL Server it might be ok. You do not need to remove the user from any roles before deleting, the role references get cleaned up automatically, (they're probably just stored on the user object itself, not the other way around).

Overrides:
realDelete in class ResourceAdapterBase
Throws:
WavesetException

getUser

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

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

buildUser

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


getAccountAttributes

public WSAttributes getAccountAttributes(java.lang.String accountIdentity)
                                  throws WavesetException
Deprecated method, use getUser instead.

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

listAllObjects

public java.util.ArrayList listAllObjects(java.lang.String objectType,
                                          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:
objectType - - 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

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
Check to see if a user account and password is valid.

Note that because of the distinction between an "login object" and a "securuty account", you may be able to login to SQL Server but still not be able to do anything within the database.

We're only checking for valid logins, we don't care if there is a security account since its possible they might want to set up a database just to handle authentication.

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

createRole

public void createRole(java.lang.String name)
                throws WavesetException
Throws:
WavesetException

execSQL

public void execSQL(java.lang.String stmt)
             throws WavesetException
Execute a SQL statement. Used by the unit tests to create tables to test cascaded delete. Should this be something all JdbcResourceAdapters support?

Throws:
WavesetException