cancel
Showing results for 
Search instead for 
Did you mean: 

webclient action repository credentials

smola
Champ in-the-making
Champ in-the-making
Hi,

I'm tying to write a web client action using JCR. I managed to get the repository bean in my ActionExecuterAbstractBase derived class by adding a JCR.Repository bean reference in my model-context file and adding a setter method for the bean.

The problem is that I don't know how to login to the repository with the current user's credentials!? Can it be done or do I have to use a predefined login credentials?

When I use the foundation API in my action it doesn't need to login.

Any ideas, please?

Thanks
2 REPLIES 2

marcus
Champ in-the-making
Champ in-the-making
How'd you go with this? I thought I'd have a play with JCR from an existing customisation of the web-client, but can't figure out how to login using the existing user stored in the authenticationService.

davidc
Star Contributor
Star Contributor
The JCR spec. requires a login call in order to get a JCR Session.

Right now, there isn't a way to JCR login using the currently authenticated user via the JCR public interface.  You can raise a JIRA feature request if you want this.

However, there is a backdoor approach - I haven't tried it personally, but it should work.


SessionImpl sessionImpl = new org.alfresco.jcr.session((RepositoryImpl)repository);
sessionImpl.init(authenticationService.getCurrentTicket(), "SpacesStore", null);
Session session = (Session)sessionImpl;

The above code assumes you have injected JCR.Repository into 'repository' and AuthenticationService into 'authenticationService'.

There is no need to call session.logout().  In fact, you shouldn't in this scenario.  Also, all calls to session will inherit the currently open transaction.