cloudsoft / winrm4j

Apache License 2.0
93 stars 53 forks source link

Authorization issue #72

Closed andreaturli closed 7 years ago

andreaturli commented 7 years ago

Using 0.6.0-SNAPSHOT

I get the following error

Aug 31, 2017 6:38:49 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd}WinRmService#{http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd}Create has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139)
    at com.sun.proxy.$Proxy70.create(Unknown Source)
    at io.cloudsoft.winrm4j.client.WinRmClient$4.call(WinRmClient.java:779)
    at io.cloudsoft.winrm4j.client.WinRmClient$4.call(WinRmClient.java:774)
    at io.cloudsoft.winrm4j.client.WinRmClient.winrmCallRetryConnFailure(WinRmClient.java:871)
    at io.cloudsoft.winrm4j.client.WinRmClient.doCreateService_3_InitializeClientAndService(WinRmClient.java:774)
    at io.cloudsoft.winrm4j.client.WinRmClient.doCreateServiceWithReflectivelySetDelegate(WinRmClient.java:605)
    at io.cloudsoft.winrm4j.client.WinRmClient.createService(WinRmClient.java:534)
    at io.cloudsoft.winrm4j.client.WinRmClient.getService(WinRmClient.java:502)
    at io.cloudsoft.winrm4j.client.WinRmClient.command(WinRmClient.java:316)
    at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:243)
    at io.cloudsoft.winrm4j.winrm.WinRmTool.executeCommand(WinRmTool.java:181)
    at io.cloudsoft.winrm4j.winrm.AbstractWinRmToolLiveTest$3.call(AbstractWinRmToolLiveTest.java:177)
    at io.cloudsoft.winrm4j.winrm.AbstractWinRmToolLiveTest$3.call(AbstractWinRmToolLiveTest.java:174)
    at io.cloudsoft.winrm4j.winrm.AbstractWinRmToolLiveTest.callWithRetries(AbstractWinRmToolLiveTest.java:213)
    at io.cloudsoft.winrm4j.winrm.AbstractWinRmToolLiveTest.executeCommand(AbstractWinRmToolLiveTest.java:174)
    at io.cloudsoft.winrm4j.winrm.AbstractWinRmToolLiveTest.assertExecSucceeds(AbstractWinRmToolLiveTest.java:113)
    at io.cloudsoft.winrm4j.winrm.WinRmToolExecLiveTest.testExecScript(WinRmToolExecLiveTest.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
    at org.testng.TestRunner.privateRun(TestRunner.java:782)
    at org.testng.TestRunner.run(TestRunner.java:632)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
    at org.testng.SuiteRunner.run(SuiteRunner.java:268)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
    at org.testng.TestNG.run(TestNG.java:1064)
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '415: ' when communicating with http://34.252.134.251:5985/wsman
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.doProcessResponseCode(HTTPConduit.java:1608)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1615)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1559)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1356)
    at org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit$AsyncWrappedOutputStream.close(AsyncHTTPConduit.java:415)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:653)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    ... 47 more

from a server with the following config

 MaxConcurrentOperations = 4294967295
 MaxConcurrentOperationsPerUser = 1500
 EnumerationTimeoutms = 240000
 MaxConnections = 300
 MaxPacketRetrievalTimeSeconds = 120
 AllowUnencrypted = true
 Auth
     Basic = false
     Kerberos = true
     Negotiate = true
     Certificate = false
     CredSSP = true
     CbtHardeningLevel = Relaxed
 DefaultPorts
     HTTP = 5985
     HTTPS = 5986
 IPv4Filter = *
 IPv6Filter = *
 EnableCompatibilityHttpListener = false
 EnableCompatibilityHttpsListener = false
 CertificateThumbprint
 AllowRemoteAccess = true

Notice I've tested the creds from the windows server

winrs -r:10.0.2.15 -unencrypted -u:Administrator -p:my-passowrd ipconfig

which works fine.

@neykov any ideas would be appreciated!

neykov commented 7 years ago

HTTP response '415: is Unsupported Media Type. I've seen this with older CXF builds or when running the tests directly in Eclipse. winrm was sending the wrong content-type.

Is this a problem with 0.6.0-SNAPSHOT specifically? Does it depend on the Windows version? What content-type is winrm sending?

andreaturli commented 7 years ago

@neykov I'm not seeing with latest master from my IDE anymore. Thanks!