Performing administrative tasks in a plugin

I have a plugin that implements InitializingBean in order to perform some administrative tasks at startup. But it is throwing the following exception …
User [Anonymous] does not have the required privileges

This is new to me, because every other plugin I have written is able to run as the current user. But apparently, there is no current user at startup.

Any ideas are welcome.

I have decided to create an admin menu item to do the administrative tasks through a servlet.

However, I would prefer to have it done on initialization, so there is one less task for an installer to forget. Is it possible to “set” the current user? I looked through the Java API and did not find anything.