Class TstConnector
- java.lang.Object
-
- org.identityconnectors.testconnector.TstConnector
-
- All Implemented Interfaces:
Connector
,CreateOp
,LiveSyncOp
,SchemaOp
,SearchOp<String>
,SPIOperation
,SyncOp
,PoolableConnector
public class TstConnector extends Object implements CreateOp, PoolableConnector, SchemaOp, SearchOp<String>, SyncOp, LiveSyncOp
-
-
Field Summary
Fields Modifier and Type Field Description static String
ACCESS_ATTR_NAME
static String
ACCESS_CLASS_NAME
static String
GROUP_1_NAME
static String
GROUP_1_UID
static String
GROUP_2_NAME
static String
GROUP_2_UID
static String
GROUP_ATTR_NAME
static String
GROUP_CLASS_NAME
static String
GROUP_MEMBERSHIP_REFERENCE_TYPE_NAME
static String
MEMBER_OF_ATTR_NAME
static String
MEMBERS_ATTR_NAME
static String
USER_100_NAME
static String
USER_100_UID
static String
USER_101_NAME
static String
USER_101_UID
static String
USER_CLASS_NAME
-
Constructor Summary
Constructors Constructor Description TstConnector()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkAlive()
Checks if the connector is still alive.static void
checkClassLoader()
String
concat(String s1, String s2)
Used by the script testsUid
create(ObjectClass objectClass, Set<Attribute> createAttributes, OperationOptions options)
TheConnector
developer is responsible for taking the attributes given (which always includes theObjectClass
) and create an object and itsUid
.FilterTranslator<String>
createFilterTranslator(ObjectClass objectClass, OperationOptions options)
Creates a filter translator that will translate a specifiedFilter
into one or more native queries.void
dispose()
Dispose of any resources theConnector
uses.void
executeQuery(ObjectClass objectClass, String query, ResultsHandler handler, OperationOptions options)
ConnectorFacade calls this method once for each native query that theSearchOp.createFilterTranslator(ObjectClass, OperationOptions)
produces in response to theFilter
passed intoSearchApiOp.search(org.identityconnectors.framework.common.objects.ObjectClass, org.identityconnectors.framework.common.objects.filter.Filter, org.identityconnectors.framework.common.objects.ResultsHandler, org.identityconnectors.framework.common.objects.OperationOptions)
.Configuration
getConfiguration()
Return the configuration that was passed toConnector.init(Configuration)
.SyncToken
getLatestSyncToken(ObjectClass objectClass)
Returns the token corresponding to the most recent synchronization event.void
init(Configuration cfg)
Initialize the connector with its configuration.void
livesync(ObjectClass objectClass, LiveSyncResultsHandler handler, OperationOptions options)
Request synchronization events--i.e., native changes to target objects.Schema
schema()
Describes the types of objects thisConnector
supports.void
sync(ObjectClass objectClass, SyncToken token, SyncResultsHandler handler, OperationOptions options)
Request synchronization events--i.e., native changes to target objects.static ObjectClass
userObjectClass()
-
-
-
Field Detail
-
USER_CLASS_NAME
public static final String USER_CLASS_NAME
- See Also:
- Constant Field Values
-
GROUP_CLASS_NAME
public static final String GROUP_CLASS_NAME
- See Also:
- Constant Field Values
-
ACCESS_CLASS_NAME
public static final String ACCESS_CLASS_NAME
- See Also:
- Constant Field Values
-
MEMBER_OF_ATTR_NAME
public static final String MEMBER_OF_ATTR_NAME
- See Also:
- Constant Field Values
-
MEMBERS_ATTR_NAME
public static final String MEMBERS_ATTR_NAME
- See Also:
- Constant Field Values
-
ACCESS_ATTR_NAME
public static final String ACCESS_ATTR_NAME
- See Also:
- Constant Field Values
-
GROUP_ATTR_NAME
public static final String GROUP_ATTR_NAME
- See Also:
- Constant Field Values
-
GROUP_MEMBERSHIP_REFERENCE_TYPE_NAME
public static final String GROUP_MEMBERSHIP_REFERENCE_TYPE_NAME
- See Also:
- Constant Field Values
-
USER_100_UID
public static final String USER_100_UID
- See Also:
- Constant Field Values
-
USER_101_UID
public static final String USER_101_UID
- See Also:
- Constant Field Values
-
USER_100_NAME
public static final String USER_100_NAME
- See Also:
- Constant Field Values
-
USER_101_NAME
public static final String USER_101_NAME
- See Also:
- Constant Field Values
-
GROUP_1_UID
public static final String GROUP_1_UID
- See Also:
- Constant Field Values
-
GROUP_2_UID
public static final String GROUP_2_UID
- See Also:
- Constant Field Values
-
GROUP_1_NAME
public static final String GROUP_1_NAME
- See Also:
- Constant Field Values
-
GROUP_2_NAME
public static final String GROUP_2_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
checkClassLoader
public static void checkClassLoader()
-
create
public Uid create(ObjectClass objectClass, Set<Attribute> createAttributes, OperationOptions options)
Description copied from interface:CreateOp
TheConnector
developer is responsible for taking the attributes given (which always includes theObjectClass
) and create an object and itsUid
. TheConnector
developer must return theUid
so that the caller can refer to the created object.*Note: There will never be a
Uid
passed in with the attribute set for this method. If the resource supports some sort of mutableUid
, you should create your own resource-specific attribute for it, such as unix_uid.- Specified by:
create
in interfaceCreateOp
- Parameters:
objectClass
- the type of object to create. Will never be null.createAttributes
- includes all the attributes necessary to create the resource object including theObjectClass
attribute andName
attribute.options
- additional options that impact the way this operation is run. If the caller passes null, the framework will convert this into an empty set of options, so SPI need not worry about this ever being null.- Returns:
- the unique id for the object that is created. For instance in LDAP this would be the 'dn', for a database this would be the primary key, and for 'ActiveDirectory' this would be the GUID.
-
init
public void init(Configuration cfg)
Description copied from interface:Connector
Initialize the connector with its configuration. For instance in a JDBCConnector
this would include the database URL, password, and user.- Specified by:
init
in interfaceConnector
- Parameters:
cfg
- instance of theConfiguration
object implemented by theConnector
developer and populated with information in order to initialize theConnector
.
-
getConfiguration
public Configuration getConfiguration()
Description copied from interface:Connector
Return the configuration that was passed toConnector.init(Configuration)
.- Specified by:
getConfiguration
in interfaceConnector
- Returns:
- The configuration that was passed to
Connector.init(Configuration)
.
-
dispose
public void dispose()
Description copied from interface:Connector
Dispose of any resources theConnector
uses.
-
checkAlive
public void checkAlive()
Description copied from interface:PoolableConnector
Checks if the connector is still alive.A connector can spend a large amount of time in the pool before being used. This method is intended to check if the connector is alive and operations can be invoked on it (for instance, an implementation would check that the connector's physical connection to the resource has not timed out).
The major difference between this method and
TestOp.test()
is that this method must do only the minimum that is necessary to check that the connector is still alive.TestOp.test()
does a more thorough check of the environment specified in the Configuration, and can therefore be much slower.This method can be called often. Implementations should do their best to keep this method fast.
- Specified by:
checkAlive
in interfacePoolableConnector
-
createFilterTranslator
public FilterTranslator<String> createFilterTranslator(ObjectClass objectClass, OperationOptions options)
Description copied from interface:SearchOp
Creates a filter translator that will translate a specifiedFilter
into one or more native queries. Each of these native queries will be passed subsequently intoexecuteQuery()
.- Specified by:
createFilterTranslator
in interfaceSearchOp<String>
- Parameters:
objectClass
- The object class for the search. Will never be null.options
- additional options that impact the way this operation is run. If the caller passes null, the framework will convert this into an empty set of options, so SPI need not worry about this ever being null.- Returns:
- A filter translator. This must not be
null
. Anull
return value will cause the API (SearchApiOp
) to throwNullPointerException
.
-
executeQuery
public void executeQuery(ObjectClass objectClass, String query, ResultsHandler handler, OperationOptions options)
Description copied from interface:SearchOp
ConnectorFacade calls this method once for each native query that theSearchOp.createFilterTranslator(ObjectClass, OperationOptions)
produces in response to theFilter
passed intoSearchApiOp.search(org.identityconnectors.framework.common.objects.ObjectClass, org.identityconnectors.framework.common.objects.filter.Filter, org.identityconnectors.framework.common.objects.ResultsHandler, org.identityconnectors.framework.common.objects.OperationOptions)
. If theFilterTranslator
produces more than one native query, then ConnectorFacade will automatically merge the results from each query and eliminate any duplicates. NOTE that this implies an in-memory data structure that holds a set of Uid values, so memory usage in the event of multiple queries will be O(N) where N is the number of results. This is why it is important that the FilterTranslator for each Connector implement OR if possible.- Specified by:
executeQuery
in interfaceSearchOp<String>
- Parameters:
objectClass
- The object class for the search. Will never be null.query
- The native query to run. A value of null means "return every instance of the given object class".handler
- Results should be returned to this handleroptions
- Additional options that impact the way this operation is run. If the caller passes null, the framework will convert this into an empty set of options, so SPI need not guard against options being null.
-
sync
public void sync(ObjectClass objectClass, SyncToken token, SyncResultsHandler handler, OperationOptions options)
Description copied from interface:SyncOp
Request synchronization events--i.e., native changes to target objects.This method will call the specified handler once to pass back each matching synchronization event. Once this method returns, this method will no longer invoke the specified handler.
Each synchronization event contains a token that can be used to resume reading events starting from that point in the event stream. In typical usage, a client will save the token from the final synchronization event that was received from one invocation of this
sync()
method and then pass that token into that client's next call to thissync()
method. This allows a client to "pick up where he left off" in receiving synchronization events. However, a client can pass the token from any synchronization event into a subsequent invocation of thissync()
method. This will return synchronization events (that represent native changes that occurred) immediately subsequent to the event from which the client obtained the token.A client that wants to read synchronization events "starting now" can call
SyncOp.getLatestSyncToken(org.identityconnectors.framework.common.objects.ObjectClass)
and then pass that token into thissync()
method.- Specified by:
sync
in interfaceSyncOp
- Parameters:
objectClass
- The class of object for which to return synchronization events. Must not be null.token
- The token representing the last token from the previous sync. TheSyncResultsHandler
will return any number of SyncDelta objects, each of which contains a token. Should benull
if this is the client's first call to thesync()
method for this connector.handler
- The result handler. Must not be null.options
- Options that affect the way this operation is run. If the caller passesnull
, the framework will convert this into an empty set of options, so an implementation need not guard against this being null.
-
getLatestSyncToken
public SyncToken getLatestSyncToken(ObjectClass objectClass)
Description copied from interface:SyncOp
Returns the token corresponding to the most recent synchronization event.An application that wants to receive synchronization events "starting now" --i.e., wants to receive only native changes that occur after this method is called-- should call this method and then pass the resulting token into the sync() method.
- Specified by:
getLatestSyncToken
in interfaceSyncOp
- Parameters:
objectClass
- the class of object for which to find the most recent synchronization event (if any). Must not be null.- Returns:
- A token if synchronization events exist; otherwise
null
.
-
livesync
public void livesync(ObjectClass objectClass, LiveSyncResultsHandler handler, OperationOptions options)
Description copied from interface:LiveSyncOp
Request synchronization events--i.e., native changes to target objects.This method will call the specified handler once to pass back each matching synchronization event. Once this method returns, this method will no longer invoke the specified handler.
- Specified by:
livesync
in interfaceLiveSyncOp
- Parameters:
objectClass
- The class of object for which to return synchronization events. Must not be null.handler
- The result handler. Must not be null.options
- Options that affect the way this operation is run. If the caller passesnull
, the framework will convert this into an empty set of options, so an implementation need not guard against this being null.
-
schema
public Schema schema()
Description copied from interface:SchemaOp
Describes the types of objects thisConnector
supports. This method is considered an operation since determining supported objects may require configuration information and allows this determination to be dynamic.The special
Uid
attribute should never appear in the schema, as it is not a true attribute of an object, rather a reference to it. If your resource object-class has a writable unique id attribute that is different than itsName
, then your schema should contain a resource-specific attribute that represents this unique id. For example, a Unix account object might contain unix_uid.
-
userObjectClass
public static ObjectClass userObjectClass()
-
-