| | |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.quicksetup; |
| | | |
| | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.nio.file.Files; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | |
| | | */ |
| | | public class LicenseFile |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private static final String INSTALL_ROOT_SYSTEM_PROPERTY = "INSTALL_ROOT"; |
| | | /** The license file name in Legal directory. */ |
| | | private static final String LICENSE_FILE_NAME = "Forgerock_License.txt"; |
| | |
| | | String instanceLegalDirName = Utils.getInstancePathFromInstallPath(getInstallDirectory()) |
| | | + File.separator + LEGAL_FOLDER_NAME; |
| | | File instanceLegalDir = new File(instanceLegalDirName); |
| | | if (!instanceLegalDir.exists()) |
| | | if (!instanceLegalDir.isDirectory() && !instanceLegalDir.mkdirs()) |
| | | { |
| | | instanceLegalDir.mkdir(); |
| | | logger.warn(LocalizableMessage.raw("Unable to create the legal directory %s", instanceLegalDirName)); |
| | | } |
| | | return instanceLegalDirName; |
| | | } |
| | |
| | | String instanceLegalDirName = instanceDirname + File.separator + LEGAL_FOLDER_NAME; |
| | | File instanceLegalDir = new File(instanceLegalDirName); |
| | | |
| | | File approvalFile = new File(instanceLegalDir, ACCEPTED_LICENSE_FILE_NAME); |
| | | try |
| | | { |
| | | if (!instanceLegalDir.exists()) |
| | | Files.createDirectories(instanceLegalDir.toPath()); |
| | | if (!approvalFile.createNewFile() && !approvalFile.isFile()) |
| | | { |
| | | instanceLegalDir.mkdir(); |
| | | logger.warn(LocalizableMessage.raw("Unable to create the license approval file %s", approvalFile)); |
| | | } |
| | | new File(instanceLegalDir, ACCEPTED_LICENSE_FILE_NAME).createNewFile(); |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | // do nothing |
| | | logger.warn(LocalizableMessage.raw( |
| | | "Unable to create the license approval file %s: %s", approvalFile, e.getLocalizedMessage())); |
| | | } |
| | | } |
| | | } |