The example is based on the code in the ExternalPscSsoWorkflow.java sample.

Note

For a complete and up-to-date version of the sample code, see the vSphere Automation SDK Java samples at GitHub.

... 

LookupServiceHelper lookupServiceHelper = new LookupServiceHelper(
            this.lookupServiceUrl);

System.out.println("\nStep 2: Discover the Single Sign-On service URL"
                   + " from lookup service.");
String ssoUrl = lookupServiceHelper.findSsoUrl();

System.out.println("\nStep 3: Connect to the Single Sign-On URL and "
                   + "retrieve the SAML bearer token.");
SamlToken samlBearerToken = SsoHelper.getSamlBearerToken(ssoUrl,
    username,
    password);