Class BasicConnection

  • All Implemented Interfaces:
    Connection

    public class BasicConnection
    extends java.lang.Object
    implements Connection
    This is the basic connection implementation that establishes an authenticated session with the STS Service, VC Service, and SPBM service in that order SPBM utilizes the per-authenticated http session cookie from the vCenter server for its authentication. The implementation provides Login functionality as follows: 1. Uses the sample AcquireHoKTokenByUserCredentialSample from the ssoclient sample set for acquiring a HoK token 2. Use this HoK token to perform LoginByToken using another sample LoginByTokenSample from the ssoclient sample set to establish authenticated session 3. Uses the authenticates session cookie from the established session and sets the PbmPortType to use the same session to make further SPBM API calls
    See Also:
    ConnectedServiceBase
    • Constructor Summary

      Constructors 
      Constructor Description
      BasicConnection()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Connection connect()
      Establishes the authenticated connection to the various services
      Connection disconnect()
      Disconnects all the services
      java.lang.String getPassword()
      Returns the password used for this connection
      com.vmware.pbm.PbmPortType getPbmPort()
      Returns the PbmPortType instance for the SPBM service
      com.vmware.pbm.PbmService getPbmService()
      Returns the PbmService instance for the SPBM service
      com.vmware.pbm.PbmServiceInstanceContent getPbmServiceContent()
      Returns the PbmServiceInstanceContentinstance for the SPBM service
      com.vmware.vim25.ManagedObjectReference getPbmServiceInstanceReference()
      Returns the ManagedObjectReference for the ServiceInstance for the SPBM Service
      java.net.URL getSpbmURL()
      Returns the SPBM Service URL
      java.net.URL getSsoURL()
      Will attempt to return the SSO URL you set from the command line, if you forgot or didn't set one it will call getDefaultSsoUrl to attempt to calculate what the URL should have been.
      java.lang.String getUsername()
      Returns the username used for this connection
      com.vmware.vim25.UserSession getUserSession()
      Returns the UserSession instance associated with the current connection
      java.net.URL getVcURL()
      Returns the vSphere web services URL
      com.vmware.vim25.VimPortType getVimPort()
      Returns the VimPortType instance for the vsphere service
      com.vmware.vim25.VimService getVimService()
      Returns the VimService instance for the vsphere service
      com.vmware.vim25.ServiceContent getVimServiceContent()
      Returns the ServiceContent instance for the vsphere service
      com.vmware.vim25.ManagedObjectReference getVimServiceInstanceReference()
      Returns the ManagedObjectReference for the ServiceInstance for the vsphere service
      boolean isConnected()
      Returns if an authenticated connection to the vCenter Server is established
      void setIgnoreCert​(java.lang.Boolean ignorecert)
      DEV ONLY option to ignore the SSL certificate check.
      void setPassword​(java.lang.String password)
      Password for the user to be used to acquire SAML token from the STS Service for accessing vCenter Server
      void setSpbmUrl​(java.lang.String spbmurl)
      SPBM Service URL e.g.
      void setSsoUrl​(java.lang.String ssourl)
      vCenter Single Sign-On STS service URL
      void setUsername​(java.lang.String username)
      Username to be used to acquire SAML token from the STS Service for accessing vCenter Server
      void setVcUrl​(java.lang.String vcurl)
      vSphere web services URL e.g https://\<vcenter>/sdk
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BasicConnection

        public BasicConnection()
    • Method Detail

      • connect

        public Connection connect()
        Description copied from interface: Connection
        Establishes the authenticated connection to the various services
        Specified by:
        connect in interface Connection
        Returns:
      • getPassword

        public java.lang.String getPassword()
        Description copied from interface: Connection
        Returns the password used for this connection
        Specified by:
        getPassword in interface Connection
        Returns:
      • getPbmPort

        public com.vmware.pbm.PbmPortType getPbmPort()
        Description copied from interface: Connection
        Returns the PbmPortType instance for the SPBM service
        Specified by:
        getPbmPort in interface Connection
        Returns:
      • getPbmService

        public com.vmware.pbm.PbmService getPbmService()
        Description copied from interface: Connection
        Returns the PbmService instance for the SPBM service
        Specified by:
        getPbmService in interface Connection
        Returns:
      • getPbmServiceContent

        public com.vmware.pbm.PbmServiceInstanceContent getPbmServiceContent()
        Description copied from interface: Connection
        Returns the PbmServiceInstanceContentinstance for the SPBM service
        Specified by:
        getPbmServiceContent in interface Connection
        Returns:
      • getPbmServiceInstanceReference

        public com.vmware.vim25.ManagedObjectReference getPbmServiceInstanceReference()
        Description copied from interface: Connection
        Returns the ManagedObjectReference for the ServiceInstance for the SPBM Service
        Specified by:
        getPbmServiceInstanceReference in interface Connection
        Returns:
      • getSpbmURL

        public java.net.URL getSpbmURL()
        Description copied from interface: Connection
        Returns the SPBM Service URL
        Specified by:
        getSpbmURL in interface Connection
        Returns:
      • getSsoURL

        public java.net.URL getSsoURL()
        Will attempt to return the SSO URL you set from the command line, if you forgot or didn't set one it will call getDefaultSsoUrl to attempt to calculate what the URL should have been.
        Specified by:
        getSsoURL in interface Connection
        Returns:
        the URL for the SSO services
      • getUsername

        public java.lang.String getUsername()
        Description copied from interface: Connection
        Returns the username used for this connection
        Specified by:
        getUsername in interface Connection
        Returns:
      • getUserSession

        public com.vmware.vim25.UserSession getUserSession()
        Description copied from interface: Connection
        Returns the UserSession instance associated with the current connection
        Specified by:
        getUserSession in interface Connection
        Returns:
      • getVcURL

        public java.net.URL getVcURL()
        Description copied from interface: Connection
        Returns the vSphere web services URL
        Specified by:
        getVcURL in interface Connection
        Returns:
      • getVimPort

        public com.vmware.vim25.VimPortType getVimPort()
        Description copied from interface: Connection
        Returns the VimPortType instance for the vsphere service
        Specified by:
        getVimPort in interface Connection
        Returns:
      • getVimService

        public com.vmware.vim25.VimService getVimService()
        Description copied from interface: Connection
        Returns the VimService instance for the vsphere service
        Specified by:
        getVimService in interface Connection
        Returns:
      • getVimServiceContent

        public com.vmware.vim25.ServiceContent getVimServiceContent()
        Description copied from interface: Connection
        Returns the ServiceContent instance for the vsphere service
        Specified by:
        getVimServiceContent in interface Connection
        Returns:
      • getVimServiceInstanceReference

        public com.vmware.vim25.ManagedObjectReference getVimServiceInstanceReference()
        Description copied from interface: Connection
        Returns the ManagedObjectReference for the ServiceInstance for the vsphere service
        Specified by:
        getVimServiceInstanceReference in interface Connection
        Returns:
      • isConnected

        public boolean isConnected()
        Description copied from interface: Connection
        Returns if an authenticated connection to the vCenter Server is established
        Specified by:
        isConnected in interface Connection
        Returns:
      • setIgnoreCert

        public void setIgnoreCert​(java.lang.Boolean ignorecert)
        Description copied from interface: Connection
        DEV ONLY option to ignore the SSL certificate check. DO NOT USE THIS OPTION FOR PRODUCTION CODE
        Specified by:
        setIgnoreCert in interface Connection
      • setPassword

        public void setPassword​(java.lang.String password)
        Description copied from interface: Connection
        Password for the user to be used to acquire SAML token from the STS Service for accessing vCenter Server
        Specified by:
        setPassword in interface Connection
      • setSpbmUrl

        public void setSpbmUrl​(java.lang.String spbmurl)
        Description copied from interface: Connection
        SPBM Service URL e.g. https://\<vcenter>/pbm
        Specified by:
        setSpbmUrl in interface Connection
      • setSsoUrl

        public void setSsoUrl​(java.lang.String ssourl)
        Description copied from interface: Connection
        vCenter Single Sign-On STS service URL
        Specified by:
        setSsoUrl in interface Connection
      • setUsername

        public void setUsername​(java.lang.String username)
        Description copied from interface: Connection
        Username to be used to acquire SAML token from the STS Service for accessing vCenter Server
        Specified by:
        setUsername in interface Connection
      • setVcUrl

        @Option(name="vcurl",
                systemProperty="vimService.url",
                description="full url to the vSphere WS SDK service on vCenter")
        public void setVcUrl​(java.lang.String vcurl)
        Description copied from interface: Connection
        vSphere web services URL e.g https://\<vcenter>/sdk
        Specified by:
        setVcUrl in interface Connection