Get the VimPort for LoginByToken in Java

The following example shows the code to get the VimPort:

Getting the VimPort

package com.vmware.vsphere.samples;

/**
* Sample program demonstrating the usage of the new loginByToken method,
* introduced to authenticate the client using the SAML token obtained from the
* SSO server.
*
* @author VMware, Inc.
*/
public class LoginByTokenExample {
/**
* This method invokes the loginByToken method for authentication. Once this
* method is called the established session is authenticated and operations
* can be performed on the connected vCenter server
*
* @param token
* {@link Element} representing the SAML token that needs to be
* used for the authentication
* @param vcServerUrl
* The vCenter server URL that needs to be connected
* @return String authenticated session cookie used by the connection
* @throws RuntimeFaultFaultMsg
* @throws InvalidLocaleFaultMsg
*/
public static String loginUsingSAMLToken(Element token, String vcServerUrl)
throws RuntimeFaultFaultMsg, InvalidLocaleFaultMsg,
InvalidLoginFaultMsg {
VimService vimService = new VimService();
HandlerResolver defaultHandler = vimService.getHandlerResolver();

// Step 1 Get the VimPort object
vimService = new VimService();
VimPortType vimPort = vimService.getVimPort();