| | |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | import java.util.Map; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | |
| | |
| | | |
| | | // The set of access loggers that have been registered with the server. It |
| | | // will initially be empty. |
| | | static CopyOnWriteArrayList<AccessLogPublisher> accessPublishers = |
| | | new CopyOnWriteArrayList<AccessLogPublisher>(); |
| | | static CopyOnWriteArrayList<AccessLogPublisher<?>> accessPublishers = |
| | | new CopyOnWriteArrayList<AccessLogPublisher<?>>(); |
| | | |
| | | // The singleton instance of this class for configuration purposes. |
| | | static final AccessLogger instance = new AccessLogger(); |
| | |
| | | * @param publisher The access log publisher to add. |
| | | */ |
| | | public synchronized static void addAccessLogPublisher( |
| | | AccessLogPublisher publisher) |
| | | AccessLogPublisher<?> publisher) |
| | | { |
| | | accessPublishers.add(publisher); |
| | | } |
| | |
| | | * @return The publisher that was removed or null if it was not found. |
| | | */ |
| | | public synchronized static boolean removeAccessLogPublisher( |
| | | AccessLogPublisher publisher) |
| | | AccessLogPublisher<?> publisher) |
| | | { |
| | | boolean removed = accessPublishers.remove(publisher); |
| | | |
| | |
| | | */ |
| | | public synchronized static void removeAllAccessLogPublishers() |
| | | { |
| | | for(AccessLogPublisher publisher : accessPublishers) |
| | | for(AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.close(); |
| | | } |
| | |
| | | |
| | | if(config.isEnabled()) |
| | | { |
| | | AccessLogPublisher AccessLogPublisher = getAccessPublisher(config); |
| | | AccessLogPublisher<?> AccessLogPublisher = getAccessPublisher(config); |
| | | |
| | | addAccessLogPublisher(AccessLogPublisher); |
| | | } |
| | |
| | | { |
| | | try |
| | | { |
| | | AccessLogPublisher AccessLogPublisher = getAccessPublisher(config); |
| | | AccessLogPublisher<?> AccessLogPublisher = getAccessPublisher(config); |
| | | |
| | | addAccessLogPublisher(AccessLogPublisher); |
| | | } |
| | |
| | | |
| | | DN dn = config.dn(); |
| | | |
| | | AccessLogPublisher accessLogPublisher = null; |
| | | for(AccessLogPublisher publisher : accessPublishers) |
| | | AccessLogPublisher<?> accessLogPublisher = null; |
| | | for(AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | if(publisher.getDN().equals(dn)) |
| | | { |
| | |
| | | { |
| | | DN dn = config.dn(); |
| | | |
| | | AccessLogPublisher accessLogPublisher = null; |
| | | for(AccessLogPublisher publisher : accessPublishers) |
| | | AccessLogPublisher<?> accessLogPublisher = null; |
| | | for(AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | if(publisher.getDN().equals(dn)) |
| | | { |
| | |
| | | ResultCode resultCode = ResultCode.SUCCESS; |
| | | boolean adminActionRequired = false; |
| | | |
| | | AccessLogPublisher accessLogPublisher = null; |
| | | for(AccessLogPublisher publisher : accessPublishers) |
| | | AccessLogPublisher<?> accessLogPublisher = null; |
| | | for(AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | if(publisher.getDN().equals(config.dn())) |
| | | { |
| | |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a DebugLogPublisher. |
| | | AccessLogPublisher publisher = null; |
| | | AccessLogPublisher<?> publisher = null; |
| | | Class<? extends AccessLogPublisher> theClass; |
| | | try { |
| | | theClass = pd.loadClass(className, AccessLogPublisher.class); |
| | |
| | | return true; |
| | | } |
| | | |
| | | private AccessLogPublisher getAccessPublisher(AccessLogPublisherCfg config) |
| | | private AccessLogPublisher<?> getAccessPublisher(AccessLogPublisherCfg config) |
| | | throws ConfigException { |
| | | String className = config.getJavaClass(); |
| | | AccessLogPublisherCfgDefn d = AccessLogPublisherCfgDefn.getInstance(); |
| | |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a AccessLogPublisher. |
| | | Class<? extends AccessLogPublisher> theClass; |
| | | AccessLogPublisher AccessLogPublisher; |
| | | AccessLogPublisher<?> AccessLogPublisher; |
| | | try { |
| | | theClass = pd.loadClass(className, AccessLogPublisher.class); |
| | | AccessLogPublisher = theClass.newInstance(); |
| | |
| | | */ |
| | | public static void logConnect(ClientConnection clientConnection) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logConnect(clientConnection); |
| | | } |
| | |
| | | DisconnectReason disconnectReason, |
| | | Message message) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logDisconnect(clientConnection, disconnectReason, message); |
| | | } |
| | |
| | | */ |
| | | public static void logAbandonRequest(AbandonOperation abandonOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logAbandonRequest(abandonOperation); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger containing additional |
| | | * information associated with the provided abandon operation. |
| | | * <p> |
| | | * This method will only be called after the request has been logged |
| | | * and before the response. Implementations can choose to ignore |
| | | * intermediate responses or filter them based on their category. |
| | | * |
| | | * @param abandonOperation |
| | | * The abandon operation containing the information to use |
| | | * to log the abandon request. |
| | | * @param category |
| | | * The category of the intermediate message. |
| | | * @param content |
| | | * The content of the intermediate message. This comprises |
| | | * of one or more key/value pairs which form the content of |
| | | * the intermediate message. |
| | | */ |
| | | public static void logAbandonIntermediateMessage( |
| | | AbandonOperation abandonOperation, String category, |
| | | Map<String, String> content) |
| | | { |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logAbandonIntermediateMessage(abandonOperation, |
| | | category, content); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the result of |
| | | * the provided abandon operation. |
| | | * |
| | |
| | | */ |
| | | public static void logAbandonResult(AbandonOperation abandonOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logAbandonResult(abandonOperation); |
| | | } |
| | |
| | | */ |
| | | public static void logAddRequest(AddOperation addOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logAddRequest(addOperation); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger containing additional |
| | | * information associated with the provided add operation. |
| | | * <p> |
| | | * This method will only be called after the request has been logged |
| | | * and before the response. Implementations can choose to ignore |
| | | * intermediate responses or filter them based on their category. |
| | | * |
| | | * @param addOperation |
| | | * The add operation containing the information to use |
| | | * to log the add request. |
| | | * @param category |
| | | * The category of the intermediate message. |
| | | * @param content |
| | | * The content of the intermediate message. This comprises |
| | | * of one or more key/value pairs which form the content of |
| | | * the intermediate message. |
| | | */ |
| | | public static void logAddIntermediateMessage( |
| | | AddOperation addOperation, String category, |
| | | Map<String, String> content) |
| | | { |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logAddIntermediateMessage(addOperation, |
| | | category, content); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the add |
| | | * response associated with the provided add operation. |
| | | * |
| | |
| | | */ |
| | | public static void logAddResponse(AddOperation addOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logAddResponse(addOperation); |
| | | } |
| | |
| | | */ |
| | | public static void logBindRequest(BindOperation bindOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logBindRequest(bindOperation); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger containing additional |
| | | * information associated with the provided bind operation. |
| | | * <p> |
| | | * This method will only be called after the request has been logged |
| | | * and before the response. Implementations can choose to ignore |
| | | * intermediate responses or filter them based on their category. |
| | | * |
| | | * @param bindOperation |
| | | * The bind operation containing the information to use |
| | | * to log the bind request. |
| | | * @param category |
| | | * The category of the intermediate message. |
| | | * @param content |
| | | * The content of the intermediate message. This comprises |
| | | * of one or more key/value pairs which form the content of |
| | | * the intermediate message. |
| | | */ |
| | | public static void logBindIntermediateMessage( |
| | | BindOperation bindOperation, String category, |
| | | Map<String, String> content) |
| | | { |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logBindIntermediateMessage(bindOperation, |
| | | category, content); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the bind |
| | | * response associated with the provided bind operation. |
| | | * |
| | |
| | | */ |
| | | public static void logBindResponse(BindOperation bindOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logBindResponse(bindOperation); |
| | | } |
| | |
| | | */ |
| | | public static void logCompareRequest(CompareOperation compareOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logCompareRequest(compareOperation); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger containing additional |
| | | * information associated with the provided compare operation. |
| | | * <p> |
| | | * This method will only be called after the request has been logged |
| | | * and before the response. Implementations can choose to ignore |
| | | * intermediate responses or filter them based on their category. |
| | | * |
| | | * @param compareOperation |
| | | * The compare operation containing the information to use |
| | | * to log the compare request. |
| | | * @param category |
| | | * The category of the intermediate message. |
| | | * @param content |
| | | * The content of the intermediate message. This comprises |
| | | * of one or more key/value pairs which form the content of |
| | | * the intermediate message. |
| | | */ |
| | | public static void logCompareIntermediateMessage( |
| | | CompareOperation compareOperation, String category, |
| | | Map<String, String> content) |
| | | { |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logCompareIntermediateMessage(compareOperation, |
| | | category, content); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the compare |
| | | * response associated with the provided compare operation. |
| | | * |
| | |
| | | */ |
| | | public static void logCompareResponse(CompareOperation compareOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logCompareResponse(compareOperation); |
| | | } |
| | |
| | | */ |
| | | public static void logDeleteRequest(DeleteOperation deleteOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logDeleteRequest(deleteOperation); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger containing additional |
| | | * information associated with the provided delete operation. |
| | | * <p> |
| | | * This method will only be called after the request has been logged |
| | | * and before the response. Implementations can choose to ignore |
| | | * intermediate responses or filter them based on their category. |
| | | * |
| | | * @param deleteOperation |
| | | * The delete operation containing the information to use |
| | | * to log the delete request. |
| | | * @param category |
| | | * The category of the intermediate message. |
| | | * @param content |
| | | * The content of the intermediate message. This comprises |
| | | * of one or more key/value pairs which form the content of |
| | | * the intermediate message. |
| | | */ |
| | | public static void logDeleteIntermediateMessage( |
| | | DeleteOperation deleteOperation, String category, |
| | | Map<String, String> content) |
| | | { |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logDeleteIntermediateMessage(deleteOperation, |
| | | category, content); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the delete |
| | | * response associated with the provided delete operation. |
| | | * |
| | |
| | | */ |
| | | public static void logDeleteResponse(DeleteOperation deleteOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logDeleteResponse(deleteOperation); |
| | | } |
| | |
| | | */ |
| | | public static void logExtendedRequest(ExtendedOperation extendedOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logExtendedRequest(extendedOperation); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger containing additional |
| | | * information associated with the provided extended operation. |
| | | * <p> |
| | | * This method will only be called after the request has been logged |
| | | * and before the response. Implementations can choose to ignore |
| | | * intermediate responses or filter them based on their category. |
| | | * |
| | | * @param extendedOperation |
| | | * The extended operation containing the information to use |
| | | * to log the extended request. |
| | | * @param category |
| | | * The category of the intermediate message. |
| | | * @param content |
| | | * The content of the intermediate message. This comprises |
| | | * of one or more key/value pairs which form the content of |
| | | * the intermediate message. |
| | | */ |
| | | public static void logExtendedIntermediateMessage( |
| | | ExtendedOperation extendedOperation, String category, |
| | | Map<String, String> content) |
| | | { |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logExtendedIntermediateMessage(extendedOperation, |
| | | category, content); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the extended |
| | | * response associated with the provided extended operation. |
| | | * |
| | |
| | | */ |
| | | public static void logExtendedResponse(ExtendedOperation extendedOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logExtendedResponse(extendedOperation); |
| | | } |
| | |
| | | */ |
| | | public static void logModifyRequest(ModifyOperation modifyOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logModifyRequest(modifyOperation); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger containing additional |
| | | * information associated with the provided modify operation. |
| | | * <p> |
| | | * This method will only be called after the request has been logged |
| | | * and before the response. Implementations can choose to ignore |
| | | * intermediate responses or filter them based on their category. |
| | | * |
| | | * @param modifyOperation |
| | | * The modify operation containing the information to use |
| | | * to log the modify request. |
| | | * @param category |
| | | * The category of the intermediate message. |
| | | * @param content |
| | | * The content of the intermediate message. This comprises |
| | | * of one or more key/value pairs which form the content of |
| | | * the intermediate message. |
| | | */ |
| | | public static void logModifyIntermediateMessage( |
| | | ModifyOperation modifyOperation, String category, |
| | | Map<String, String> content) |
| | | { |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logModifyIntermediateMessage(modifyOperation, |
| | | category, content); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the modify |
| | | * response associated with the provided modify operation. |
| | | * |
| | |
| | | */ |
| | | public static void logModifyResponse(ModifyOperation modifyOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logModifyResponse(modifyOperation); |
| | | } |
| | |
| | | */ |
| | | public static void logModifyDNRequest(ModifyDNOperation modifyDNOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logModifyDNRequest(modifyDNOperation); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger containing additional |
| | | * information associated with the provided modify DN operation. |
| | | * <p> |
| | | * This method will only be called after the request has been logged |
| | | * and before the response. Implementations can choose to ignore |
| | | * intermediate responses or filter them based on their category. |
| | | * |
| | | * @param modifyDNOperation |
| | | * The modify DN operation containing the information to use |
| | | * to log the modify DN request. |
| | | * @param category |
| | | * The category of the intermediate message. |
| | | * @param content |
| | | * The content of the intermediate message. This comprises |
| | | * of one or more key/value pairs which form the content of |
| | | * the intermediate message. |
| | | */ |
| | | public static void logModifyDNIntermediateMessage( |
| | | ModifyDNOperation modifyDNOperation, String category, |
| | | Map<String, String> content) |
| | | { |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logModifyDNIntermediateMessage(modifyDNOperation, |
| | | category, content); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the modify DN |
| | | * response associated with the provided modify DN operation. |
| | | * |
| | |
| | | */ |
| | | public static void logModifyDNResponse(ModifyDNOperation modifyDNOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logModifyDNResponse(modifyDNOperation); |
| | | } |
| | |
| | | */ |
| | | public static void logSearchRequest(SearchOperation searchOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logSearchRequest(searchOperation); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger containing additional |
| | | * information associated with the provided search operation. |
| | | * <p> |
| | | * This method will only be called after the request has been logged |
| | | * and before the response. Implementations can choose to ignore |
| | | * intermediate responses or filter them based on their category. |
| | | * |
| | | * @param searchOperation |
| | | * The search operation containing the information to use |
| | | * to log the search request. |
| | | * @param category |
| | | * The category of the intermediate message. |
| | | * @param content |
| | | * The content of the intermediate message. This comprises |
| | | * of one or more key/value pairs which form the content of |
| | | * the intermediate message. |
| | | */ |
| | | public static void logSearchIntermediateMessage( |
| | | SearchOperation searchOperation, String category, |
| | | Map<String, String> content) |
| | | { |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logSearchIntermediateMessage(searchOperation, |
| | | category, content); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about the search |
| | | * result entry that matches the criteria associated with the provided search |
| | | * operation. |
| | |
| | | public static void logSearchResultEntry(SearchOperation searchOperation, |
| | | SearchResultEntry searchEntry) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logSearchResultEntry(searchOperation, searchEntry); |
| | | } |
| | |
| | | public static void logSearchResultReference(SearchOperation searchOperation, |
| | | SearchResultReference searchReference) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logSearchResultReference(searchOperation, searchReference); |
| | | } |
| | |
| | | */ |
| | | public static void logSearchResultDone(SearchOperation searchOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logSearchResultDone(searchOperation); |
| | | } |
| | |
| | | */ |
| | | public static void logUnbind(UnbindOperation unbindOperation) |
| | | { |
| | | for (AccessLogPublisher publisher : accessPublishers) |
| | | for (AccessLogPublisher<?> publisher : accessPublishers) |
| | | { |
| | | publisher.logUnbind(unbindOperation); |
| | | } |