Overview Developing Custom Java Plug-Ins

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 Customizing Oracle Virtual Directory 18-7 the plug-in is skipped. Similarly, if the addonCreate option is set to false, the plug-in is skipped. Example 18–2 Example Method Checking for ignoreOnModify Option Determines if a plugin is available for the current chain param chain param base return True or False if available for a particular chain base public boolean availableChain chain, DirectoryString base { if chain.getOperationType == Chain.ADD_OP this.addOnCreate { return false; } else if chain.getOperationType == Chain.MOD_OP this.ignoreOnModify { return false; } else { return true; } } If the available method returns as true, the operation portion of the request will be executed.

18.3.3.3 Operation Plug-In Implementation Point

The final implementation point is operation implementations. Consider the following code implementation of a bind operation in Example 18–3 : Example 18–3 Example Bind Operation Implementation Moves through the bind operations chain param chain The current chain param dn The DN for the user param password The users password param result The result of the bind public void bindChain chain, Credentials creds, DirectoryString dn, BinarySyntax password, Bool result throws DirectoryException, ChainException { Pre-event processing calls the next plug-in in the chain or comment out if a handler try { chain.nextBindcreds, dn, password, result; } catch DirectoryException e { throw e; } Post-event processing