Class AbstractScriptedConnector<C extends AbstractScriptedConfiguration>

java.lang.Object
net.tirasa.connid.commons.scripted.AbstractScriptedConnector<C>
All Implemented Interfaces:
APIOperation, ResolveUsernameApiOp, Connector, AuthenticateOp, CreateOp, DeleteOp, SchemaOp, ScriptOnConnectorOp, SearchOp<Map<String,Object>>, SPIOperation, SyncOp, TestOp, UpdateAttributeValuesOp, UpdateDeltaOp, UpdateOp

  • Field Details

  • Constructor Details

    • AbstractScriptedConnector

      public AbstractScriptedConnector()
  • Method Details

    • resolveVariables

      public static final String resolveVariables(String input)
    • getConfiguration

      public C getConfiguration()
      Description copied from interface: Connector
      Return the configuration that was passed to Connector.init(Configuration).
      Specified by:
      getConfiguration in interface Connector
      Returns:
      The configuration that was passed to Connector.init(Configuration).
    • dispose

      public void dispose()
      Description copied from interface: Connector
      Dispose of any resources the Connector uses.
      Specified by:
      dispose in interface Connector
    • init

      public void init(Configuration cfg)
      Description copied from interface: Connector
      Initialize the connector with its configuration. For instance in a JDBC Connector this would include the database URL, password, and user.
      Specified by:
      init in interface Connector
      Parameters:
      cfg - instance of the Configuration object implemented by the Connector developer and populated with information in order to initialize the Connector.
    • buildArguments

      protected abstract Map<String,Object> buildArguments()
    • create

      public Uid create(ObjectClass objectClass, Set<Attribute> createAttributes, OperationOptions options)
      Description copied from interface: CreateOp
      The Connector developer is responsible for taking the attributes given (which always includes the ObjectClass) and create an object and its Uid. The Connector developer must return the Uid 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 mutable Uid, you should create your own resource-specific attribute for it, such as unix_uid.

      Specified by:
      create in interface CreateOp
      Parameters:
      objectClass - the type of object to create. Will never be null.
      createAttributes - includes all the attributes necessary to create the resource object including the ObjectClass attribute and Name 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 the ObjectClass and Uid, 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 interface UpdateOp
      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 new Attribute. the values in this set represent the new, merged values to be applied to the object. This set may also include operational 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 and Uid, 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 interface UpdateDeltaOp
      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 the ObjectClass and Uid, 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 interface UpdateAttributeValuesOp
      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 of Attribute deltas. The values for the attributes in this set represent the values to add to attributes in the object. merged. This set will never include operational 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 the ObjectClass and Uid, 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 interface UpdateAttributeValuesOp
      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 of Attribute deltas. The values for the attributes in this set represent the values to remove from attributes in the object. merged. This set will never include operational 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

      public void delete(ObjectClass objectClass, Uid uid, OperationOptions options)
      Description copied from interface: DeleteOp
      The Connector developer is responsible for calling the native delete methods to remove the object specified by its unique id.
      Specified by:
      delete in interface DeleteOp
      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. The Connector developer is expected to attempt to authenticate these credentials natively. If the authentication fails the developer should throw a type of RuntimeException either IllegalArgumentException or if a native exception is available and if its of type RuntimeException simple throw it. If the native exception is not a RuntimeException 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 interface AuthenticateOp
      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

      public Uid resolveUsername(ObjectClass objectClass, String username, OperationOptions options)
      Description copied from interface: ResolveUsernameApiOp
      Specified by:
      resolveUsername in interface ResolveUsernameApiOp
      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

      public Schema schema()
      Description copied from interface: SchemaOp
      Describes the types of objects this Connector 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 its Name, then your schema should contain a resource-specific attribute that represents this unique id. For example, a Unix account object might contain unix_uid.

      Specified by:
      schema in interface SchemaOp
      Returns:
      basic schema supported by this Connector.
    • 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 the SearchOp.createFilterTranslator(ObjectClass, OperationOptions) produces in response to the Filter passed into SearchApiOp.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 the FilterTranslator 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 interface SearchOp<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 handler
      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 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 this sync() 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 this sync() 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 this sync() method.

      Specified by:
      sync in interface SyncOp
      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. The SyncResultsHandler will return any number of SyncDelta objects, each of which contains a token. Should be null if this is the client's first call to the sync() 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 passes null, 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 interface SyncOp
      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

      public Object runScriptOnConnector(ScriptContext request, OperationOptions options)
      Description copied from interface: ScriptOnConnectorOp
      Runs the script request.
      Specified by:
      runScriptOnConnector in interface ScriptOnConnectorOp
      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 the Configuration with the connector.
      Specified by:
      test in interface TestOp