[ovirt-users] How to get logged in into restapi in java using session ID
shailendra saxena
shailendra.iiita801 at gmail.com
Mon Mar 14 20:19:29 UTC 2016
Hello Juan Hernández,
Thanks you for the help. Now i am able to authenticate using session id.
On 14 March 2016 at 23:00, Juan Hernández <jhernand at redhat.com> wrote:
> On 02/18/2016 03:22 PM, shailendra saxena wrote:
> > Has somebody tried to get API object with the constructor having
> > parameters- URL and restapisession- by using java-sdk ?
> > Here is the following syntax ?
> > Api api =new Api(RestURL,restapisessionID)
> >
> > I have searched a lot but i didn't find anything. Somewhere I read that
> > Ovirt has some issue on keeping restapisession. Is it correct ?
> >
>
> This should work, but the value that you have to pass is the session
> cookie plus its value:
>
> JSESSIONID=asfasdfasdfas
>
> Also consider using the "ApiBuilder" object, instead of directly the
> "Api" constructor, and secure the connection:
>
> // Get the session id from somewhere:
> String sessionId = ...;
>
> // Create the builder:
> ApiBuilder builder = new ApiBuilder()
> .url(URL)
> .sessionId("JSESSIONID=" + sessionId)
> .keyStorePath("ca.jks")
> .keyStorePassword("mykeystorepassword")
> .debug(DEBUG);
>
> // The "ca.jks" file above needs to be created from
> // the CA certificate of the engine, which is usually
> // located in the "/etc/pki/ovirt-engine/ca.pem" file.
> // Get that file, and then use a the "keytool" command
> // to import it to the "ca.jks" keystore file:
> //
> // keytool \
> // -importcert \
> // -keystore ca.jks \
> // -file ca.pem \
> // -alias ca \
> // -storepass mykeystorepassword \
> // -noprompt
> //
> // The resulting "ca.jks" file only contains the CA
> // certificate, so its content isn't confidential.
>
> // Create the API object:
> Api api = builder.build();
>
> --
> Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
> 3ºD, 28016 Madrid, Spain
> Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.
>
--
Thanx & regards,
Shailendra Kr. Saxena
IIIT Allahabad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20160315/895f1734/attachment-0001.html>
More information about the Users
mailing list