Package org.opends.server.util
Class SetupUtils
- java.lang.Object
-
- org.opends.server.util.SetupUtils
-
@PublicAPI(stability=VOLATILE, mayInstantiate=false, mayExtend=false, mayInvoke=true) public class SetupUtils extends Object
This class provides a number of utility methods that may be used during the graphical or command-line setup process.
-
-
Field Summary
Fields Modifier and Type Field Description static StringBUILD_IDBuild ID.static StringBUILD_JAVA_VENDORThe java vendor of the JVM used to build.static StringBUILD_JAVA_VERSIONThe java version used to generate the build.static StringBUILD_JVM_VENDORThe vendor of the JVM used to create the build.static StringBUILD_JVM_VERSIONThe version of the JVM used to create the build.static StringBUILD_NUMBERThe build number.static StringBUILD_OSThe OS used during the build.static StringBUILD_USERThe user that generated the build.static StringDEBUG_BUILDDebug build identifier.static StringFIX_IDSFix IDs associated with the build.static StringHOST_NAME_FILEThe relative path where the setup stores the name of the host the user provides.static StringLIBRARIES_PATH_RELATIVEThe relative path where all the libraries (jar files) are.static StringMAJOR_VERSIONMajor version.static StringMINOR_VERSIONMinor version.static StringNAMEProduct name.static StringOPENDJ_JAVA_ARGSSpecific environment variable used by the scripts to set java arguments.static StringOPENDJ_JAVA_HOMESpecific environment variable used by the scripts to find java.static StringPOINT_VERSIONPoint version of the product.static StringREVISIONRevision in VCS.static StringURL_REPOSITORYThe VCS url repository.static StringVERSION_QUALIFIERThe version qualifier.
-
Constructor Summary
Constructors Constructor Description SetupUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancanUseAsPort(int port)Returnstrueif the provided port is free and we can use it,falseotherwise.static char[]createSelfSignedCertificatePwd()Returns a randomly generated password for a self-signed certificate keystore.static FilecreateTemplateFile(String baseDN, int numEntries)Creates a MakeLDIF template file using the provided information.static FilecreateTemplateFile(Set<String> baseDNs, int numEntries)Creates a MakeLDIF template file using the provided information.static voidexportCertificate(CertificateManager certManager, String alias, String path)Export a certificate in a file.static StringgetHostNameForCertificate(String installationRoot)Returns the host name to be used to create self-signed certificates.static StringgetScriptPath(String script)Returns the String that can be used to launch an script using Runtime.exec.static booleanisPrivilegedPort(int port)Returnstrueif the provided port is a privileged port,falseotherwise.
-
-
-
Field Detail
-
OPENDJ_JAVA_HOME
public static final String OPENDJ_JAVA_HOME
Specific environment variable used by the scripts to find java.- See Also:
- Constant Field Values
-
OPENDJ_JAVA_ARGS
public static final String OPENDJ_JAVA_ARGS
Specific environment variable used by the scripts to set java arguments.- See Also:
- Constant Field Values
-
LIBRARIES_PATH_RELATIVE
public static final String LIBRARIES_PATH_RELATIVE
The relative path where all the libraries (jar files) are.- See Also:
- Constant Field Values
-
HOST_NAME_FILE
public static final String HOST_NAME_FILE
The relative path where the setup stores the name of the host the user provides. This is used for instance to generate the self-signed admin certificate the first time the server starts.
-
NAME
public static final String NAME
Product name.- See Also:
- Constant Field Values
-
BUILD_ID
public static final String BUILD_ID
Build ID.- See Also:
- Constant Field Values
-
MAJOR_VERSION
public static final String MAJOR_VERSION
Major version.- See Also:
- Constant Field Values
-
MINOR_VERSION
public static final String MINOR_VERSION
Minor version.- See Also:
- Constant Field Values
-
POINT_VERSION
public static final String POINT_VERSION
Point version of the product.- See Also:
- Constant Field Values
-
REVISION
public static final String REVISION
Revision in VCS.- See Also:
- Constant Field Values
-
URL_REPOSITORY
public static final String URL_REPOSITORY
The VCS url repository.- See Also:
- Constant Field Values
-
VERSION_QUALIFIER
public static final String VERSION_QUALIFIER
The version qualifier.- See Also:
- Constant Field Values
-
FIX_IDS
public static final String FIX_IDS
Fix IDs associated with the build.- See Also:
- Constant Field Values
-
DEBUG_BUILD
public static final String DEBUG_BUILD
Debug build identifier.- See Also:
- Constant Field Values
-
BUILD_OS
public static final String BUILD_OS
The OS used during the build.- See Also:
- Constant Field Values
-
BUILD_USER
public static final String BUILD_USER
The user that generated the build.- See Also:
- Constant Field Values
-
BUILD_JAVA_VERSION
public static final String BUILD_JAVA_VERSION
The java version used to generate the build.- See Also:
- Constant Field Values
-
BUILD_JAVA_VENDOR
public static final String BUILD_JAVA_VENDOR
The java vendor of the JVM used to build.- See Also:
- Constant Field Values
-
BUILD_JVM_VERSION
public static final String BUILD_JVM_VERSION
The version of the JVM used to create the build.- See Also:
- Constant Field Values
-
BUILD_JVM_VENDOR
public static final String BUILD_JVM_VENDOR
The vendor of the JVM used to create the build.- See Also:
- Constant Field Values
-
BUILD_NUMBER
public static final String BUILD_NUMBER
The build number.- See Also:
- Constant Field Values
-
-
Method Detail
-
createTemplateFile
public static File createTemplateFile(String baseDN, int numEntries) throws IOException
Creates a MakeLDIF template file using the provided information.- Parameters:
baseDN- The base DN for the data in the template file.numEntries- The number of user entries the template file should create.- Returns:
- The
Fileobject that references the created template file. - Throws:
IOException- If a problem occurs while writing the template file.
-
createTemplateFile
public static File createTemplateFile(Set<String> baseDNs, int numEntries) throws IOException
Creates a MakeLDIF template file using the provided information.- Parameters:
baseDNs- The base DNs for the data in the template file.numEntries- The number of user entries the template file should create.- Returns:
- The
Fileobject that references the created template file. - Throws:
IOException- If a problem occurs while writing the template file.
-
canUseAsPort
public static boolean canUseAsPort(int port)
Returnstrueif the provided port is free and we can use it,falseotherwise.- Parameters:
port- the port we are analyzing.- Returns:
trueif the provided port is free and we can use it,falseotherwise.
-
isPrivilegedPort
public static boolean isPrivilegedPort(int port)
Returnstrueif the provided port is a privileged port,falseotherwise.- Parameters:
port- the port we are analyzing.- Returns:
trueif the provided port is a privileged port,falseotherwise.
-
getScriptPath
public static String getScriptPath(String script)
Returns the String that can be used to launch an script using Runtime.exec. This method is required because in Windows the script that contain a "=" in their path must be quoted.- Parameters:
script- the script name- Returns:
- the absolute path for the given parentPath and relativePath.
-
createSelfSignedCertificatePwd
public static char[] createSelfSignedCertificatePwd()
Returns a randomly generated password for a self-signed certificate keystore.- Returns:
- a randomly generated password for a self-signed certificate keystore.
-
exportCertificate
public static void exportCertificate(CertificateManager certManager, String alias, String path) throws CertificateEncodingException, IOException, KeyStoreException
Export a certificate in a file. If the certificate alias to export is null, It will export the first certificate defined.- Parameters:
certManager- Certificate manager to use.alias- Certificate alias to export. Ifnullthe first certificate defined will be exported.path- Path of the output file.- Throws:
CertificateEncodingException- If the certificate manager cannot encode the certificate.IOException- If a problem occurs while creating or writing in the output file.KeyStoreException- If the certificate manager cannot retrieve the certificate to be exported.
-
getHostNameForCertificate
public static String getHostNameForCertificate(String installationRoot) throws UnknownHostException
Returns the host name to be used to create self-signed certificates.
The method will first try to read the host name file written by the setup where the user provided the host name where OpenDJ has been installed. If the file cannot be read, the classInetAddressis used.- Parameters:
installationRoot- the path where the server is installed.- Returns:
- the host name to be used to create self-signed certificates.
- Throws:
UnknownHostException- if a host name could not be used.
-
-