On Thursday, December 04, 2014 10:57:43 AM 王成俊 wrote: > I'm sorry I did not explain my needs clearly. > > In my case,I want to redesign the WebAdmin login GUI and add some > javascript in my WebAdmin login page to do many own logic.At present I > don't know how to add javascript in gwt framework,so I have to make a > servlet to alternative the original WebAdmin login GUI. > > After admin user log in the WebAdmin Portal through my servlet,UIPlugin > which use restapi to get data in the portal cannot automate get the > user's certificate,the uiplugin show me a prompt to input the username and > password. >
Okay so if I understand correctly there are 2 parts to your issue. 1. You want an alternate login screen for which you wrote your own servlet that displays your login screen. 2. You have a UI plugin that needs the rest api credentials to make calls to the REST api. - For 1, A consequence of what you are describing to me, is that you will need to compile and package ovirt with your custom extension yourself. Which may potentially break if we ever make changes to the code. I highly suggest you keep an eye out for the SSO capability we are working on in 3.6. But for now I guess you can do the following, which can and probably will break with each version of ovirt. The source code for the login window in webadmin is in: rontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/login/presenter and view. You can alter it whatever way you want to do your custom stuff. However this requires you to know GWT. If you want to do the servlet approach: look in frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/server/gwt/GenericApiGWTServiceImpl.java at the login and logOff methods. Do something similar to that in your servlet when you submit the form from your servlet. After you login, you can redirect the browser to the webadmin URL, at that point it should recognize you are logged in and show the webadmin while bypassing the original login screen. This will work if you servlet lives in the same context as the webadmin servlet. Again, both of these approached will probably work, but depend on internal code which can and will change over time, so you will have to maintain your code to match. When the SSO capability is fully rolled out you should be able to write your own login screen that doesn't depend on internal structures which will make maintaining that much easier for you. I believe this is scheduled for the 3.6 timeframe. - For 2, in your UI plugin, you need to hook into the RestApiSessionAcquired event. Its use is described here [1]. You can pass the session id in that event as a header to your request to the REST api and that makes the requests succeed. Examples of code that do that are available in the sample UI plugins on that page. Alexander [1] http://www.ovirt.org/Features/UIPlugins#REST_API_integration > I am looking forward to your guide! > > Thanks! > > Best regards! > > 2014-12-03 1:04 GMT+08:00 Vojtech Szocs <vsz...@redhat.com>: > > ----- Original Message ----- > > > > > From: "Alexander Wels" <aw...@redhat.com> > > > To: "王成俊" <wcj2...@gmail.com> > > > Cc: devel@ovirt.org > > > Sent: Tuesday, December 2, 2014 1:59:21 PM > > > Subject: Re: [ovirt-devel] How To Auto Set oVirt RESTApi Session? > > > > > > On Tuesday, December 02, 2014 09:45:49 AM 王成俊 wrote: > > > > Hi,awels: > > > > Thanks for your reply! > > > > > > > > I make this servlet to run the backend action which > > > > > > > > names "LoginAdminUser", because I want to check admin log in with > > > > it,so > > > > that my engine no need to log in through engine's loginpopupview. > > > > Hm, so you're trying to automate WebAdmin GUI login? Can you please > > explain your use case without any technical (servlet etc.) details? > > > > > > But when I log in through my servlet,the restapi can not get the > > > > > > > > user's certificate. > > > > > > > > Can you tell me how to set and resume the restapi session in my > > > > case? > > > > > > Thanks! > > > > > > > > Best Regards! > > > > > > You can login to the REST api using standard http connection techniques. > > > > For > > > > > instance basic auth you can login doing the following: > > > > > > http://<user>%40<domain>:<password>@<engine_host>/ovirt-engine/api > > > > > > Will list the available REST api. > > > > > > But I am still not clear on what you are trying to do. Are you trying to > > > write > > > your own external servlet, that calls the REST api to do things for you? > > > > Or > > > > > are you trying to write a servlet that lives inside the context of the > > > > engine > > > > > and implements a new action? > > > > > > Also please reply all, so we can keep the discussion on the mailing list > > > > so > > > > > other people can find it in the future. > > > > > > Alexander > > > > > > > 2014-12-02 5:42 GMT+08:00 Alexander Wels <aw...@redhat.com>: > > > > > On Monday, December 01, 2014 04:56:04 PM 王成俊 wrote: > > > > > > Dear Sir: > > > > > > > > > > > > I am a new one in studing ovirt engine.Now,I have a > > > > Servlet in > > > > > > > > org.ovirt.engine.ui.frontend.server.gwt package. > > > > > > > > > > > > I want to call > > > > *Frontend.getInstance().getLoginHandler().**onLoginSuccess(userName, > > > > > > > > password, domain)* to set session for restapi in this servlet. > > > > > > > > > > > > But when I visit this servlet,it occur to show me an > > > > > > error > > > > > > which > > > > > > > > > > > > just like "*JBWEB000071: root cause > > > > java.lang.ClassNotFoundException: > > > > > > org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback from > > > > [Module > > > > > > > > "deployment.engine.ear.webadmin.war:main" from Service > > > > Module > > > > > > > > Loader]*". I found that this error is occured by calling* > > > > > > Frontend.getInstance()*. > > > > > > > > > > > > Can you tell me how to resolve this problem or a new way > > > > to > > > > > > > > set > > > > > > > > > > > > and resume restapi session in a servlet package of > > > > > > org.ovirt.engine.ui.front.server.gwt like the > > > > RestApiSessionManager in > > > > > > > > org.ovirt.engine.ui.webadmin.plugin.restapi package? > > > > > > > > > > > > thanks! > > > > > > > > > > > > Best Regards! > > > > > > > > > > Hi, > > > > > > > > > > The problem you are experiencing is the fact the > > > > Frontend.getInstance() > > > > > > > is > > > > > a > > > > > frontend (client, which get compiled to javascript) class, and the > > > > > servlet > > > > > is > > > > > on the server side where this class is not defined (as it is > > > > > frontend > > > > > only). > > > > > Maybe if you could explain what you are trying to do we could assist > > > > > better. > > > > > > > > > > We have a mechanism of getting the REST api session on the front end > > > > when > > > > > > > you > > > > > log in. On the backend you don't really need that, since you are on > > > > the > > > > > > > backend. So your question sort of confuses me at this point. > > > > > > > > > > Alexander > > > > > > _______________________________________________ > > > Devel mailing list > > > Devel@ovirt.org > > > http://lists.ovirt.org/mailman/listinfo/devel _______________________________________________ Devel mailing list Devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/devel