cloudsoft / winrm4j

Apache License 2.0
93 stars 53 forks source link

AuthSchemes uses just CredSSP and ignoring others #118

Open ni3mm4nd opened 4 years ago

ni3mm4nd commented 4 years ago

Hello

I'm facing strange issue. No matter what is set in authenticationScheme it uses CredSSP.

public WinRmTool getWinRmTool() {
        WinRmClientContext context = WinRmClientContext.newInstance();

        WinRmTool tool = WinRmTool.Builder.builder(apiLoginURL, apiUsername, apiPassword)
                .authenticationScheme(AuthSchemes.BASIC)
                .port(Integer.parseInt(apiPort))
                .useHttps(Boolean.parseBoolean(useHttps))
                .disableCertificateChecks(true)
                .context(context)
                .build();

        System.out.println(tool.executePs("Get-Date"));

        return tool;
    }

@PostConstruct
    public void executeGetDate() {
        getWinRmTool();
    }

Output log after application startup:

2020-03-10 08:36:22.174  INFO 2358 --- [           main] o.a.c.w.s.f.ReflectionServiceFactoryBean : Creating Service {http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd}WinRmService from WSDL: jar:file:/home/kadlec/.m2/repository/io/cloudsoft/windows/winrm4j-client/0.8.0/winrm4j-client-0.8.0.jar!/wsdl/WinRmService.wsdl
2020-03-10 08:36:22.697  WARN 2358 --- [/O dispatcher 1] o.a.h.i.c.TargetAuthenticationStrategy   : Authentication scheme CredSSP not supported
2020-03-10 08:36:22.704  WARN 2358 --- [           main] o.a.cxf.phase.PhaseInterceptorChain      : 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:67) ~[cxf-core-3.3.2.jar:3.3.2]

If some other method is set like NTLM it uses CredSSP still. Even simple string "Basic" does not work.