}
};
}
public void authenticateUser(String name, String password) throws Exception {
Client vmomiClient = null;
try {
URI uri = new URI(serviceUrl);
HttpConfiguration httpConfig = new HttpConfigurationImpl();
httpConfig.setThumbprintVerifier(getThumbprintVerifier());
HttpClientConfiguration clientConfig =
HttpClientConfiguration.Factory.newInstance();
clientConfig.setHttpConfiguration(httpConfig);
vmomiClient = Client.Factory.createClient(uri, version, clientConfig);
ManagedObjectReference svcRef = new ManagedObjectReference();
svcRef.setType("ServiceInstance");
svcRef.setValue("ServiceInstance");
ServiceInstance instance =
vmomiClient.createStub(ServiceInstance.class, svcRef);
ServiceInstanceContent instanceContent = instance.retrieveContent();
SessionManager sessionManager =
vmomiClient.createStub(SessionManager.class,
instanceContent.getSessionManager());
sessionManager.login(name, password, sessionManager.getDefaultLocale());
sessionManager.logout();
} finally {
if (vmomiClient != null) {
vmomiClient.shutdown();
}
}
}