Skip to content

Add support for WinRS shell command execution#31

Open
dino2gnt wants to merge 7 commits into
masterfrom
dcy/winrs-support
Open

Add support for WinRS shell command execution#31
dino2gnt wants to merge 7 commits into
masterfrom
dcy/winrs-support

Conversation

@dino2gnt
Copy link
Copy Markdown

@dino2gnt dino2gnt commented May 14, 2026

Add support for WinRS shell command execution to the wsman client library. This is built largely around mimicking how pywinrm does it, and what its wire format and soap envelopes looks like.

It is built with the expectation of short-lived shell sessions executing simple commands or scripts; it isn't designed with long-lived shell sessions or persistent remote shell interfaces as a requirement. The expectation is that this will be leveraged by OpenNMS within the context of a single poll or collection cycle and have a lifespan measured in ~seconds. The code changes were intended to be as self-contained and non-invasive to the existing library as possible.

I have function-tested this end to end in my lab against a Windows 2019 server, configured for Kerberos authenticated WinRM, using the CLI client jar.

I was heavily and shamefully assisted by Claude. I apologize to my future reviewers. (Except Copilot)

(03:44PM) dino2gnt@lard wsman $ java -Dsun.security.krb5.debug=false -Djava.security.krb5.conf=/etc/krb5.conf -Djava.security.auth.login.config=/tmp/login.conf -jar cli/target/org.opennms.core.wsman.cli-2.0.0-SNAPSHOT.jar -gssAuth -r https://dc18.ad.example.com:5986/wsman -w WSMAN_1_0 -o SHELL  -- ipconfig /all
[INFO ] org.opennms.core.wsman.WSManCli 2026-05-14 15:46:13.988 [main] WSManCli - Using endpoint: WSManEndpoint[url='https://dc18.ad.example.com:5986/wsman', isGSSAuth='true', isBasicAuth='false', isStrictSSL='false', serverVersion='WSMAN_1_0',  maxElements='100', maxEnvelopeSize='null'connectionTimeout='null', receiveTimeout='null']
[INFO ] org.opennms.core.wsman.WSManCli 2026-05-14 15:46:13.994 [main] WSManCli - Running WinRS command 'ipconfig' (timeout=60s)

Windows IP Configuration

   Host Name . . . . . . . . . . . . : dc18
   Primary Dns Suffix  . . . . . . . : ad.example.com
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : ad.example.com
                                       example.com

Ethernet adapter Ethernet Instance 0:

   Connection-specific DNS Suffix  . : example.com
   Description . . . . . . . . . . . : Red Hat VirtIO Ethernet Adapter
   Physical Address. . . . . . . . . : 52-54-00-90-4B-99
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv6 Address. . . . . . . . . . . : fdbe:36d6:2ade:6541:616d:8ff0:8f41:d09a(Preferred)
   Link-local IPv6 Address . . . . . : fe80::9d43:dc8a:b88a:d347%8(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.1.147(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.1
   DHCPv6 IAID . . . . . . . . . . . : 106058752
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-2E-D2-A9-B7-52-54-00-90-4B-99
   DNS Servers . . . . . . . . . . . : ::1
                                       192.168.1.149
                                       192.168.1.1
                                       127.0.0.1
   NetBIOS over Tcpip. . . . . . . . : Enabled
   Connection-specific DNS Suffix Search List :
                                       example.com
                                       ad.example.com
[INFO ] org.opennms.core.wsman.WSManCli 2026-05-14 15:46:15.270 [main] WSManCli - Command exited with code 0
(03:46PM) dino2gnt@lard wsman $ java -Dsun.security.krb5.debug=false -Djava.security.krb5.conf=/etc/krb5.conf -Djava.security.auth.login.config=/tmp/login.conf -jar cli/target/org.opennms.core.wsman.cli-2.0.0-SNAPSHOT.jar -gssAuth -r https://dc18.ad.example.com:5986/wsman -w WSMAN_1_0 -o SHELL  -- powershell Get-Service
[INFO ] org.opennms.core.wsman.WSManCli 2026-05-14 15:47:03.870 [main] WSManCli - Using endpoint: WSManEndpoint[url='https://dc18.ad.example.com:5986/wsman', isGSSAuth='true', isBasicAuth='false', isStrictSSL='false', serverVersion='WSMAN_1_0',  maxElements='100', maxEnvelopeSize='null'connectionTimeout='null', receiveTimeout='null']
[INFO ] org.opennms.core.wsman.WSManCli 2026-05-14 15:47:03.877 [main] WSManCli - Running WinRS command 'powershell' (timeout=60s)

Status   Name               DisplayName
------   ----               -----------
Running  ADWS               Active Directory Web Services
Stopped  AJRouter           AllJoyn Router Service
Stopped  ALG                Application Layer Gateway Service
Stopped  AppIDSvc           Application Identity
Running  Appinfo            Application Information
Stopped  AppMgmt            Application Management
Stopped  AppReadiness       App Readiness
Stopped  AppVClient         Microsoft App-V Client
Stopped  AppXSvc            AppX Deployment Service (AppXSVC)
Stopped  AudioEndpointBu... Windows Audio Endpoint Builder
Stopped  Audiosrv           Windows Audio
Stopped  AxInstSV           ActiveX Installer (AxInstSV)
Running  BalloonService     BalloonService
Running  BFE                Base Filtering Engine
Stopped  BITS               Background Intelligent Transfer Ser...
Running  BrokerInfrastru... Background Tasks Infrastructure Ser...
Stopped  BTAGService        Bluetooth Audio Gateway Service
Stopped  BthAvctpSvc        AVCTP service
Stopped  bthserv            Bluetooth Support Service
Stopped  camsvc             Capability Access Manager Service
Stopped  CaptureService_... CaptureService_6e1659
Stopped  cbdhsvc_6e1659     Clipboard User Service_6e1659
Running  CDPSvc             Connected Devices Platform Service
Running  CDPUserSvc_6e1659  Connected Devices Platform User Ser...
Running  CertPropSvc        Certificate Propagation
Stopped  ClipSVC            Client License Service (ClipSVC)
Stopped  COMSysApp          COM+ System Application
Stopped  ConsentUxUserSv... ConsentUX_6e1659
Running  CoreMessagingRe... CoreMessaging
Running  CryptSvc           Cryptographic Services
Stopped  CscService         Offline Files
Running  DcomLaunch         DCOM Server Process Launcher
Stopped  defragsvc          Optimize drives
Stopped  DeviceAssociati... Device Association Service
Stopped  DeviceInstall      Device Install Service
Stopped  DevicePickerUse... DevicePicker_6e1659
Stopped  DevicesFlowUser... DevicesFlow_6e1659
Stopped  DevQueryBroker     DevQuery Background Discovery Broker
Running  Dfs                DFS Namespace
Running  DFSR               DFS Replication
Running  Dhcp               DHCP Client
Stopped  diagnosticshub.... Microsoft (R) Diagnostics Hub Stand...
Running  DiagTrack          Connected User Experiences and Tele...
Stopped  DmEnrollmentSvc    Device Management Enrollment Service
Stopped  dmwappushservice   Device Management Wireless Applicat...
Running  DNS                DNS Server
Running  Dnscache           DNS Client
Stopped  DoSvc              Delivery Optimization
Stopped  dot3svc            Wired AutoConfig
Running  DPS                Diagnostic Policy Service
Stopped  DsmSvc             Device Setup Manager
Stopped  DsRoleSvc          DS Role Server
Running  DsSvc              Data Sharing Service
Stopped  Eaphost            Extensible Authentication Protocol
Stopped  EFS                Encrypting File System (EFS)
Stopped  embeddedmode       Embedded Mode
Stopped  EntAppSvc          Enterprise App Management Service
Running  EventLog           Windows Event Log
Running  EventSystem        COM+ Event System
Running  fdPHost            Function Discovery Provider Host
Running  FDResPub           Function Discovery Resource Publica...
Running  FontCache          Windows Font Cache Service
Stopped  FrameServer        Windows Camera Frame Server
Running  gpsvc              Group Policy Client
Stopped  GraphicsPerfSvc    GraphicsPerfSvc
Stopped  hidserv            Human Interface Device Service
Stopped  HvHost             HV Host Service
Stopped  icssvc             Windows Mobile Hotspot Service
Stopped  IKEEXT             IKE and AuthIP IPsec Keying Modules
Stopped  InstallService     Microsoft Store Install Service
Running  iphlpsvc           IP Helper
Running  IsmServ            Intersite Messaging
Running  Kdc                Kerberos Key Distribution Center
Stopped  KdsSvc             Microsoft Key Distribution Service
Running  KeyIso             CNG Key Isolation
Stopped  KPSSVC             KDC Proxy Server service (KPS)
Stopped  KtmRm              KtmRm for Distributed Transaction C...
Running  LanmanServer       Server
Running  LanmanWorkstation  Workstation
Stopped  lfsvc              Geolocation Service
Running  LicenseManager     Windows License Manager Service
Stopped  lltdsvc            Link-Layer Topology Discovery Mapper
Running  lmhosts            TCP/IP NetBIOS Helper
Running  LSM                Local Session Manager
Stopped  MapsBroker         Downloaded Maps Manager
Running  MDCoreSvc          Microsoft Defender Core Service
Running  mpssvc             Windows Defender Firewall
Running  MSDTC              Distributed Transaction Coordinator
Stopped  MSiSCSI            Microsoft iSCSI Initiator Service
Stopped  msiserver          Windows Installer
Stopped  NcaSvc             Network Connectivity Assistant
Running  NcbService         Network Connection Broker
Running  Netlogon           Netlogon
Stopped  Netman             Network Connections
Running  netprofm           Network List Service
Stopped  NetSetupSvc        Network Setup Service
Stopped  NetTcpPortSharing  Net.Tcp Port Sharing Service
Stopped  NgcCtnrSvc         Microsoft Passport Container
Stopped  NgcSvc             Microsoft Passport
Running  NlaSvc             Network Location Awareness
Running  nsi                Network Store Interface Service
Running  NTDS               Active Directory Domain Services
Stopped  NtFrs              File Replication
Running  PcaSvc             Program Compatibility Assistant Ser...
Stopped  PerfHost           Performance Counter DLL Host
Stopped  PhoneSvc           Phone Service
Stopped  PimIndexMainten... Contact Data_6e1659
Stopped  pla                Performance Logs & Alerts
Running  PlugPlay           Plug and Play
Running  PolicyAgent        IPsec Policy Agent
Running  Power              Power
Stopped  PrintNotify        Printer Extensions and Notifications
Stopped  PrintWorkflowUs... PrintWorkflow_6e1659
Running  ProfSvc            User Profile Service
Stopped  PushToInstall      Windows PushToInstall Service
Stopped  QWAVE              Quality Windows Audio Video Experience
Stopped  RasAuto            Remote Access Auto Connection Manager
Running  RasMan             Remote Access Connection Manager
Stopped  RemoteAccess       Routing and Remote Access
Stopped  RemoteRegistry     Remote Registry
Stopped  RmSvc              Radio Management Service
Running  RpcEptMapper       RPC Endpoint Mapper
Stopped  RpcLocator         Remote Procedure Call (RPC) Locator
Running  RpcSs              Remote Procedure Call (RPC)
Stopped  RSoPProv           Resultant Set of Policy Provider
Stopped  sacsvr             Special Administration Console Helper
Running  SamSs              Security Accounts Manager
Stopped  SCardSvr           Smart Card
Running  ScDeviceEnum       Smart Card Device Enumeration Service
Running  Schedule           Task Scheduler
Stopped  SCPolicySvc        Smart Card Removal Policy
Stopped  seclogon           Secondary Logon
Running  SecurityHealthS... Windows Security Service
Stopped  SEMgrSvc           Payments and NFC/SE Manager
Running  SENS               System Event Notification Service
Stopped  Sense              Windows Defender Advanced Threat Pr...
Stopped  SensorDataService  Sensor Data Service
Stopped  SensorService      Sensor Service
Stopped  SensrSvc           Sensor Monitoring Service
Running  SessionEnv         Remote Desktop Configuration
Stopped  SgrmBroker         System Guard Runtime Monitor Broker
Stopped  SharedAccess       Internet Connection Sharing (ICS)
Running  ShellHWDetection   Shell Hardware Detection
Stopped  shpamsvc           Shared PC Account Manager
Stopped  smphost            Microsoft Storage Spaces SMP
Stopped  SNMPTRAP           SNMP Trap
Running  Spooler            Print Spooler
Stopped  sppsvc             Software Protection
Stopped  SSDPSRV            SSDP Discovery
Stopped  ssh-agent          OpenSSH Authentication Agent
Running  sshd               OpenSSH SSH Server
Running  SstpSvc            Secure Socket Tunneling Protocol Se...
Running  StateRepository    State Repository Service
Stopped  stisvc             Windows Image Acquisition (WIA)
Running  StorSvc            Storage Service
Stopped  svsvc              Spot Verifier
Stopped  swprv              Microsoft Software Shadow Copy Prov...
Running  SysMain            SysMain
Running  SystemEventsBroker System Events Broker
Running  TabletInputService Touch Keyboard and Handwriting Pane...
Stopped  tapisrv            Telephony
Running  TermService        Remote Desktop Services
Running  Themes             Themes
Stopped  TieringEngineSe... Storage Tiers Management
Running  TimeBrokerSvc      Time Broker
Running  TokenBroker        Web Account Manager
Stopped  TrkWks             Distributed Link Tracking Client
Stopped  TrustedInstaller   Windows Modules Installer
Stopped  tzautoupdate       Auto Time Zone Updater
Running  UALSVC             User Access Logging Service
Stopped  UevAgentService    User Experience Virtualization Service
Running  UmRdpService       Remote Desktop Services UserMode Po...
Stopped  UnistoreSvc_6e1659 User Data Storage_6e1659
Stopped  upnphost           UPnP Device Host
Stopped  UserDataSvc_6e1659 User Data Access_6e1659
Running  UserManager        User Manager
Running  UsoSvc             Update Orchestrator Service
Stopped  VaultSvc           Credential Manager
Running  vds                Virtual Disk
Stopped  VirtioFsSvc        VirtIO-FS Service
Stopped  vmicguestinterface Hyper-V Guest Service Interface
Stopped  vmicheartbeat      Hyper-V Heartbeat Service
Stopped  vmickvpexchange    Hyper-V Data Exchange Service
Stopped  vmicrdv            Hyper-V Remote Desktop Virtualizati...
Stopped  vmicshutdown       Hyper-V Guest Shutdown Service
Stopped  vmictimesync       Hyper-V Time Synchronization Service
Stopped  vmicvmsession      Hyper-V PowerShell Direct Service
Stopped  vmicvss            Hyper-V Volume Shadow Copy Requestor
Stopped  VSS                Volume Shadow Copy
Running  W32Time            Windows Time
Stopped  WaaSMedicSvc       Windows Update Medic Service
Stopped  WalletService      WalletService
Stopped  WarpJITSvc         WarpJITSvc
Stopped  WbioSrvc           Windows Biometric Service
Running  Wcmsvc             Windows Connection Manager
Stopped  WdiServiceHost     Diagnostic Service Host
Running  WdiSystemHost      Diagnostic System Host
Running  WdNisSvc           Microsoft Defender Antivirus Networ...
Stopped  Wecsvc             Windows Event Collector
Stopped  WEPHOSTSVC         Windows Encryption Provider Host Se...
Stopped  wercplsupport      Problem Reports and Solutions Contr...
Stopped  WerSvc             Windows Error Reporting Service
Stopped  WiaRpc             Still Image Acquisition Events
Running  WinDefend          Microsoft Defender Antivirus Service
Running  windows_exporter   windows_exporter
Running  WinHttpAutoProx... WinHTTP Web Proxy Auto-Discovery Se...
Running  Winmgmt            Windows Management Instrumentation
Running  WinRM              Windows Remote Management (WS-Manag...
Stopped  wisvc              Windows Insider Service
Stopped  wlidsvc            Microsoft Account Sign-in Assistant
Running  WLMS               Windows Licensing Monitoring Service
Stopped  wmiApSrv           WMI Performance Adapter
Stopped  WMPNetworkSvc      Windows Media Player Network Sharin...
Stopped  WPDBusEnum         Portable Device Enumerator Service
Running  WpnService         Windows Push Notifications System S...
Running  WpnUserService_... Windows Push Notifications User Ser...
Stopped  WSearch            Windows Search
Stopped  wuauserv           Windows Update


[INFO ] org.opennms.core.wsman.WSManCli 2026-05-14 15:47:06.498 [main] WSManCli - Command exited with code 0

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds WinRS (MS-WSMV) “shell command execution” support to the wsman client library, including a WinRS orchestration client, CXF-backed wire operations, SOAP body/header builders, public API types, and CLI support.

Changes:

  • Introduces a WinRS shell orchestration flow (Create → Command → Receive loop → Delete) with parsing/building utilities under cxf/.../shell.
  • Extends the public WSManClient API with runCommand(...) and adds new shell API types (ShellOptions, CommandResult).
  • Adds a new CLI operation (-o SHELL) and adjusts CLI shaded dependencies to use javax.* APIs.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
cxf/src/test/java/org/opennms/core/wsman/cxf/shell/WinRSClientTest.java Adds unit tests for WinRS lifecycle orchestration and edge cases.
cxf/src/test/java/org/opennms/core/wsman/cxf/shell/ShellSoapHeadersTest.java Adds unit tests for SOAP header element builders (partial coverage).
cxf/src/test/java/org/opennms/core/wsman/cxf/shell/ShellResponseParserTest.java Adds unit tests for response parsing (ShellId/CommandId/Receive).
cxf/src/test/java/org/opennms/core/wsman/cxf/shell/ShellBodyBuilderTest.java Adds unit tests for SOAP body builders for Create/Command/Receive/Signal/Delete.
cxf/src/main/java/org/opennms/core/wsman/cxf/shell/WinRSClient.java Implements WinRS orchestration client (Create/Command/Receive/Terminate/Delete).
cxf/src/main/java/org/opennms/core/wsman/cxf/shell/ShellSoapHeaders.java Adds builders for WS-Man SOAP header elements needed for WinRS.
cxf/src/main/java/org/opennms/core/wsman/cxf/shell/ShellResponseParser.java Adds DOM-based parsing for WinRS responses and Receive stream decoding.
cxf/src/main/java/org/opennms/core/wsman/cxf/shell/ShellOperations.java Defines transport-agnostic interface for the 5 WinRS operations.
cxf/src/main/java/org/opennms/core/wsman/cxf/shell/ShellConstants.java Adds protocol constants (URIs, actions, stream names, command states).
cxf/src/main/java/org/opennms/core/wsman/cxf/shell/ShellBodyBuilder.java Adds DOM builders for WinRS SOAP bodies (Create/Command/Receive/Signal).
cxf/src/main/java/org/opennms/core/wsman/cxf/shell/CxfShellOperations.java Implements WinRS operations using CXF Dispatch with per-request headers.
cxf/src/main/java/org/opennms/core/wsman/cxf/CXFWSManClient.java Wires runCommand(...) into the existing CXF WS-Man client implementation.
cli/src/main/java/org/opennms/core/wsman/WSManCli.java Adds SHELL operation and argument parsing via -- sentinel + timeout flag.
cli/pom.xml Switches CLI shaded JAXB/JAX-WS APIs to javax.* (2.3.1) for CXF 3.5.x compatibility.
api/src/main/java/org/opennms/core/wsman/WSManClient.java Extends public API with runCommand(...) (+ default overload).
api/src/main/java/org/opennms/core/wsman/shell/ShellOptions.java Adds shell options type (no-profile, codepage, idle timeout, env, working dir).
api/src/main/java/org/opennms/core/wsman/shell/CommandResult.java Adds command result type (exit code + stdout/stderr strings).
Comments suppressed due to low confidence (3)

cxf/src/main/java/org/opennms/core/wsman/cxf/shell/ShellSoapHeaders.java:137

  • String.format(...) uses the default JVM Locale; in locales that use ',' as the decimal separator this will emit something like "PT60,000S", which is not a valid ISO-8601 duration for OperationTimeout. Use String.format(Locale.ROOT, ...) (or equivalent) to guarantee '.' as the separator.
    public static Element operationTimeout(Duration timeout) {
        Document doc = newDocument();
        Element el = doc.createElementNS(WSManConstants.XML_NS_DMTF_WSMAN_V1, "wsman:OperationTimeout");
        long millis = timeout.toMillis();
        long whole = millis / 1000;
        long frac = millis % 1000;
        el.setTextContent(String.format("PT%d.%03dS", whole, frac));
        return el;

cxf/src/main/java/org/opennms/core/wsman/cxf/shell/ShellSoapHeaders.java:95

  • The optionSet() Javadoc says it "Returns null if both are at defaults" but the implementation always creates and returns an OptionSet (and the comment below says so too). Please align the Javadoc with actual behavior to avoid misleading callers.
    /**
     * Builds {@code <wsman:OptionSet>} for the standard WinRS shell options:
     * {@code WINRS_NOPROFILE} and {@code WINRS_CODEPAGE}. Returns {@code null} if both
     * are at defaults that the server would already assume — but in practice we always
     * emit at least the code page to avoid surprises, so we always return a non-null
     * element when called.
     */

cxf/src/main/java/org/opennms/core/wsman/cxf/shell/ShellSoapHeaders.java:151

  • maxEnvelopeSize(), operationTimeout(), and locale() are new public helpers but currently have no unit tests, while resourceUri/selectorSet/optionSet do. Adding focused tests here would help prevent subtle wire-format regressions (attributes/namespaces/formatting).
    /**
     * Builds {@code <wsman:MaxEnvelopeSize mustUnderstand="true">N</wsman:MaxEnvelopeSize>}.
     * WinRM rejects shell Create requests that omit this header (the MS-WSMV reference
     * envelope marks it as {@code mustUnderstand}). The pywinrm default is 153600 bytes.
     */
    public static Element maxEnvelopeSize(long bytes) {
        Document doc = newDocument();
        Element el = doc.createElementNS(WSManConstants.XML_NS_DMTF_WSMAN_V1, "wsman:MaxEnvelopeSize");
        el.setAttributeNS("http://www.w3.org/2003/05/soap-envelope", "soap:mustUnderstand", "true");
        el.setTextContent(Long.toString(bytes));
        return el;
    }

    /**
     * Builds {@code <wsman:OperationTimeout>PT…S</wsman:OperationTimeout>}. Formats the
     * {@link Duration} as an ISO-8601 duration string with millisecond precision, e.g.
     * {@code PT60.000S}, which is what pywinrm and the MS-WSMV reference envelopes emit.
     */
    public static Element operationTimeout(Duration timeout) {
        Document doc = newDocument();
        Element el = doc.createElementNS(WSManConstants.XML_NS_DMTF_WSMAN_V1, "wsman:OperationTimeout");
        long millis = timeout.toMillis();
        long whole = millis / 1000;
        long frac = millis % 1000;
        el.setTextContent(String.format("PT%d.%03dS", whole, frac));
        return el;
    }

    /**
     * Builds {@code <wsman:Locale xml:lang="…" mustUnderstand="false"/>}. WinRM uses this
     * to pick the language of error messages; the element is required to be present even
     * when the value doesn't matter for the operation.
     */
    public static Element locale(String langTag) {
        Document doc = newDocument();
        Element el = doc.createElementNS(WSManConstants.XML_NS_DMTF_WSMAN_V1, "wsman:Locale");
        el.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:lang", langTag);
        el.setAttributeNS("http://www.w3.org/2003/05/soap-envelope", "soap:mustUnderstand", "false");
        return el;
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cxf/src/main/java/org/opennms/core/wsman/cxf/shell/WinRSClient.java
Comment thread cxf/src/main/java/org/opennms/core/wsman/cxf/shell/WinRSClient.java Outdated
Comment thread cxf/src/main/java/org/opennms/core/wsman/cxf/shell/WinRSClient.java
Comment thread cxf/src/main/java/org/opennms/core/wsman/cxf/shell/CxfShellOperations.java Outdated
Comment thread cxf/src/main/java/org/opennms/core/wsman/cxf/shell/ShellSoapHeaders.java Outdated
Comment thread api/src/main/java/org/opennms/core/wsman/shell/ShellOptions.java
Comment thread api/src/main/java/org/opennms/core/wsman/WSManClient.java Outdated
Comment thread cli/src/main/java/org/opennms/core/wsman/WSManCli.java
Comment thread cli/src/main/java/org/opennms/core/wsman/WSManCli.java
dino2gnt and others added 5 commits May 15, 2026 18:41
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Comment on lines +133 to +137
long millis = timeout.toMillis();
long whole = millis / 1000;
long frac = millis % 1000;
el.setTextContent(String.format("PT%d.%03dS", whole, frac));
return el;
Comment on lines +23 to +32
/**
* Options passed to {@code rsp:Shell} on shell creation. Defaults are tuned for monitoring
* workloads: skip user profile load, UTF-8 code page, short idle timeout.
*/
public final class ShellOptions {
private final boolean noProfile;
private final int codepage;
private final Duration idleTimeout;
private final String workingDirectory;
private final Map<String, String> environment;
Comment on lines +54 to +71
public static Element buildCreateBody(ShellOptions options) {
Document doc = newDocument();
Element shell = doc.createElementNS(ShellConstants.NS_SHELL, "rsp:Shell");
doc.appendChild(shell);

Element inputStreams = doc.createElementNS(ShellConstants.NS_SHELL, "rsp:InputStreams");
inputStreams.setTextContent(ShellConstants.STREAM_STDIN);
shell.appendChild(inputStreams);

Element outputStreams = doc.createElementNS(ShellConstants.NS_SHELL, "rsp:OutputStreams");
outputStreams.setTextContent(ShellConstants.STREAM_STDOUT + " " + ShellConstants.STREAM_STDERR);
shell.appendChild(outputStreams);

if (options.getWorkingDirectory() != null && !options.getWorkingDirectory().isEmpty()) {
Element wd = doc.createElementNS(ShellConstants.NS_SHELL, "rsp:WorkingDirectory");
wd.setTextContent(options.getWorkingDirectory());
shell.appendChild(wd);
}
Comment on lines +231 to +240
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DOMResult result = new DOMResult(dbf.newDocumentBuilder().newDocument());
TransformerFactory.newInstance().newTransformer().transform(response, result);
Document doc = (Document) result.getNode();
return doc == null ? null : doc.getDocumentElement();
} catch (Exception e) {
throw new IllegalStateException("Failed to materialise shell response Source to DOM", e);
}
TrustManager[] simpleTrustManager = new TrustManager[] { new X509TrustManager() {
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants