VMware Cloud Community
ScottLaser
Contributor
Contributor
Jump to solution

Accessing Objects in Third-Party Systems

Using the code snippet found in "Accessing Objects in Third-Party Systems" section of the vSphere 5.5 Documentation Center, I found a problem I can't overcome. 

Code snippet (straight from the documentation):

URI uri = URI.create("https://orchestrator1:8283/vco/api");

    VcoSessionFactory sessionFactory = new DefaultVcoSessionFactory(uri);

    //provide the address of the vCenter Single Sign-On server

    URI ssoUri = URI.create("https://vCenter1:7444/ims/STSService?wsdl");

    //set the tokens to be valid for an hour

    long lifeTimeSeconds = 60 * 60;

    //create a factory for vCenter Single Sign-On tokens

    SsoAuthenticator sso = new SsoAuthenticator(ssoUri, sessionFactory, lifeTimeSeconds);

There is no class found in any of the vSphere or Orchestrator libraries that can be imported to handle the object "SsoAuthenticator".  My goal is to use this code to obtain the token needed to make REST API calls on Orchestrator to run workflows.  Any help in accomplishing my goal would be appreciated. 

As an aside, another approach to obtain the token using a SOAP call works (I used the AcquireBearerTokenByUserCredentialSample found in the documentation successfully); however, I thought I would ask the forum for insight on the whereabouts of the class associated with SsoAuthenticator in case there is something I am missing.

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Scott,

SsoAuthenticator class can be found in o11n-rest-client-sso.jar, part of vCO Java REST SDK.

There are a few errors in your code:

1) The port number is vCO URI is not correct. It should be 8281, not 8283. 8283 is the port of vCO Web Configurator, 8281 is the port of vCO server (and vCO REST API)

2) It looks like you have SSO URI valid for version 5.1.x, not 5.5.x. For 5.5.x, the URI should be something like https://vCenter1:7444/sts/STSService/vsphere.local?wsdl. Note that ims has been changed to sts


Actually, you don't need to obtain SSO token. We support basic authentication with username/password over SSO. Take a look at the following sample code which searches for stock 'Rename Datacenter' workflow by its ID:


            String user = "user123@domain";

            String pwd = "password123";

            URI vcoUri = new URI("https://10.23.20.30:8281/vco/api");  // replace with your vCO IP

            VcoSessionFactory sessionFactory = new DefaultVcoSessionFactory(vcoUri) {

                @Override

                protected HostnameVerifier newHostnameVerifier() {

                    return newUnsecureHostnameVerifier();

                }

                @Override

                protected SSLContext newSSLContext() throws KeyManagementException, NoSuchAlgorithmException {

                    return newUnsecureSSLContext();

                }

            };

            VcoSession session = sessionFactory.newSession(new UsernamePasswordAuthentication(user, pwd));

            WorkflowService wfService = new WorkflowService(session);

            Workflow workflow = wfService.getWorkflow("BD808080808080808080808080808080A3C380800122528313869552e41805bb1"); // ID of 'Rename datacenter' workflow

            if (workflow != null) {

                System.out.println("Found workflow -> " + workflow.getName());

            }

View solution in original post

Reply
0 Kudos
1 Reply
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Scott,

SsoAuthenticator class can be found in o11n-rest-client-sso.jar, part of vCO Java REST SDK.

There are a few errors in your code:

1) The port number is vCO URI is not correct. It should be 8281, not 8283. 8283 is the port of vCO Web Configurator, 8281 is the port of vCO server (and vCO REST API)

2) It looks like you have SSO URI valid for version 5.1.x, not 5.5.x. For 5.5.x, the URI should be something like https://vCenter1:7444/sts/STSService/vsphere.local?wsdl. Note that ims has been changed to sts


Actually, you don't need to obtain SSO token. We support basic authentication with username/password over SSO. Take a look at the following sample code which searches for stock 'Rename Datacenter' workflow by its ID:


            String user = "user123@domain";

            String pwd = "password123";

            URI vcoUri = new URI("https://10.23.20.30:8281/vco/api");  // replace with your vCO IP

            VcoSessionFactory sessionFactory = new DefaultVcoSessionFactory(vcoUri) {

                @Override

                protected HostnameVerifier newHostnameVerifier() {

                    return newUnsecureHostnameVerifier();

                }

                @Override

                protected SSLContext newSSLContext() throws KeyManagementException, NoSuchAlgorithmException {

                    return newUnsecureSSLContext();

                }

            };

            VcoSession session = sessionFactory.newSession(new UsernamePasswordAuthentication(user, pwd));

            WorkflowService wfService = new WorkflowService(session);

            Workflow workflow = wfService.getWorkflow("BD808080808080808080808080808080A3C380800122528313869552e41805bb1"); // ID of 'Rename datacenter' workflow

            if (workflow != null) {

                System.out.println("Found workflow -> " + workflow.getName());

            }

Reply
0 Kudos