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 StringProperty that can be used to override the reported value fromgetCurrentUser().private static final AtomicReference<VersionInfo>static final StringProperty that can be used to override the reported value fromgetJavaVersion().static final Stringprivate static final AtomicReference<String>static final StringProperty that can be used to override the reported value fromisWin32().static final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetCanonicalUser(String user) RemoveWindowsdomain and/or group prefix as well as "(User);" suffixstatic StringgetComparablePath(String path) static StringGet current user namestatic VersionInfoResolves the reported Java version by consultingJAVA_VERSION_OVERRIDE_PROP.private static StringgetOS()static booleanisOSX()static booleanisUNIX()static booleanisWin32()static StringresolveCanonicalGroup(String group, String user) Attempts to resolve canonical group name forWindowsresolveDefaultInteractiveCommandElements(boolean winOS) static Stringstatic StringresolveDefaultInteractiveShellCommand(boolean winOS) static voidsetCurrentUser(String username) Can be used to programmatically set the username reported bygetCurrentUser()static voidsetJavaVersion(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
RemoveWindowsdomain and/or group prefix as well as "(User);" suffix- Parameters:
user- The original username - ignored ifnull/empty- Returns:
- The canonical user - unchanged if
UnixO/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 - ifnullthenCURRENT_USER_OVERRIDE_PROPwill 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 - ifnullthen 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
-