Package com.vmware.vsphere.samples
Class LoginByTokenSample
- java.lang.Object
-
- com.vmware.vsphere.samples.LoginByTokenSample
-
public class LoginByTokenSample extends java.lang.ObjectSample program demonstrating the usage of the new LoginByToken method, introduced to authenticate the client using the SAML token obtained from the SSO server. This sample illustrates the usage of both Bearer token as well as the HolderOfKey token for authenticating to a vCenter serverUsage: run.bat com.vmware.vsphere.samples.LoginByTokenSample [sso url] [username] [password] [vCenter url]
-
-
Field Summary
Fields Modifier and Type Field Description static com.vmware.vim25.ManagedObjectReferenceSVC_INST_REFstatic com.vmware.vim25.VimPortTypevimPort
-
Constructor Summary
Constructors Constructor Description LoginByTokenSample()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidgetCurrentTime()This method retrieves the current time from the server and prints it.static java.lang.StringloginUsingSAMLToken(org.w3c.dom.Element token, java.lang.String vcServerUrl, java.security.PrivateKey privateKey, java.security.cert.X509Certificate publicCert)This method invokes the loginByToken method for authentication.static voidlogout()Disconnects the user session.static voidmain(java.lang.String[] args)
-
-
-
Method Detail
-
getCurrentTime
public static void getCurrentTime()
This method retrieves the current time from the server and prints it.
-
loginUsingSAMLToken
public static java.lang.String loginUsingSAMLToken(org.w3c.dom.Element token, java.lang.String vcServerUrl, java.security.PrivateKey privateKey, java.security.cert.X509Certificate publicCert) throws com.vmware.vim25.RuntimeFaultFaultMsg, com.vmware.vim25.InvalidLocaleFaultMsg, com.vmware.vim25.InvalidLoginFaultMsgThis 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- Parameters:
token-Elementrepresenting the SAML token that needs to be used for the authenticationvcServerUrl- The vCenter server url that needs to be connectedprivateKey-PrivateKeyof the user. Only required when using HoK token to loginpublicCert-X509Certificatecertificate of the user. Only required when using HoK token to login- Returns:
- String authenticated session cookie used by the connection
- Throws:
com.vmware.vim25.RuntimeFaultFaultMsgcom.vmware.vim25.InvalidLocaleFaultMsgcom.vmware.vim25.InvalidLoginFaultMsg
-
logout
public static void logout() throws com.vmware.vim25.RuntimeFaultFaultMsgDisconnects the user session.- Throws:
com.vmware.vim25.RuntimeFaultFaultMsg
-
main
public static void main(java.lang.String[] args) throws javax.xml.datatype.DatatypeConfigurationException, com.vmware.vim25.RuntimeFaultFaultMsg, com.vmware.vim25.InvalidLocaleFaultMsg, com.vmware.vim25.InvalidLoginFaultMsg- Throws:
javax.xml.datatype.DatatypeConfigurationExceptioncom.vmware.vim25.RuntimeFaultFaultMsgcom.vmware.vim25.InvalidLocaleFaultMsgcom.vmware.vim25.InvalidLoginFaultMsg
-
-