Esta conversación ha sido bloqueada debido a la inactividad. Cree una nueva publicación.
Nivel 1
Nivel 2
Iniciar sesión en la comunidad
Iniciar sesión para ver todas las insignias
Esta conversación ha sido bloqueada debido a la inactividad. Cree una nueva publicación.
Hi,
There are two methods to get the session:
session= this.repository.loginAdministrative(null); session = resourceResolver.adaptTo(Session.class);
With the first approach i need an explicit session.logout() and with the second the logout is managed automatically by sling, right?
Thanks
¡Resuelto! Ir a solución.
Vistas
Respuestas
Total de me gusta
okay, you can use
session.logout();
to close the session
Vistas
Respuestas
Total de me gusta
but you need to close your resolver which will take care of it.
Vistas
Respuestas
Total de me gusta
Hi,
You are right, but If you are going to use loginAdministrative(), I would recommend not to use it, It has been deprecated. Although it is still available to support existing applications.
Take a look
@ http://sling.apache.org/documentation/the-sling-engine/service-authentication.html
Vistas
Respuestas
Total de me gusta
Hi
As mentioned by Praveen, "session= this.repository.loginAdministrative(null);" has been depricated.
and another good article to read
Link:- http://www.wemblog.com/2014/08/how-to-use-sessions-and-resource.html
I hope this would act as some help to you.
Thanks and Regards
Kautuk Sahni
Vistas
Respuestas
Total de me gusta
I'm tryng to use:
session = resourceResolver.adaptTo(Session.class);
but the reference of resourceResolver is null inside my bundle
i can recovery the session only by:
session=resolverFactory.getAdministrativeResourceResolver(null).adaptTo(Session.class);
Is it correct?
Vistas
Respuestas
Total de me gusta
If you have request object you can get it this way
ResourceResolver resourceResolver = request.getResourceResolver(); Session session = resourceResolver.adaptTo(Session.class);
Vistas
Respuestas
Total de me gusta
as @edubey mentioned, get the resourceResolver from the request and then adapTo session
or you can use whatever you have mentioned. Even thats correct
Vistas
Respuestas
Total de me gusta
I don't have a servlet or a jsp is a simple java class so i can't use the request.
With the deprecated method i don't have problem, with resolverFactory.getAdministrativeResourceResolver(null).adaptTo(Session.class) i have a lot of session unclosed
Vistas
Respuestas
Total de me gusta
okay, you can use
session.logout();
to close the session
Vistas
Respuestas
Total de me gusta
So doesn't exist a method without the need of logout?
The approach with the resource resolver doesn't need a try/catch and i think it is the right way but why my reference is null?
Vistas
Respuestas
Total de me gusta
Hi,
To replace loginAdministrative, you need to use Service Based Authentication [1]. The idea is to move away from creating a session which has full access to the whole repository and instead for you to think about what permissions are really required, so you create service users for specific tasks.Examples here [2][3][4] When using the ResourceResolver, you would call close() on that object.
This is an older article which talks about your responsibility when opening sessions or a resourceresolver. Ignore the talk of loginadministrative 🙂
Regards,
Opkar
[1] http://sling.apache.org/documentation/the-sling-engine/service-authentication.html
[2] http://www.wemblog.com/2014/08/how-to-use-sessions-and-resource.html
[3] http://www.tothenew.com/blog/access-content-repository-via-getserviceresourceresolver-in-aem6sling7/
[4] https://cqdump.wordpress.com/2014/06/23/aem-6-0-admin-sessions/
Vistas
Respuestas
Total de me gusta
Vistas
me gusta
Respuestas