LicenseFile.java revision 407bb81fb935e713a4a1ae1b9189b81488a944d5
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2013 ForgeRock AS.
*/
/**
* Represents information about the license file. NOTE: the license file
* location must be kept in sync with build.xml and
* org.opends.server.tools.upgrade.LicenseFile.
*/
public class LicenseFile
{
/**
* The license file name in Legal directory.
*/
/**
* The Legal folder which contains license file.
*/
/**
* The accepted license file name.
*/
/**
* Get the directory in which legal files are stored.
*/
private static String getInstanceLegalDirectory()
{
if (installDirName == null)
{
}
if (installDirName == null)
{
installDirName = ".";
}
if (!instanceLegalDir.exists())
{
}
return instanceLegalDirName;
}
/**
* The File object related to the license file.
*/
/**
* The license file approval state.
*/
static private boolean approved = false;
/**
* Returns the license file name.
*/
{
}
/**
* Returns the license file object.
*/
{
{
}
return licFile;
}
/**
* Returns the URL to the license file when using jnlp / java web start.
*/
static private URL getWebStartLicenseFile()
{
final String licenseResource =
}
/**
* Checks if the license file exists.
*
* @return <CODE>true</CODE> if the license file exists in the Legal directory
* in the top level installation directory <CODE>false</CODE>
* otherwise.
*/
static public boolean exists()
{
if (Utils.isWebStart())
{
return (getWebStartLicenseFile() != null);
}
else
{
}
}
/**
* Get the textual contents of the license file.
*
* @return the textual contents of the license file.
*/
{
// Gets the inputstream of the license
// From a file as the usual way,
// from an URL if we use web start / jnlp.
if (!Utils.isWebStart())
{
try
{
}
catch (FileNotFoundException e)
{
// Should not happen
return "";
}
}
else
{
if (licenseURL != null)
{
try
{
}
catch (Exception e)
{
// Should not happen
return "";
}
}
}
// Reads the inputstream content.
{
try
{
final BufferedReader br =
{
}
}
catch (IOException ioe)
{
// Should not happen
return "";
}
}
}
/**
* Get the license approval status.
*
* @return <CODE>true</CODE> if the license has been accepted by the user
* <CODE>false</CODE> otherwise.
*/
static public boolean getApproval()
{
return approved;
}
/**
* Sets the license approval status.
*
* @param p_approved
* the license approval status
*/
static public void setApproval(boolean p_approved)
{
}
/**
* Creates a file - in the legal folder from the specified directory; which
* indicates that the license has been approved.
*
* @param installationPath
* The server installation's path.
*/
{
{
try
{
}
catch (IOException e)
{
// do nothing
}
}
}
/**
* Indicate if the license had already been approved..
*
* @return <CODE>true</CODE> if the license had already been approved by the
* user <CODE>false</CODE> otherwise.
*/
static public boolean isAlreadyApproved()
{
final File f =
return f.exists();
}
}