cancel
Showing results for 
Search instead for 
Did you mean: 

Get Administrator password with JAVA

lmoulin
Champ in-the-making
Champ in-the-making
Hello,
I have developed a new wizard.
In my program, I create a new administrator session.
See the following code:

FacesContext context = FacesContext.getCurrentInstance();
ServiceRegistry serviceRegistry =  Repository.getServiceRegistry(context);
AuthenticationService authenticationService = serviceRegistry.getAuthenticationService();
authenticationService.authenticate("admin", "admin".toCharArray());

How can I create a administrator session without writing the password of admin?
Thanks a lot,
Luc
2 REPLIES 2

gavinc
Champ in-the-making
Champ in-the-making
I'm not sure you can retrieve the admin username but you can make some code run as admin, it just depends on what you are trying to achieve as to whether its appropriate for you.

AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{
   public Object doWork() throws Exception
   {
      // do something

      return null;
   }
}, "admin");

lmoulin
Champ in-the-making
Champ in-the-making
Thanks a lot It works fine