Class WebServerAccessLogImpl

  • All Implemented Interfaces:
    java.io.Serializable, org.torproject.descriptor.Descriptor, org.torproject.descriptor.LogDescriptor, org.torproject.descriptor.WebServerAccessLog

    public class WebServerAccessLogImpl
    extends java.lang.Object
    implements org.torproject.descriptor.WebServerAccessLog
    Implementation of web server access log descriptors.

    Defines sanitization and validation for web server access logs.

    Since:
    2.2.0
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.torproject.descriptor.WebServerAccessLog

        org.torproject.descriptor.WebServerAccessLog.Line
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.regex.Pattern filenamePattern
      The mandatory web server log descriptor file name pattern.
      static java.lang.String MARKER
      The log's name should include this string.
      static java.lang.String SEP
      Logfile name parts separator.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected WebServerAccessLogImpl​(byte[] logBytes, java.io.File descriptorFile, java.lang.String logName)
      Creates a WebServerAccessLog from the given bytes and filename.
      protected WebServerAccessLogImpl​(java.lang.String virtualHost, java.lang.String physicalHost, java.time.LocalDate logDate)
      Creates an empty WebServerAccessLog from the given filename parts.
    • Field Detail

      • SEP

        public static final java.lang.String SEP
        Logfile name parts separator.
        See Also:
        Constant Field Values
      • MARKER

        public static final java.lang.String MARKER
        The log's name should include this string.
        See Also:
        Constant Field Values
      • filenamePattern

        public static final java.util.regex.Pattern filenamePattern
        The mandatory web server log descriptor file name pattern.
    • Constructor Detail

      • WebServerAccessLogImpl

        protected WebServerAccessLogImpl​(byte[] logBytes,
                                         java.io.File descriptorFile,
                                         java.lang.String logName)
                                  throws org.torproject.descriptor.DescriptorParseException
        Creates a WebServerAccessLog from the given bytes and filename.

        The given bytes are read, whereas the file is not read.

        The path of the given file has to be compliant to the following naming pattern <virtualHost>-<physicalHost>-access.log-<yyyymmdd>.<compression>, where an unknown compression type (see getCompressionType()) is interpreted as missing compression. In this case the bytes will be compressed to the default compression type. The immediate parent name is taken to be the physical host collecting the logs.

        Throws:
        org.torproject.descriptor.DescriptorParseException
      • WebServerAccessLogImpl

        protected WebServerAccessLogImpl​(java.lang.String virtualHost,
                                         java.lang.String physicalHost,
                                         java.time.LocalDate logDate)
        Creates an empty WebServerAccessLog from the given filename parts.

        This instance is not intended to be written to disk, as it doesn't have any content. The main intention of this instance is to compute storage paths.

        Parameters:
        virtualHost - Virtual host name.
        physicalHost - Physical host name.
        logDate - Log date.
    • Method Detail

      • decompressedByteStream

        public java.io.InputStream decompressedByteStream()
                                                   throws org.torproject.descriptor.DescriptorParseException
        Specified by:
        decompressedByteStream in interface org.torproject.descriptor.LogDescriptor
        Throws:
        org.torproject.descriptor.DescriptorParseException
      • getCompressionType

        public java.lang.String getCompressionType()
      • getRawDescriptorBytes

        public byte[] getRawDescriptorBytes()
        Specified by:
        getRawDescriptorBytes in interface org.torproject.descriptor.Descriptor
        Specified by:
        getRawDescriptorBytes in interface org.torproject.descriptor.LogDescriptor
      • setRawDescriptorBytes

        public void setRawDescriptorBytes​(byte[] bytes)
      • getRawDescriptorLength

        public int getRawDescriptorLength()
        Specified by:
        getRawDescriptorLength in interface org.torproject.descriptor.Descriptor
      • getAnnotations

        public java.util.List<java.lang.String> getAnnotations()
        Specified by:
        getAnnotations in interface org.torproject.descriptor.Descriptor
        Specified by:
        getAnnotations in interface org.torproject.descriptor.LogDescriptor
      • getUnrecognizedLines

        public java.util.List<java.lang.String> getUnrecognizedLines()
        Specified by:
        getUnrecognizedLines in interface org.torproject.descriptor.Descriptor
        Specified by:
        getUnrecognizedLines in interface org.torproject.descriptor.LogDescriptor
        Specified by:
        getUnrecognizedLines in interface org.torproject.descriptor.WebServerAccessLog
      • getDescriptorFile

        public java.io.File getDescriptorFile()
        Specified by:
        getDescriptorFile in interface org.torproject.descriptor.Descriptor
      • getPhysicalHost

        public java.lang.String getPhysicalHost()
        Specified by:
        getPhysicalHost in interface org.torproject.descriptor.WebServerAccessLog
      • getVirtualHost

        public java.lang.String getVirtualHost()
        Specified by:
        getVirtualHost in interface org.torproject.descriptor.WebServerAccessLog
      • getLogDate

        public java.time.LocalDate getLogDate()
        Specified by:
        getLogDate in interface org.torproject.descriptor.WebServerAccessLog
      • logLines

        public java.util.stream.Stream<org.torproject.descriptor.WebServerAccessLog.Line> logLines()
                                                                                            throws org.torproject.descriptor.DescriptorParseException
        Returns a stream of all valid log lines.
        Specified by:
        logLines in interface org.torproject.descriptor.LogDescriptor
        Specified by:
        logLines in interface org.torproject.descriptor.WebServerAccessLog
        Throws:
        org.torproject.descriptor.DescriptorParseException