<?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 ThreadLocal&amp;lt;String&amp;gt; authenticatedUserIdThreadLocal sometimes null in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/threadlocal-lt-string-gt-authenticateduseridthreadlocal/m-p/41178#M17273</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have implemented a small widget to allow the users to add comments to a task. I use AngularJS and I use activiti-reset and I pass the basic authentication hash as a http header. the problem that&amp;nbsp;authenticatedUserIdThreadLocal.get() is inconsistent and it doesn't return always the authenticated and sometimes it returns null.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://connect.hyland.com/legacyfs/online/alfresco/13189_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as you can see in the picture the user id is available and printed. but just in the middle there was no user id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea how to resolve such issue? I would really appreciate it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Apr 2017 16:25:38 GMT</pubDate>
    <dc:creator>ahmed_mahfouz</dc:creator>
    <dc:date>2017-04-03T16:25:38Z</dc:date>
    <item>
      <title>ThreadLocal&lt;String&gt; authenticatedUserIdThreadLocal sometimes null</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/threadlocal-lt-string-gt-authenticateduseridthreadlocal/m-p/41178#M17273</link>
      <description>I have implemented a small widget to allow the users to add comments to a task. I use AngularJS and I use activiti-reset and I pass the basic authentication hash as a http header. the problem that&amp;nbsp;authenticatedUserIdThreadLocal.get() is inconsistent and it doesn't return always the authenticated and</description>
      <pubDate>Mon, 03 Apr 2017 16:25:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/threadlocal-lt-string-gt-authenticateduseridthreadlocal/m-p/41178#M17273</guid>
      <dc:creator>ahmed_mahfouz</dc:creator>
      <dc:date>2017-04-03T16:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: ThreadLocal&lt;String&gt; authenticatedUserIdThreadLocal sometimes null</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/threadlocal-lt-string-gt-authenticateduseridthreadlocal/m-p/41179#M17274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried simply using the authentication object?&lt;/P&gt;&lt;PRE class="" style="color: #000000; background: #eeeeee; border: 1pt solid #000000; font-size: 10pt; padding: 7pt 3pt;"&gt;SecurityContextHolder.getContext().getAuthentication().getPrincipal()&lt;/PRE&gt;&lt;P&gt;This should hold the user principal for any of your secure rest calls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;P&gt;&lt;A href="https://migration33.stage.lithium.com/t5/tag/bp3/tg-p"&gt;&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:46:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/threadlocal-lt-string-gt-authenticateduseridthreadlocal/m-p/41179#M17274</guid>
      <dc:creator>gdharley</dc:creator>
      <dc:date>2017-04-03T21:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: ThreadLocal&lt;String&gt; authenticatedUserIdThreadLocal sometimes null</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/threadlocal-lt-string-gt-authenticateduseridthreadlocal/m-p/41180#M17275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually I didn't do a custom implementation this is the existing implementation for AddCommentCmd in activiti-engine:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String userId = Authentication.getAuthenticatedUserId();&lt;BR /&gt; CommentEntity comment = new CommentEntity();&lt;BR /&gt; comment.setUserId(userId);&lt;BR /&gt; comment.setType( (type == null)? CommentEntity.TYPE_COMMENT : type );&lt;BR /&gt; comment.setTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime());&lt;BR /&gt; comment.setTaskId(taskId);&lt;BR /&gt; comment.setProcessInstanceId(processInstanceId);&lt;BR /&gt; comment.setAction(Event.ACTION_ADD_COMMENT);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also the issue that sometimes if other user just logged in&amp;nbsp;&lt;SPAN&gt; Authentication.getAuthenticatedUserId(); returns the other&amp;nbsp;username instead of my username I am not sure how the threads are sharing the same value.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 01:52:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/threadlocal-lt-string-gt-authenticateduseridthreadlocal/m-p/41180#M17275</guid>
      <dc:creator>ahmed_mahfouz</dc:creator>
      <dc:date>2017-04-04T01:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: ThreadLocal&lt;String&gt; authenticatedUserIdThreadLocal sometimes null</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/threadlocal-lt-string-gt-authenticateduseridthreadlocal/m-p/41181#M17276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I implemented a workaround by creating a filter to set the username every time I do a rest call to activiti-reset:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Component&lt;BR /&gt;public class AuthenticationFilter implements Filter {&lt;/P&gt;&lt;P&gt;@Override&lt;BR /&gt; public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)&lt;BR /&gt; throws IOException, ServletException {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HttpServletRequest request = (HttpServletRequest) req;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String username=request.getUserPrincipal().getName();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Authentication.setAuthenticatedUserId(username);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; chain.doFilter(req, res);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;@Override&lt;BR /&gt; public void destroy() {&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;@Override&lt;BR /&gt; public void init(FilterConfig arg0) throws ServletException {&lt;BR /&gt; }&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Apr 2017 02:49:10 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/threadlocal-lt-string-gt-authenticateduseridthreadlocal/m-p/41181#M17276</guid>
      <dc:creator>ahmed_mahfouz</dc:creator>
      <dc:date>2017-04-04T02:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: ThreadLocal&lt;String&gt; authenticatedUserIdThreadLocal sometimes null</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/threadlocal-lt-string-gt-authenticateduseridthreadlocal/m-p/41182#M17277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You really shouldnt have needed to implement a new filter.&lt;BR /&gt;Your own filter logic indicates the use principal is included in the request.&lt;/P&gt;&lt;P&gt;However, I'm glad you found a work around.&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;P&gt;&lt;A href="https://migration33.stage.lithium.com/t5/tag/bp3/tg-p"&gt;&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Apr 2017 17:05:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/threadlocal-lt-string-gt-authenticateduseridthreadlocal/m-p/41182#M17277</guid>
      <dc:creator>gdharley</dc:creator>
      <dc:date>2017-04-05T17:05:43Z</dc:date>
    </item>
  </channel>
</rss>

