Configuring Custom Adapters Click Next. The Settings screen appears.

Customizing Oracle Virtual Directory 18-5 virtual directory to have a chance to further process the request through other plug-ins, you would call the chain.nextAdd method. Most plug-in methods have corresponding chain.nextXXX methods. If you do not want to allow further processing of the request by plug-ins, you can omit the chain.nextXXX call.

18.3.3 Plug-In Implementation Points

Before you can build a custom plug-in, you must decide whether to implement the com.octetstring.vde.chain.Plugin interface or extend the com.octetstring.vde.chain.BasePlugin class. The BasePlugin class is a convenience that allows a plug-in developer to only implement the methods for operations to be handled by the plug-in. The example plug-in in this chapter extends the BasePlugin class to simplify the implementation. The sections in this topic describe the Oracle Virtual Directory plug-in implementation points, including: ■ Configuration, Startup, and Shutdown Plug-In Implementation Points ■ Availability Plug-In Implementation Point ■ Operation Plug-In Implementation Point

18.3.3.1 Configuration, Startup, and Shutdown Plug-In Implementation Points

Configuration is the first plug-in implementation point. Plug-ins are configured using a set of simple name and value pairs provided by the Oracle Virtual Directory configuration system. The pairs are provided to the plug-in developer through the params argument to the init method of the plug-in. The example plug-in in this chapter includes the following configuration options: ■ countAttribute: An attribute to be attached to all user entries that store the bad password count. ■ addOnCreate: Boolean value set to true if the plug-in adds this attribute when a user is created. ■ objectClassForAdd: The object classes that represent users to which the attribute is added. ■ ignoreOnModify: Boolean value, set to true if modify requests on the countAttribute should be ignored. The configuration options listed above are picked-up at the life cycle methods, which is the second implementation point. The init method is called on the initialization of the plug-in at server startup and the destroy method is called when the plug-in is being shutdown. Example 18–1 shows an example init method: Example 18–1 Example init Method Passes initialization information to the Plug-in param initParams Hashmap of keyvalue pairs specified in initial config param name The name specified in the config for this Plug-in Note: The adapter type is irrelevant to the plug-ins, as plug-ins can be added to any type of adapter. 18-6 Oracle Fusion Middleware Administrators Guide for Oracle Virtual Directory public void initPluginInit initParams, String name throws ChainException { the countAttribute parameter is required if initParams.containsKeyBadPasswordCount.CONFIG_COUNT_ATTRIBUTE { throw new ChainExceptionname + : The + BadPasswordCount.CONFIG_COUNT_ATTRIBUTE + attribute is required; } this.countAttribute = new DirectoryStringinitParams .getBadPasswordCount.CONFIG_COUNT_ATTRIBUTE; this.attribType = SchemaChecker.getInstance.getAttributeType this.countAttribute; determine if add on create this.addOnCreate = initParams .containsKeyBadPasswordCount.CONFIG_ADD_ON_CREATE initParams.getBadPasswordCount.CONFIG_ADD_ON_CREATE .equalsIgnoreCasetrue; if this.addOnCreate { if this.addOnCreate initParams .containsKeyBadPasswordCount.CONFIG_OBJECTCLASS_FOR_ADD { throw new ChainExceptionname + : When adding count attribute, the parameter + BadPasswordCount.CONFIG_OBJECTCLASS_FOR_ADD + is required; } String[] objectClasses = initParams .getValsBadPasswordCount.CONFIG_OBJECTCLASS_FOR_ADD; this.objectClasses = new HashSet; for int i = 0, m = objectClasses.length; i m; i++ { this.objectClasses.addnew DirectoryStringobjectClasses[i]; } } else { this.addOnCreate = false; } logger.infoAdding on create : + this.addOnCreate; determine if the modify operation should be ignored this.ignoreModify = initParams .containsKeyBadPasswordCount.CONFIG_IGNORE_MODIFY initParams.getBadPasswordCount.CONFIG_IGNORE_MODIFY .equalsIgnoreCasetrue; The method in Example 18–1 checks the initialization parameters to setup the plug-in. If there is not enough configuration information, then the plug-in throws an exception, causing the plug-in to not be configured for operational use by the server. You are not required to implement the destroy method unless there is a need to release any connections or shutdown any services.

18.3.3.2 Availability Plug-In Implementation Point

The available implementation point follows the configuration and startup and shutdown implementation points. The available method is called before each plug-in can be called for a particular LDAP operation. If the available method returns as true, then the plug-in is executed. In Example 18–2 , the available method checks for the existence of the ignoreOnModify option in the Request object. If it is defined, then