mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
17.48.2015 0e73432880f7c3bb60300bb00625772bef37e4b5
OPENDJ-2144 Update license files and folder location

CR-7262
This change is a consequence of OPENDJ-2098
* src/main/java/org/opends/server/tools/upgrade/LicenseFile.java
** Perform a check in multiple folders to ensure if the license has been accepted for a 2.6.x version a user would not be prompted again.
** Introduce some constants to avoid harcoded string repetitions
* build.xml
** I do not think this code is still use, but update to prevent any regression
5 files modified
118 ■■■■■ changed files
opendj-server-legacy/build.xml 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/resource/webstart/create-webstart-standalone.sh 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/docbkx/reference/appendix-file-layout.xml 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/quicksetup/LicenseFile.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java 98 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/build.xml
@@ -1048,7 +1048,7 @@
       This target should only be called from targets which have defined the
       pdir property, such as prepackage and rebuild.
       The license file will be copied to ${pdir}/Legal/license_to_accept.txt.
       The license file will be copied to ${pdir}/legal-notices/Forgerock_License.txt.
       This file location is hard-coded in the following classes:
       org.opends.server.tools.upgrade.LicenseFile
@@ -1057,8 +1057,8 @@
       Care must be taken to keep these filenames synchronized.
  -->
  <target name="copylicense" if="include.license.file" >
    <mkdir dir="${pdir}/Legal" />
    <copy tofile="${pdir}/Legal/license_to_accept.txt" file="${license.file}" />
    <mkdir dir="${pdir}/legal-notices" />
    <copy tofile="${pdir}/legal-notices/Forgerock_License.txt" file="${license.file}" />
  </target>
  <!-- Populate the Directory Server package, but don't zip it up. -->
opendj-server-legacy/resource/webstart/create-webstart-standalone.sh
@@ -175,12 +175,12 @@
done
# Create and sign the licence.jar file if exists.
if [ -d ${BUILD_DIR}/package/${ZIP_FILENAME_BASE}/Legal ]
if [ -d ${BUILD_DIR}/package/${ZIP_FILENAME_BASE}/legal-notices ]
then
echo "Creating license.jar ..."
cp "${BUILD_DIR}/package/${ZIP_FILENAME_BASE}/Legal" "${INSTALL_DIR}/lib"
cp "${BUILD_DIR}/package/${ZIP_FILENAME_BASE}/legal-notices" "${INSTALL_DIR}/lib"
cd "${BUILD_DIR}/package"
"${JAR}" -cf "${INSTALL_DIR}/lib/license.jar" -C "${BUILD_DIR}/package/${ZIP_FILENAME_BASE}/" "Legal"
"${JAR}" -cf "${INSTALL_DIR}/lib/license.jar" -C "${BUILD_DIR}/package/${ZIP_FILENAME_BASE}/" "legal-notices"
cd "${INSTALL_DIR}/lib"
echo "Signing license.jar ..."
"${JARSIGNER}" -keystore "${CERT_KEYSTORE}" -keypass "${CERT_KEYSTORE_PIN}" \
opendj-server-legacy/src/main/docbkx/reference/appendix-file-layout.xml
@@ -21,7 +21,7 @@
  ! CCPL HEADER END
  !
  !      Copyright 2011-2015 ForgeRock AS.
  !
  !
-->
<appendix xml:id='appendix-file-layout'
          xmlns='http://docbook.org/ns/docbook' version='5.0' xml:lang='en'
@@ -38,7 +38,7 @@
 <indexterm><primary>Installed files</primary></indexterm>
 <variablelist>
  <varlistentry>
   <term><filename>Legal</filename></term>
   <term><filename>legal-notices</filename></term>
   <listitem>
    <para>
     License information
opendj-server-legacy/src/main/java/org/opends/quicksetup/LicenseFile.java
@@ -51,12 +51,12 @@
  /**
   * The license file name in Legal directory.
   */
  private static final String LICENSE_FILE_NAME = "license_to_accept.txt";
  private static final String LICENSE_FILE_NAME = "Forgerock_License.txt";
  /**
   * The Legal folder which contains license file.
   */
  private static final String LEGAL_FOLDER_NAME = "Legal";
  private static final String LEGAL_FOLDER_NAME = "legal-notices";
  /**
   * The accepted license file name.
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/LicenseFile.java
@@ -41,24 +41,48 @@
 */
class LicenseFile
{
  private static final String INSTALL_ROOT_SYSTEM_PROPERTY = "INSTALL_ROOT";
  /**
   * Get the directory in which legal files are stored.
   * The license file name in Legal directory.
   */
  private static final String LICENSE_FILE_NAME = "Forgerock_License.txt";
  /**
   * The Legal folder which contains license file.
   */
  private static final String LEGAL_FOLDER_NAME = "legal-notices";
  /** List of possible folder of the accepted license file. */
  private static final String[] ACCEPTED_LICENSE_FOLDER_NAMES = new String[] { LEGAL_FOLDER_NAME, "Legal" };
  /**
   * The accepted license file name.
   */
  private static final String ACCEPTED_LICENSE_FILE_NAME = "licenseAccepted";
  /**
   * Try to find the local instance path from system property or environment. If
   * both are null, return the provided fallback value.
   */
  private static String getInstanceRootPathFromSystem(final String fallBackValue)
  {
    final String[] possibleValues = new String[] {
      System.getProperty(INSTALL_ROOT_SYSTEM_PROPERTY), System.getenv(INSTALL_ROOT_SYSTEM_PROPERTY) };
    for (final String value : possibleValues )
    {
      if (value != null)
      {
        return value;
      }
    }
    return fallBackValue;
  }
  /** Get the directory in which legal files are stored. */
  private static String getLegalDirectory()
  {
    String installRootFromSystem = System.getProperty("INSTALL_ROOT");
    if (installRootFromSystem == null)
    {
      installRootFromSystem = System.getenv("INSTALL_ROOT");
    }
    if (installRootFromSystem == null)
    {
      installRootFromSystem = "";
    }
    return installRootFromSystem + File.separatorChar + "Legal";
    return getInstanceRootPathFromSystem("") + File.separatorChar + LEGAL_FOLDER_NAME;
  }
  /**
@@ -66,30 +90,14 @@
   */
  private static String getInstanceLegalDirectory()
  {
    String installDirName = System.getProperty("INSTALL_ROOT");
    if (installDirName == null)
    {
      installDirName = System.getenv("INSTALL_ROOT");
    }
    if (installDirName == null)
    {
      installDirName = ".";
    }
    final String instanceDirname =
        UpgradeUtils.getInstancePathFromInstallPath(installDirName);
    StringBuilder instanceLegalDirName =
        new StringBuilder(instanceDirname).append(File.separator).append(
            "Legal");
    final File instanceLegalDir = new File(instanceLegalDirName.toString());
    final String instanceDirname = UpgradeUtils.getInstancePathFromInstallPath(getInstanceRootPathFromSystem("."));
    final String instanceLegalDirName = instanceDirname + File.separator + LEGAL_FOLDER_NAME;
    final File instanceLegalDir = new File(instanceLegalDirName);
    if (!instanceLegalDir.exists())
    {
      instanceLegalDir.mkdir();
    }
    return instanceLegalDirName.toString();
    return instanceLegalDirName;
  }
  /**
@@ -107,7 +115,7 @@
   */
  private static String getName()
  {
    return getLegalDirectory() + File.separatorChar + "license_to_accept.txt";
    return getLegalDirectory() + File.separatorChar + LICENSE_FILE_NAME;
  }
  /**
@@ -126,7 +134,7 @@
  /**
   * Checks if the license file exists.
   *
   * @return <CODE>true</CODE> a license file license_to_accept.txt exists in
   * @return <CODE>true</CODE> a license file exists in
   *         the Legal directory in the top level installation directory
   *         <CODE>false</CODE> otherwise.
   */
@@ -205,7 +213,7 @@
      try
      {
        new File(getInstanceLegalDirectory() + File.separatorChar
            + "licenseAccepted").createNewFile();
            + ACCEPTED_LICENSE_FILE_NAME).createNewFile();
      }
      catch (IOException e)
      {
@@ -219,12 +227,18 @@
   * @return <CODE>true</CODE> if the license had already been approved by the
   *         user <CODE>false</CODE> otherwise.
   */
  static boolean isAlreadyApproved()
  public static boolean isAlreadyApproved()
  {
    File f =
        new File(getInstanceLegalDirectory() + File.separatorChar
            + "licenseAccepted");
    return f.exists();
    for (final String folderName : ACCEPTED_LICENSE_FOLDER_NAMES)
    {
      final File f = new File(getInstanceRootPathFromSystem(".") + File.separatorChar + folderName
          + File.separatorChar + ACCEPTED_LICENSE_FILE_NAME);
      if (f.exists())
      {
        return true;
      }
    }
    return false;
  }
}