Package org.sentrysoftware.winrm.service
Class WinRMService
java.lang.Object
org.sentrysoftware.winrm.service.WinRMService
- All Implemented Interfaces:
AutoCloseable
,WindowsRemoteExecutor
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Check if it's connected.void
close()
static WinRMService
createInstance
(WinRMEndpoint winRMEndpoint, long timeout, Path ticketCache, List<AuthenticationEnum> authentications) Create a WinRMService instancestatic WinRMInvocationHandler
createWinRMInvocationHandlerInstance
(WinRMEndpoint winRMEndpoint, org.apache.cxf.Bus bus, long timeout, String resourceUri, Path ticketCache, List<AuthenticationEnum> authentications) int
executeCommand
(String command, String workingDirectory, Charset charset, long timeout) Execute the command on the remoteexecuteWql
(String wqlQuery, long timeout) Execute a WQL query and process its result.getContextIdFrom
(EnumerationContextType context) Get the hostname.boolean
getItemsFrom
(EnumerateResponse response, List<Node> items) Retrieves the list of items from the given response, adding them to the given list and returns true if the response contains an 'end-of-sequence' marker.char[]
Get the password.int
Get the username.boolean
-
Field Details
-
DEFAULT_AUTHENTICATION
-
-
Method Details
-
createInstance
public static WinRMService createInstance(WinRMEndpoint winRMEndpoint, long timeout, Path ticketCache, List<AuthenticationEnum> authentications) throws WinRMException Create a WinRMService instance- Parameters:
winRMEndpoint
- Endpoint with credentials (mandatory)timeout
- Timeout used for Connection, Connection Request and Receive Request in milliseconds (throws an IllegalArgumentException if negative or zero)ticketCache
- The Ticket Cache pathauthentications
- List of authentications. only NTLM if absent- Returns:
- WinRMService instance
- Throws:
WinRMException
- For any problem encountered
-
getUseCount
public int getUseCount() -
isConnected
public boolean isConnected()- Returns:
- whether this WbemServices instance is connected and usable
-
checkConnectedFirst
public void checkConnectedFirst()Check if it's connected. If not, throw an IllegalStateException. -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
executeCommand
public WindowsRemoteCommandResult executeCommand(String command, String workingDirectory, Charset charset, long timeout) throws WinRMException, TimeoutException Description copied from interface:WindowsRemoteExecutor
Execute the command on the remote- Specified by:
executeCommand
in interfaceWindowsRemoteExecutor
- Parameters:
command
- The command to executeworkingDirectory
- Path of the directory for the spawned process on the remote system (can be null)charset
- The charsettimeout
- Timeout in milliseconds- Returns:
- The command result
- Throws:
TimeoutException
- To notify userName of timeout.WinRMException
-
executeWql
public List<Map<String,Object>> executeWql(String wqlQuery, long timeout) throws WinRMException, WqlQuerySyntaxException, TimeoutException Description copied from interface:WindowsRemoteExecutor
Execute a WQL query and process its result.
- Specified by:
executeWql
in interfaceWindowsRemoteExecutor
- Parameters:
wqlQuery
- the WQL query (required)timeout
- Timeout in milliseconds (throws an IllegalArgumentException if negative or zero)- Returns:
- a list of result rows. A result row is a Map(LinkedHashMap to preserve the query order) of properties/values.
- Throws:
WqlQuerySyntaxException
- if WQL query syntax is invalidTimeoutException
- to notify userName of timeout.WinRMException
-
createWinRMInvocationHandlerInstance
public static WinRMInvocationHandler createWinRMInvocationHandlerInstance(WinRMEndpoint winRMEndpoint, org.apache.cxf.Bus bus, long timeout, String resourceUri, Path ticketCache, List<AuthenticationEnum> authentications) -
enumerate
-
pull
- Throws:
WinRMException
-
create
-
execute
- Throws:
WinRMException
-
getItemsFrom
Retrieves the list of items from the given response, adding them to the given list and returns true if the response contains an 'end-of-sequence' marker.- Throws:
WinRMException
-
getContextIdFrom
- Throws:
WinRMException
-
getShellSelector
-
getHostname
Description copied from interface:WindowsRemoteExecutor
Get the hostname.- Specified by:
getHostname
in interfaceWindowsRemoteExecutor
- Returns:
-
getUsername
Description copied from interface:WindowsRemoteExecutor
Get the username.- Specified by:
getUsername
in interfaceWindowsRemoteExecutor
- Returns:
-
getPassword
public char[] getPassword()Description copied from interface:WindowsRemoteExecutor
Get the password.- Specified by:
getPassword
in interfaceWindowsRemoteExecutor
- Returns:
-