Class WinRMEndpoint

java.lang.Object
org.metricshub.winrm.service.WinRMEndpoint

public class WinRMEndpoint extends Object
  • Constructor Details

    • WinRMEndpoint

      public WinRMEndpoint(WinRMHttpProtocolEnum protocol, String hostname, Integer port, String username, char[] password, String namespace)
      Constructor of the endpoint and credentials for WinRM.
      Parameters:
      protocol - The protocol
      hostname - The host name (mandatory)
      port - The port
      username - The user name (mandatory)
      password - The password (mandatory)
      namespace - The namespace default value: "ROOT\\CIMV2"
  • Method Details

    • getHostname

      public String getHostname()
      Get the hostname
    • getEndpoint

      public String getEndpoint()
      Get the endpoint in the form of http(s)://host:port/wsman
    • getDomain

      public String getDomain()
      Get the domain from the raw username
    • getRawUsername

      public String getRawUsername()
      Get the username exactly as supplied in the constructor (could be in domain\\user form, and may contain the whitespace the caller typed). The getDomain() / getUsername() parts are the whitespace-normalized split of this value, which is what the protocols send.
    • getUsername

      public String getUsername()
      Get the username part of the raw username
    • getPassword

      public char[] getPassword()
      Get the password
    • getNamespace

      public String getNamespace()
      Get the namespace
    • getProtocol

      public WinRMHttpProtocolEnum getProtocol()
      Get the protocol
    • getPort

      public int getPort()
      Get the resolved endpoint port (the port provided to the constructor, or the protocol default).
    • buildEndpointUrl

      public static String buildEndpointUrl(WinRMHttpProtocolEnum protocol, String hostname, Integer port)
      Build the endpoint URL.
      Parameters:
      protocol - The HTTP protocol
      hostname - The host name
      port - The port
      Returns:
      the endpoint URL in form of protocol://hostname:port (with protocol in HTTP or HTTPS).
    • getEndpointPort

      public static int getEndpointPort(WinRMHttpProtocolEnum protocol, Integer port)
      Get the endpoint port:
      • The port if provided
      • 5986 if the protocol is HTTPS
      • 5985 otherwise
      Parameters:
      protocol - The HTTP protocol
      port - The port
      Returns:
      The endpoint port
    • buildNamespace

      public static String buildNamespace(String namespace)
      Get the namespace and replace '\' by '/' if necessary default: "ROOT\\CIMV2" if null
      Parameters:
      namespace - the provided namespace
      Returns:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object