Class AbstractScriptedConnector<C extends AbstractScriptedConfiguration>
- All Implemented Interfaces:
APIOperation
,ResolveUsernameApiOp
,Connector
,AuthenticateOp
,CreateOp
,DeleteOp
,SchemaOp
,ScriptOnConnectorOp
,SearchOp<Map<String,
,Object>> SPIOperation
,SyncOp
,TestOp
,UpdateAttributeValuesOp
,UpdateDeltaOp
,UpdateOp
-
Field Summary
Fields inherited from interface org.identityconnectors.framework.api.operations.APIOperation
NO_TIMEOUT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddAttributeValues
(ObjectClass objectClass, Uid uid, Set<Attribute> valuesToAdd, OperationOptions options) Update the object specified by theObjectClass
andUid
, adding to the current values of each attribute the values provided.authenticate
(ObjectClass objectClass, String username, GuardedString password, OperationOptions options) Simple authentication with two parameters presumed to be user name and password.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
.void
delete
(ObjectClass objectClass, Uid uid, OperationOptions options) TheConnector
developer is responsible for calling the native delete methods to remove the object specified by its unique id.void
dispose()
Dispose of any resources theConnector
uses.void
executeQuery
(ObjectClass objectClass, Map<String, Object> 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)
.Return the configuration that was passed toConnector.init(Configuration)
.getLatestSyncToken
(ObjectClass objectClass) Returns the token corresponding to the most recent synchronization event.void
init
(Configuration cfg) Initialize the connector with its configuration.removeAttributeValues
(ObjectClass objectClass, Uid uid, Set<Attribute> valuesToRemove, OperationOptions options) Update the object specified by theObjectClass
andUid
, removing from the current values of each attribute the values provided.resolveUsername
(ObjectClass objectClass, String username, OperationOptions options) Resolve the givenauthentication
username to the correspondingUid
.static final String
resolveVariables
(String input) runScriptOnConnector
(ScriptContext request, OperationOptions options) Runs the script request.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.void
test()
Tests theConfiguration
with the connector.update
(ObjectClass objectClass, Uid uid, Set<Attribute> replaceAttributes, OperationOptions options) Update the object specified by theObjectClass
andUid
, replacing the current values of each attribute with the values provided.updateDelta
(ObjectClass objectClass, Uid uid, Set<AttributeDelta> modifications, OperationOptions options) Update the object specified by theObjectClass
andUid
, modifying the values according to the attribute deltas.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.identityconnectors.framework.spi.operations.SearchOp
createFilterTranslator
-
Field Details
-
LOG
-
config
-
-
Constructor Details
-
AbstractScriptedConnector
public AbstractScriptedConnector()
-
-
Method Details
-
resolveVariables
-
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. -
init
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
.
-
buildArguments
-
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.
-
update
public Uid update(ObjectClass objectClass, Uid uid, Set<Attribute> replaceAttributes, OperationOptions options) Description copied from interface:UpdateOp
Update the object specified by theObjectClass
andUid
, replacing the current values of each attribute with the values provided.For each input attribute, replace all of the current values of that attribute in the target object with the values of that attribute.
If the target object does not currently contain an attribute that the input set contains, then add this attribute (along with the provided values) to the target object.
If the value of an attribute in the input set is
null
, then do one of the following, depending on which is most appropriate for the target:- If possible, remove that attribute from the target object entirely.
- Otherwise, replace all of the current values of that
attribute in the target object with a single value of
null
.
- Specified by:
update
in interfaceUpdateOp
- Parameters:
objectClass
- the type of object to modify. Will never be null.uid
- the uid of the object to modify. Will never be null.replaceAttributes
- set of newAttribute
. the values in this set represent the new, merged values to be applied to the object. This set may also includeoperational attributes
. Will never be null.options
- additional options that impact the way this operation is run. Will never be null.- Returns:
- the
Uid
of the updated object in case the update changes the formation of the unique identifier.
-
updateDelta
public Set<AttributeDelta> updateDelta(ObjectClass objectClass, Uid uid, Set<AttributeDelta> modifications, OperationOptions options) Description copied from interface:UpdateDeltaOp
Update the object specified by the
ObjectClass
andUid
, modifying the values according to the attribute deltas.The connector is supposed to return side-effect changes as a return value from this operation. E.g. if the modification of some of the attributes changed other attribute then these changes should be returned. The connector must return a new value of primary identifier (Uid) if it is changed. But the connector should return other changes only if the connector has an efficient way how to detect them. Connector is not supposed to return all side-effect changes if it does not know about them or if additional operation is required to fetch them.
- Specified by:
updateDelta
in interfaceUpdateDeltaOp
- Parameters:
objectClass
- the type of object to modify. Will never be null.uid
- the uid of the object to modify. Will never be null.modifications
- set of attribute deltas. Each delta describes modification of one attribute. Each attribute will be in the set at most once. The set will never be null.options
- additional options that impact the way this operation is run. Will never be null.- Returns:
- the set of modifications that were a side-effect of the primary modifications specified in the modifications parameters.
-
addAttributeValues
public Uid addAttributeValues(ObjectClass objectClass, Uid uid, Set<Attribute> valuesToAdd, OperationOptions options) Description copied from interface:UpdateAttributeValuesOp
Update the object specified by theObjectClass
andUid
, adding to the current values of each attribute the values provided.For each attribute that the input set contains, add to the current values of that attribute in the target object all of the values of that attribute in the input set.
NOTE that this does not specify how to handle duplicate values. The general assumption for an attribute of a
ConnectorObject
is that the values for an attribute may contain duplicates. Therefore, in general simply append the provided values to the current value for each attribute.- Specified by:
addAttributeValues
in interfaceUpdateAttributeValuesOp
- Parameters:
objectClass
- the type of object to modify. Will never be null.uid
- the uid of the object to modify. Will never be null.valuesToAdd
- set ofAttribute
deltas. The values for the attributes in this set represent the values to add to attributes in the object. merged. This set will never includeoperational attributes
. Will never be null.options
- additional options that impact the way this operation is run. Will never be null.- Returns:
- the
Uid
of the updated object in case the update changes the formation of the unique identifier.
-
removeAttributeValues
public Uid removeAttributeValues(ObjectClass objectClass, Uid uid, Set<Attribute> valuesToRemove, OperationOptions options) Description copied from interface:UpdateAttributeValuesOp
Update the object specified by theObjectClass
andUid
, removing from the current values of each attribute the values provided.For each attribute that the input set contains, remove from the current values of that attribute in the target object any value that matches one of the values of the attribute from the input set.
NOTE that this does not specify how to handle unmatched values. The general assumption for an attribute of a
ConnectorObject
is that the values for an attribute are merely representational state. Therefore, the implementer should simply ignore any provided value that does not match a current value of that attribute in the target object. Deleting an unmatched value should always succeed.- Specified by:
removeAttributeValues
in interfaceUpdateAttributeValuesOp
- Parameters:
objectClass
- the type of object to modify. Will never be null.uid
- the uid of the object to modify. Will never be null.valuesToRemove
- set ofAttribute
deltas. The values for the attributes in this set represent the values to remove from attributes in the object. merged. This set will never includeoperational attributes
. Will never be null.options
- additional options that impact the way this operation is run. Will never be null..- Returns:
- the
Uid
of the updated object in case the update changes the formation of the unique identifier.
-
delete
Description copied from interface:DeleteOp
TheConnector
developer is responsible for calling the native delete methods to remove the object specified by its unique id.- Specified by:
delete
in interfaceDeleteOp
- Parameters:
objectClass
- type of object to delete.uid
- The unique id that specifies the object to delete.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.
-
authenticate
public Uid authenticate(ObjectClass objectClass, String username, GuardedString password, OperationOptions options) Description copied from interface:AuthenticateOp
Simple authentication with two parameters presumed to be user name and password. TheConnector
developer is expected to attempt to authenticate these credentials natively. If the authentication fails the developer should throw a type ofRuntimeException
eitherIllegalArgumentException
or if a native exception is available and if its of typeRuntimeException
simple throw it. If the native exception is not aRuntimeException
wrap it in one and throw it. This will provide the most detail for logging problem and failed attempts.The developer is of course encourage to try and throw the most informative exception as possible. In that regards there are several exceptions provided in the exceptions package. For instance one of the most common is
InvalidPasswordException
.- Specified by:
authenticate
in interfaceAuthenticateOp
- Parameters:
objectClass
- The object class to use for authenticate. Will typically be an account. Must not be null.username
- the name based credential for authentication.password
- the password based credential for authentication.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:
- Uid The uid of the account that was used to authenticate
-
resolveUsername
Description copied from interface:ResolveUsernameApiOp
Resolve the givenauthentication
username to the correspondingUid
. TheUid
is the one thatAuthenticationApiOp.authenticate(org.identityconnectors.framework.common.objects.ObjectClass, java.lang.String, org.identityconnectors.common.security.GuardedString, org.identityconnectors.framework.common.objects.OperationOptions)
would return in case of a successful authentication.- Specified by:
resolveUsername
in interfaceResolveUsernameApiOp
- Parameters:
objectClass
- The object class to use for authenticate. Will typically be an account. Must not be null.username
- string that represents the account or user id.options
- additional options that impact the way this operation is run. May be null.- Returns:
- Uid The uid of the account that would be used to authenticate.
-
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. -
executeQuery
public void executeQuery(ObjectClass objectClass, Map<String, Object> 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<C extends AbstractScriptedConfiguration>
- 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
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
.
-
runScriptOnConnector
Description copied from interface:ScriptOnConnectorOp
Runs the script request.- Specified by:
runScriptOnConnector
in interfaceScriptOnConnectorOp
- Parameters:
request
- The script and arguments to run.options
- Additional options that control how the script is run.- Returns:
- The result of the script. The return type must be a type that the
framework supports for serialization. See
ObjectSerializerFactory
for a list of supported types.
-
test
public void test()Description copied from interface:TestOp
Tests theConfiguration
with the connector.
-