Package org.apache.sshd.common.util
Class OsUtils
- java.lang.Object
-
- org.apache.sshd.common.util.OsUtils
-
public final class OsUtils extends Object
Operating system dependent utility methods.- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description static String
CURRENT_USER_OVERRIDE_PROP
Property that can be used to override the reported value fromgetCurrentUser()
.static String
JAVA_VERSION_OVERRIDE_PROP
Property that can be used to override the reported value fromgetJavaVersion()
.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 fromisWin32()
.static String
ROOT_USER
static List<String>
WINDOWS_COMMAND
static String
WINDOWS_SHELL_COMMAND_NAME
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getCanonicalUser(String user)
RemoveWindows
domain and/or group prefix as well as "(User);" suffixstatic String
getComparablePath(String path)
static String
getCurrentUser()
Get current user namestatic VersionInfo
getJavaVersion()
Resolves the reported Java version by consultingJAVA_VERSION_OVERRIDE_PROP
.static boolean
isUNIX()
static boolean
isWin32()
static String
resolveCanonicalGroup(String group, String user)
Attempts to resolve canonical group name forWindows
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 bygetCurrentUser()
static void
setJavaVersion(VersionInfo version)
Set programmatically the reported Java versionstatic void
setWin32(Boolean win32)
-
-
-
Field Detail
-
CURRENT_USER_OVERRIDE_PROP
public static final String 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:
- Constant Field Values
-
JAVA_VERSION_OVERRIDE_PROP
public static final String 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:
- Constant Field Values
-
OS_TYPE_OVERRIDE_PROP
public static final String 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:
- Constant Field Values
-
WINDOWS_SHELL_COMMAND_NAME
public static final String WINDOWS_SHELL_COMMAND_NAME
- See Also:
- Constant Field Values
-
LINUX_SHELL_COMMAND_NAME
public static final String LINUX_SHELL_COMMAND_NAME
- See Also:
- Constant Field Values
-
ROOT_USER
public static final String ROOT_USER
- See Also:
- Constant Field Values
-
-
Method Detail
-
isUNIX
public static boolean isUNIX()
- Returns:
- true if the host is a UNIX system (and not Windows).
-
isWin32
public static boolean isWin32()
- Returns:
- true if the host is Windows (and not UNIX).
- See Also:
OS_TYPE_OVERRIDE_PROP
,setWin32(Boolean)
-
setWin32
public static void setWin32(Boolean win32)
- Parameters:
win32
- The value to set - ifnull
then O/S type is auto-detected- See Also:
isWin32()
-
resolveDefaultInteractiveShellCommand
public static String resolveDefaultInteractiveShellCommand()
-
resolveDefaultInteractiveShellCommand
public static String resolveDefaultInteractiveShellCommand(boolean winOS)
-
resolveDefaultInteractiveCommandElements
public static List<String> resolveDefaultInteractiveCommandElements()
-
resolveDefaultInteractiveCommandElements
public static List<String> resolveDefaultInteractiveCommandElements(boolean winOS)
-
getCurrentUser
public static String getCurrentUser()
Get current user name- Returns:
- Current user
- See Also:
CURRENT_USER_OVERRIDE_PROP
-
getCanonicalUser
public static String getCanonicalUser(String user)
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
public static String resolveCanonicalGroup(String group, String user)
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
public static void setCurrentUser(String username)
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
public static VersionInfo 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(VersionInfo)
-
setJavaVersion
public static void setJavaVersion(VersionInfo version)
Set programmatically the reported Java version- Parameters:
version
- The version - ifnull
then it will be automatically resolved
-
-