Class PropertiesFileLicenseLog

  • All Implemented Interfaces:
    LicenseLog

    public class PropertiesFileLicenseLog
    extends Object
    implements LicenseLog
    Stores acceptance of license terms in a Properties file on disk. Uses a separate properties file for each license file with an entry for each user that has accepted the license, of the form:
         user=date-accepted
     
    Where user is the user name of the user (usually from user.name system property), and date-accepted is the ISO-8601 formatted timestamp of when they accepted that license. Each license log file is placed in the given log directory and named by taking the root name of the license and changing the extension to .log. For example, license.txt will produce a license.log file.
    Since:
    12.0.0
    • Constructor Detail

      • PropertiesFileLicenseLog

        public PropertiesFileLicenseLog​(File logDirectory)
        Constructs the license log with the given log directory and log date format (see SimpleDateFormat for allowed format strings).
        Parameters:
        logDirectory - the directory to store log files in.
        Throws:
        NullPointerException - if either parameter is null.
        IllegalArgumentException - if the log directory does not exist, is not a directory or is not writeable or if the date format is invalid.
    • Method Detail

      • logLicenseAccepted

        public void logLicenseAccepted​(License license,
                                       String user,
                                       Date acceptedDate)
        Logs that the given user has accepted the given license terms.
        Specified by:
        logLicenseAccepted in interface LicenseLog
        Parameters:
        license - the license that the user accepted
        user - the user who accepted the license
        acceptedDate - the timestamp at which the license was accepted.
      • isLicenseAccepted

        public boolean isLicenseAccepted​(License license,
                                         String user)
        Determines whether the given user has accepted the given license according to the log.
        Specified by:
        isLicenseAccepted in interface LicenseLog
        Parameters:
        license - the license to check acceptance for.
        user - the user to check.
        Returns:
        true if the user has accepted the given license terms, or false if not.