| | |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | import static org.opends.messages.LoggerMessages.ERR_COMMON_AUDIT_INVALID_TRANSACTION_ID; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | import org.opends.server.admin.std.server.FileBasedAccessLogPublisherCfg; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.ExtendedOperationHandler; |
| | | import org.opends.server.controls.TransactionIdControl; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | /** This class provides the implementation of the access logger used by the directory server. */ |
| | |
| | | private boolean isCombinedMode; |
| | | private boolean includeControlOIDs; |
| | | private String timeStampFormat = "dd/MMM/yyyy:HH:mm:ss Z"; |
| | | private ServerContext serverContext; |
| | | |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(FileBasedAccessLogPublisherCfg config) |
| | |
| | | public void initializeLogPublisher(final FileBasedAccessLogPublisherCfg cfg, ServerContext serverContext) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | this.serverContext = serverContext; |
| | | final File logFile = getLogFile(cfg); |
| | | final FileNamingPolicy fnPolicy = new TimeStampNaming(logFile); |
| | | |
| | |
| | | buffer.append(" conn=").append(operation.getConnectionID()); |
| | | buffer.append(" op=").append(operation.getOperationID()); |
| | | buffer.append(" msgID=").append(operation.getMessageID()); |
| | | appendTransactionId(operation, buffer); |
| | | } |
| | | |
| | | private void appendModifyDNRequest(final ModifyDNOperation modifyDNOperation, |
| | |
| | | } |
| | | } |
| | | |
| | | private void appendTransactionId(Operation operation, final StringBuilder buffer) |
| | | { |
| | | // In test context, serverContext may be null |
| | | if (serverContext != null && serverContext.getCommonAudit().shouldTrustTransactionIds()) |
| | | { |
| | | String transactionId = getTransactionIdFromControl(operation); |
| | | if (transactionId != null) |
| | | { |
| | | buffer.append(" transactionId=").append(transactionId); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private String getTransactionIdFromControl(Operation operation) |
| | | { |
| | | try |
| | | { |
| | | TransactionIdControl control = operation.getRequestControl(TransactionIdControl.DECODER); |
| | | return control != null ? control.getTransactionId() : null; |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | logger.error(ERR_COMMON_AUDIT_INVALID_TRANSACTION_ID.get(StaticUtils.stackTraceToSingleLineString(e))); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private void appendRequestControls(final Operation operation, final StringBuilder buffer) |
| | | { |
| | | appendControls(buffer, " requestControls=", operation.getRequestControls()); |