public final class OsUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CURRENT_USER_OVERRIDE_PROP
Property that can be used to override the reported value from
getCurrentUser(). |
static String |
JAVA_VERSION_OVERRIDE_PROP
Property that can be used to override the reported value from
getJavaVersion(). |
static List<String> |
LINUX_COMMAND |
static String |
LINUX_SHELL_COMMAND_NAME |
static String |
OS_TYPE_OVERRIDE_PROP
Property that can be used to override the reported value from
isWin32(). |
static String |
ROOT_USER |
static List<String> |
WINDOWS_COMMAND |
static String |
WINDOWS_SHELL_COMMAND_NAME |
| Modifier and Type | Method and Description |
|---|---|
static String |
getCanonicalUser(String user)
Remove
Windows domain and/or group prefix as well as "(User);" suffix |
static String |
getComparablePath(String path) |
static String |
getCurrentUser()
Get current user name
|
static VersionInfo |
getJavaVersion()
Resolves the reported Java version by consulting
JAVA_VERSION_OVERRIDE_PROP. |
static boolean |
isOSX() |
static boolean |
isUNIX() |
static boolean |
isWin32() |
static String |
resolveCanonicalGroup(String group,
String user)
Attempts to resolve canonical group name for
Windows |
static List<String> |
resolveDefaultInteractiveCommandElements() |
static List<String> |
resolveDefaultInteractiveCommandElements(boolean winOS) |
static String |
resolveDefaultInteractiveShellCommand() |
static String |
resolveDefaultInteractiveShellCommand(boolean winOS) |
static void |
setCurrentUser(String username)
Can be used to programmatically set the username reported by
getCurrentUser() |
static void |
setJavaVersion(VersionInfo version)
Set programmatically the reported Java version
|
static void |
setOS(String os)
|
public static final String CURRENT_USER_OVERRIDE_PROP
getCurrentUser(). If not set then
"user.name" system property is usedpublic static final String JAVA_VERSION_OVERRIDE_PROP
getJavaVersion(). If not set then
"java.version" system property is usedpublic static final String OS_TYPE_OVERRIDE_PROP
isWin32(). If not set then
"os.name" system property is usedpublic static final String WINDOWS_SHELL_COMMAND_NAME
public static final String LINUX_SHELL_COMMAND_NAME
public static final String ROOT_USER
public static boolean isUNIX()
public static boolean isOSX()
public static boolean isWin32()
OS_TYPE_OVERRIDE_PROP,
setOS(String)public static void setOS(String os)
public static String resolveDefaultInteractiveShellCommand()
public static String resolveDefaultInteractiveShellCommand(boolean winOS)
public static List<String> resolveDefaultInteractiveCommandElements()
public static List<String> resolveDefaultInteractiveCommandElements(boolean winOS)
public static String getCurrentUser()
CURRENT_USER_OVERRIDE_PROPpublic static String getCanonicalUser(String user)
Windows domain and/or group prefix as well as "(User);" suffixuser - The original username - ignored if null/emptyUnix O/Spublic static String resolveCanonicalGroup(String group, String user)
Windowsgroup - The original group name - used if not null/emptyuser - The owner name - sometimes it contains a group namepublic static void setCurrentUser(String username)
getCurrentUser()username - The username to set - if null then CURRENT_USER_OVERRIDE_PROP will be consultedpublic static VersionInfo getJavaVersion()
JAVA_VERSION_OVERRIDE_PROP. If not set, then
"java.version" property is usedVersionInfo - never nullsetJavaVersion(VersionInfo)public static void setJavaVersion(VersionInfo version)
version - The version - if null then it will be automatically resolvedCopyright © 2018–2021 The Apache Software Foundation. All rights reserved.