<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Programmatically logging-in within a OpenURL WebEngine Project in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/programmatically-logging-in-within-a-openurl-webengine-project/m-p/321136#M8137</link>
    <description>&lt;P&gt;Thanx Laurent,&lt;/P&gt;
&lt;P&gt;That is interesting that something like this is already there, I think github is better place to search for code example rather than my local copy of nuxeo 5.6 clone &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thanx again. Next time when I change my implementation I would use the approach as you indicated.&lt;/P&gt;
&lt;P&gt;Regards
Nataraj&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jun 2012 14:03:55 GMT</pubDate>
    <dc:creator>nataraj_</dc:creator>
    <dc:date>2012-06-28T14:03:55Z</dc:date>
    <item>
      <title>Programmatically logging-in within a OpenURL WebEngine Project</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/programmatically-logging-in-within-a-openurl-webengine-project/m-p/321133#M8134</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I am trying to programmatically log-in from a WebEngine project context. The WebEngine's URL is configured as OpenURL using the OpenUrl extension point of PluggableAuthenticationService([&lt;EM&gt;OpenUrl&lt;/EM&gt;]).&lt;/P&gt;
&lt;P&gt;In the first view, WebContext(ctx).getPrincipal() returns null. At this point I need to login to the nuxeo with a pre-configured user so that I have a valid CoreSession on subsequent request. A call like WebContext(ctx).getCoreSession() throws exception like "Un-authenticated user trying to access core-session."&lt;/P&gt;
&lt;P&gt;Following are the steps I already tried with no success:&lt;/P&gt;
&lt;P&gt;1)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;LoginContext lc = Framework.login(loginId, password);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result: &lt;EM&gt;The logged-in users context is not propagated down the layers so that next time I call getCoreSession() I get the above exception.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;2)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;LoginContext lc = Framework.login(loginId, password); 
request = wrapRequest(request, lc); // Uses HttpServletRequestWrapper
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result: &lt;EM&gt;Same exception.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;3)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;UserManager userManager = Framework.getService(UserManager.class);
NuxeoPrincipalImpl userPrin = (NuxeoPrincipalImpl)userManager.authenticate(loginId, password);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result: &lt;EM&gt;The logged-in users context is not propagated down the layers.&lt;/EM&gt;&lt;/P&gt;
&lt;OL start="4"&gt;
&lt;LI&gt;&lt;P&gt;Tried to use nuxeo-automation-client from inside the WebEngine by adding the respective jars, but get exception:&lt;/P&gt;
&lt;P&gt;ERROR [org.nuxeo.ecm.webengine.app.WebEngineExceptionMapper] Exception in JAX-RS processing
java.lang.NoClassDefFoundError: org/nuxeo/ecm/automation/client/jaxrs/impl/HttpAutomationClient&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;What am I doing wrong. I can't find any API which does this. Or may be I am calling the wrong sequence of API calls. Please help.&lt;/P&gt;
&lt;P&gt;Note:&lt;/P&gt;
&lt;P&gt;A similar question was also asked in Nuxeo forums(&lt;EM&gt;&lt;A href="http://forum.nuxeo.com/m/7605/"&gt;Nuxeo Forum Question&lt;/A&gt;&lt;/EM&gt;) on January 2009, he was directed to read &lt;EM&gt;&lt;A href="http://www.nuxeo.org/static/book-draft/ch10.html"&gt;Nuxeo book Chapter 10&lt;/A&gt;&lt;/EM&gt;, but no concrete answer.
I have read the above chapter thoroughly. But can't see how this chapter can be help to me here.&lt;/P&gt;
&lt;P&gt;Kindly help.&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;Nataraj&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2012 14:01:55 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/programmatically-logging-in-within-a-openurl-webengine-project/m-p/321133#M8134</guid>
      <dc:creator>nataraj_</dc:creator>
      <dc:date>2012-06-14T14:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically logging-in within a OpenURL WebEngine Project</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/programmatically-logging-in-within-a-openurl-webengine-project/m-p/321134#M8135</link>
      <description>&lt;P&gt;For the benefit of others, here I am listing my current solution, although I am not sure whether this is the right usage idiom:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;WebContext(ctx).getCoreSession(), i.e., ctx.getCoreSession() will always return invalid  CoreSession. Since user login context is not available.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;The solution is to use CoreSession class by itself, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;RepositoryManager repoMgr = Framework.getService(RepositoryManager.class);
CoreSession cs = repoMgr.getRepository("default").open();
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;This way you get the CoreSession object and can do your usual stuff. But it's a good idea to do the following also:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;	LoginContext lc = Framework.loginAsUser(userId);
	NuxeoPrincipal principal = (NuxeoPrincipal) Framework.getService(
			UserManager.class).authenticate(userId, password);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will help in checking permission etc.&lt;/P&gt;
&lt;P&gt;But regarding the WebEngine infrastructure their is bad news. No inbuilt APIs of WebEngine is going to work. Like for e.g.,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;	ctx.getCoreSession();
              OR
	ctx.getUserSession();
              OR
    ctx.setProperty()
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It seems the context information in the WebEngine is totally null.
Simple solution can be QueryString or Hidden Form Input field to pass state variables between different view methods.&lt;/P&gt;
&lt;P&gt;I am not sure whether this is right and safe way to do this. I hope there is a better way.&lt;/P&gt;
&lt;P&gt;Please if you know of any, let me know.&lt;/P&gt;
&lt;P&gt;Regards
Nataraj&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jun 2012 14:18:25 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/programmatically-logging-in-within-a-openurl-webengine-project/m-p/321134#M8135</guid>
      <dc:creator>nataraj_</dc:creator>
      <dc:date>2012-06-16T14:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically logging-in within a OpenURL WebEngine Project</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/programmatically-logging-in-within-a-openurl-webengine-project/m-p/321135#M8136</link>
      <description>&lt;P&gt;Hi Nataraj,
You could also use an UnrestrictedSessionRunner instantiated with the repository name instead of a CoreSession. You can find an example in this module: &lt;A href="https://github.com/ldoguin/nuxeo-userpassword-reset" target="test_blank"&gt;https://github.com/ldoguin/nuxeo-userpassword-reset&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2012 13:55:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/programmatically-logging-in-within-a-openurl-webengine-project/m-p/321135#M8136</guid>
      <dc:creator>Laurent_Doguin</dc:creator>
      <dc:date>2012-06-28T13:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically logging-in within a OpenURL WebEngine Project</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/programmatically-logging-in-within-a-openurl-webengine-project/m-p/321136#M8137</link>
      <description>&lt;P&gt;Thanx Laurent,&lt;/P&gt;
&lt;P&gt;That is interesting that something like this is already there, I think github is better place to search for code example rather than my local copy of nuxeo 5.6 clone &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thanx again. Next time when I change my implementation I would use the approach as you indicated.&lt;/P&gt;
&lt;P&gt;Regards
Nataraj&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2012 14:03:55 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/programmatically-logging-in-within-a-openurl-webengine-project/m-p/321136#M8137</guid>
      <dc:creator>nataraj_</dc:creator>
      <dc:date>2012-06-28T14:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically logging-in within a OpenURL WebEngine Project</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/programmatically-logging-in-within-a-openurl-webengine-project/m-p/321137#M8138</link>
      <description>&lt;P&gt;You can also look for example on dev.blogs.nuxeo.com .&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2012 14:12:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/programmatically-logging-in-within-a-openurl-webengine-project/m-p/321137#M8138</guid>
      <dc:creator>Laurent_Doguin</dc:creator>
      <dc:date>2012-06-28T14:12:07Z</dc:date>
    </item>
  </channel>
</rss>

