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 |
isUNIX() |
static boolean |
isWin32() |
static String |
resolveCanonicalGroup(String group,
String user)
Attempts to resolve canonical group name for
Windows |
static List<String> |
resolveDefaultInteractiveCommand() |
static List<String> |
resolveInteractiveCommand(boolean isWin32) |
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 |
setWin32(Boolean win32)
|
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 isWin32()
OS_TYPE_OVERRIDE_PROP
,
setWin32(Boolean)
public static void setWin32(Boolean win32)
win32
- The value to set - if null
then O/S type is auto-detectedisWin32()
public static String getCurrentUser()
CURRENT_USER_OVERRIDE_PROP
public 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)
Windows
group
- 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 null
setJavaVersion(VersionInfo)
public static void setJavaVersion(VersionInfo version)
version
- The version - if null
then it will be automatically resolvedCopyright © 2008–2016 The Apache Software Foundation. All rights reserved.