@Override
    protected Connection undecorate(Connection connection) throws GuacamoleException {

        // If the connection was wrapped, unwrap it
        if (connection instanceof HistoryTrackingConnection) {
            return ((HistoryTrackingConnection) connection).getWrappedConnection();
        }

        // Otherwise, return the unwrapped connection directly
        return connection;
    }
Create a new history tracking connection directory. Any connection retrieved from this
directory will be wrapped in a HistoryTrackingConnection, enabling connection history
records to be written with the provided connection record mapper.

@param directory
    The connection directory to wrap.

@param user
    The user associated with the connection directory.

@param remoteHost
    The remote host that the user connected from.

@param connectionRecordMapper
    The connection record mapper that will be used to write the connection history records.
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/HistoryTrackingConnectionDirectory.java