<?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 authenticationComponent.setSystemUserAsCurrentUser() in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/authenticationcomponent-setsystemuserascurrentuser/m-p/29658#M15162</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I was trying to create a node, but not from the web app - from within a scheduled job. So there is no "current user" where I am trying to create the node.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had the trouble of authentication, and used the following first:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;AuthenticationService authenticationService = serviceRegistry.getAuthenticationService();&lt;BR /&gt;authenticationService.authenticate("admin", "admin".toCharArray());&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;But obviously this is not a good idea as the admin password should have been changed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I noticed that (in BaseAlfrescoSpringTest class for example), the following is used:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;AuthenticationComponent authenticationComponent = (AuthenticationComponent) this.applicationContext&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .getBean("authenticationComponent");&lt;BR /&gt;authenticationComponent.setSystemUserAsCurrentUser();&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;And I decided to use this in my class. But is a good idea to use this other than within a TestCase?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Mar 2006 13:15:43 GMT</pubDate>
    <dc:creator>turgayz</dc:creator>
    <dc:date>2006-03-28T13:15:43Z</dc:date>
    <item>
      <title>authenticationComponent.setSystemUserAsCurrentUser()</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/authenticationcomponent-setsystemuserascurrentuser/m-p/29658#M15162</link>
      <description>Hi,I was trying to create a node, but not from the web app - from within a scheduled job. So there is no "current user" where I am trying to create the node.I had the trouble of authentication, and used the following first:AuthenticationService authenticationService = serviceRegistry.getAuthenticati</description>
      <pubDate>Tue, 28 Mar 2006 13:15:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/authenticationcomponent-setsystemuserascurrentuser/m-p/29658#M15162</guid>
      <dc:creator>turgayz</dc:creator>
      <dc:date>2006-03-28T13:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: authenticationComponent.setSystemUserAsCurrentUser()</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/authenticationcomponent-setsystemuserascurrentuser/m-p/29659#M15163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Internally you can set a user as authenticated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This should certainly be used with caution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can use the authentication component to set the current authentication to be a given user name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So if you want your sceduled job to run as the user "bobbins"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;use authenticationComponent.setCurrentUser("bobbins") will do this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Mar 2006 14:51:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/authenticationcomponent-setsystemuserascurrentuser/m-p/29659#M15163</guid>
      <dc:creator>andy</dc:creator>
      <dc:date>2006-03-28T14:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: authenticationComponent.setSystemUserAsCurrentUser()</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/authenticationcomponent-setsystemuserascurrentuser/m-p/29660#M15164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you, Andy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Are there any side effects when using this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As I said, I want to run a scheduled job as a given user name. When I use this method, only the job's thread will be authenticated with the given user name, is that correct?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Mar 2006 15:18:30 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/authenticationcomponent-setsystemuserascurrentuser/m-p/29660#M15164</guid>
      <dc:creator>turgayz</dc:creator>
      <dc:date>2006-03-28T15:18:30Z</dc:date>
    </item>
  </channel>
</rss>

