Package org.apache.sshd.common.util
Class OsUtils
java.lang.Object
org.apache.sshd.common.util.OsUtils
Operating system dependent utility methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final AtomicReference<String>
static final String
Property that can be used to override the reported value fromgetCurrentUser()
.private static final AtomicReference<VersionInfo>
static final String
Property that can be used to override the reported value fromgetJavaVersion()
.static final String
private static final AtomicReference<String>
static final String
Property that can be used to override the reported value fromisWin32()
.static final String
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getCanonicalUser
(String user) RemoveWindows
domain and/or group prefix as well as "(User);" suffixstatic String
getComparablePath
(String path) static String
Get current user namestatic VersionInfo
Resolves the reported Java version by consultingJAVA_VERSION_OVERRIDE_PROP
.private static String
getOS()
static boolean
isOSX()
static boolean
isUNIX()
static boolean
isWin32()
static String
resolveCanonicalGroup
(String group, String user) Attempts to resolve canonical group name forWindows
resolveDefaultInteractiveCommandElements
(boolean winOS) static String
static String
resolveDefaultInteractiveShellCommand
(boolean winOS) static void
setCurrentUser
(String username) Can be used to programmatically set the username reported bygetCurrentUser()
static void
setJavaVersion
(VersionInfo version) Set programmatically the reported Java versionstatic void
-
Field Details
-
CURRENT_USER_OVERRIDE_PROP
Property that can be used to override the reported value fromgetCurrentUser()
. If not set then "user.name" system property is used- See Also:
-
JAVA_VERSION_OVERRIDE_PROP
Property that can be used to override the reported value fromgetJavaVersion()
. If not set then "java.version" system property is used- See Also:
-
OS_TYPE_OVERRIDE_PROP
Property that can be used to override the reported value fromisWin32()
. If not set then "os.name" system property is used- See Also:
-
WINDOWS_SHELL_COMMAND_NAME
- See Also:
-
LINUX_SHELL_COMMAND_NAME
- See Also:
-
ROOT_USER
- See Also:
-
LINUX_COMMAND
-
WINDOWS_COMMAND
-
CURRENT_USER_HOLDER
-
JAVA_VERSION_HOLDER
-
OS_TYPE_HOLDER
-
-
Constructor Details
-
OsUtils
private OsUtils()
-
-
Method Details
-
isUNIX
public static boolean isUNIX()- Returns:
- true if the host is a UNIX system (and not Windows).
-
isOSX
public static boolean isOSX()- Returns:
- true if the host is a OSX (and not Windows or Unix).
-
isWin32
public static boolean isWin32()- Returns:
- true if the host is Windows (and not UNIX).
- See Also:
-
setOS
-
getOS
- Returns:
- The resolved O/S type string if not already set (lowercase)
-
resolveDefaultInteractiveShellCommand
-
resolveDefaultInteractiveShellCommand
-
resolveDefaultInteractiveCommandElements
-
resolveDefaultInteractiveCommandElements
-
getCurrentUser
Get current user name- Returns:
- Current user
- See Also:
-
getCanonicalUser
RemoveWindows
domain and/or group prefix as well as "(User);" suffix- Parameters:
user
- The original username - ignored ifnull
/empty- Returns:
- The canonical user - unchanged if
Unix
O/S
-
resolveCanonicalGroup
Attempts to resolve canonical group name forWindows
- Parameters:
group
- The original group name - used if notnull
/emptyuser
- The owner name - sometimes it contains a group name- Returns:
- The canonical group name
-
setCurrentUser
Can be used to programmatically set the username reported bygetCurrentUser()
- Parameters:
username
- The username to set - ifnull
thenCURRENT_USER_OVERRIDE_PROP
will be consulted
-
getJavaVersion
Resolves the reported Java version by consultingJAVA_VERSION_OVERRIDE_PROP
. If not set, then "java.version" property is used- Returns:
- The resolved
VersionInfo
- nevernull
- See Also:
-
setJavaVersion
Set programmatically the reported Java version- Parameters:
version
- The version - ifnull
then it will be automatically resolved
-
getComparablePath
- Parameters:
path
- The original path- Returns:
- A path that can be compared with another one where case sensitivity of the underlying O/S has been
taken into account - never
null
-