Hi everyone,
I am currently using the vCloud SDK for Java (version 1.5), along with vCloud Director 1.5. Following the samples provided in the SDK package, I have been trying to log in vCD with the following code snippet:
//...
final String HTTPS = "https";
final String fullURL = getApi_endpoint() + ":"+ getApi_endpoint_port();
if (this.vcloudClient == null) {
VcloudClient.setLogLevel(Level.ALL);
this.vcloudClient = new VcloudClient(fullURL, Version.V1_5);
if (!isStrict_api_certificate_check()) { // No Strict Check
this.vcloudClient.registerScheme(HTTPS, getApi_endpoint_port(), NotStrictSSLFactory.getInstance());
}
this.vcloudClient.setMaxConnections(20);
}
this.vcloudClient.login(user+"@"+organization,password);
//...
However, when running the code above, I get the following log:
[2012-02-27 13:12:40.066] http-8090-1 ...
...
[2012-02-27 13:12:40.288] http-8090-1 </SupportedVersions>
[2012-02-27 13:12:45.744] http-8090-1 Feb 27, 2012 1:12:45 PM com.vmware.vcloud.sdk.RestUtil login
[2012-02-27 13:12:45.744] http-8090-1 INFO: Login URL - https://vcloud.maxnod/api/sessions
[2012-02-27 13:12:46.206] http-8090-1 Feb 27, 2012 1:12:46 PM com.vmware.vcloud.sdk.RestUtil login
[2012-02-27 13:12:46.206] http-8090-1 INFO: Status Code - 401
[2012-02-27 13:12:46.206] http-8090-1 Feb 27, 2012 1:12:46 PM com.vmware.vcloud.sdk.RestUtil login
[2012-02-27 13:12:46.207] http-8090-1 INFO: Status - Unauthorized
[2012-02-27 13:12:46.207] http-8090-1 Feb 27, 2012 1:12:46 PM com.vmware.vcloud.sdk.RestUtil login
[2012-02-27 13:12:46.207] http-8090-1 INFO: Response -
[2012-02-27 13:12:46.208] http-8090-1 Feb 27, 2012 1:12:46 PM com.vmware.vcloud.sdk.Response isExpected
[2012-02-27 13:12:46.208] http-8090-1 INFO: Expected Status Code - 200
[2012-02-27 13:12:46.208] http-8090-1 Feb 27, 2012 1:12:46 PM com.vmware.vcloud.sdk.Response isExpected
[2012-02-27 13:12:46.209] http-8090-1 INFO: Actual Status Code - 401
[2012-02-27 13:12:46.209] http-8090-1 VCloudException No Error Report - 401
The credentials provided are corrected.
Moreover, I noticed something strange again, manually using curl client: I am using vCD version 1.5, but when following the login URL for version 1.5, I cannot login, and when using the one for version 1.0, I can.
[ me@slashme: ~ ] curl -k -i https://vcloud.maxnod:443/api/sessions --user user@organization1
Enter host password for user 'user@organization1':
HTTP/1.1 405 Method Not Allowed
Date: Mon, 27 Feb 2012 12:15:47 GMT
x-vcloud-authorization: IeU7nFPrpn2y+u0BpazL7knXWlaJsJ6XzXTnEuOLM/I=
Set-Cookie: vcloud-token=IeU7nFPrpn2y+u0BpazL7knXWlaJsJ6XzXTnEuOLM/I=; Secure; Path=/
Content-Type: application/vnd.vmware.vcloud.error+xml;version=1.5
Date: Mon, 27 Feb 2012 12:15:47 GMT
Content-Length: 346
<?xml version="1.0" encoding="UTF-8"?>
<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="METHOD_NOT_ALLOWED" message="HTTP method not allowed" majorErrorCode="405" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://172.16.101.113/api/v1.5/schema/master.xsd"></Error>
----
[ me@slashme: ~ ] curl -k -i https://vcloud.maxnod:443/api/login --user user@organization1
Enter host password for user 'user@organization1':
HTTP/1.1 200 OK
Date: Mon, 27 Feb 2012 12:16:47 GMT
x-vcloud-authorization: GLx/fSj2M53hAoqFVs+3DiMJ6e7RzqBHTW+7FlzzTlY=
Set-Cookie: vcloud-token=GLx/fSj2M53hAoqFVs+3DiMJ6e7RzqBHTW+7FlzzTlY=; Secure; Path=/
Content-Type: application/vnd.vmware.vcloud.orglist+xml;version=1.5
Date: Mon, 27 Feb 2012 12:16:47 GMT
Content-Length: 497
<?xml version="1.0" encoding="UTF-8"?>
<OrgList xmlns="http://www.vmware.com/vcloud/v1.5" type="application/vnd.vmware.vcloud.orgList+xml" href="https://vcloud.maxnod/api/org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://172.16.101.113/api/v1.5/schema/master.xsd">
<Org type="application/vnd.vmware.vcloud.org+xml" name="organization1" href="https://vcloud.maxnod/api/org/bb910972-a1d9-4baf-84cf-6d5ffdab5ef7"/>
</OrgList>
I really do not understand why such error in my Java program occurs. Am I doing something wrong?
How can I force the vCloud version when instantiating my VCloudClient object (since the only value permitted in Version Enum is V1.5)?
Thanks in advance.
-- A.S.