RE: Auto Login

Menno Avegaart, modified 5 Years ago. New Member Posts: 9 Join Date: 12/24/19 Recent Posts
Hello,I'm trying to create a CASAutoLogin service replacement for Liferay 7.2 (adding insert/update users support) and followed the instructions on https://portal.liferay.dev/docs/7-2/frameworks/-/knowledge_base/f/auto-login. The jar deploys fine, but the service doesn't seem to be used by Liferay. In older Liferay versions you would have added a plugin-hook.xml to configure the auto.login.hooks property. Is this still required in 7.2, and if yes, how do I configure this in a proper OSGi bundle instead of a war?Thanks.
Menno Avegaart, modified 5 Years ago. New Member Posts: 9 Join Date: 12/24/19 Recent Posts
Thanks. I already found the original CASAutoLogin code. The problem is that deploying this isn't enough.The class name needs to be added to the auto.login.hooks property too, but I don't know how to do that in an Osgi bundle. 
thumbnail
Mohammed Yasin, modified 5 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
Menno Avegaart, modified 5 Years ago. New Member Posts: 9 Join Date: 12/24/19 Recent Posts
Yes, that property. The problem is with the remark from the description: This property is not read by the portal except for portal properties overridden by liferay-hook.xml. It remains here only as a reference.
Menno Avegaart, modified 5 Years ago. New Member Posts: 9 Join Date: 12/24/19 Recent Posts
I got the hook working now to set the auto.login.hooks property to my CASAutoLogin class.In previous Liferay versions (6) setting auto.login.hooks to a single class name implied that only that class should be loaded.The problem is that now Liferay is using OSGi services the already loaded AutoLogin services are not unloaded and my class in only appended to the list.This means the original CASAutoLogin executes first, which causes my own CASAutoLogin to fail.Is there any way to disable all other AutoLogin services or to get my CASAutoLogin class to load first?
thumbnail
Mohammed Yasin, modified 5 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
You can stop cas impl service and try

 com.liferay.portal.security.sso.cas.api 
com.liferay.portal.security.sso.cas.impl
Also there is concept of service ranking you can refer that also
https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/creating-a-custom-osgi-service
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
You can also blacklist bundles
https://portal.liferay.dev/docs/7-0/user/-/knowledge_base/u/blacklisting-osgi-modules
Blacklisting the impl bundle should work. But I didn't try it.
Mircea Curticapean, modified 5 Years ago. New Member Posts: 2 Join Date: 1/10/20 Recent Posts
Hi,
If you got it working can you please tell me how you did it?
I'm facing with an "Unresolved requirement:  Import-Package: com.liferay.portal.security.sso.cas.internal.auto.login.. " error
Regards,
Mircea
Menno Avegaart, modified 5 Years ago. New Member Posts: 9 Join Date: 12/24/19 Recent Posts
So I assume you are extending the original CASAutoLogin? My code doesn't extend CASAutoLogin; I created my own AutoLogin service (based on the CASAutoLogin code from Liferay).
However, I abandoned this approach. Instead, I've now created my own UserImporter service (because the LDAP import was the only part of CASAutoLogin that I wanted to change).
Mircea Curticapean, modified 5 Years ago. New Member Posts: 2 Join Date: 1/10/20 Recent Posts
Yes, that's what I tried to do. That's how is currently done in our Liferay 6 deployment. But I think it would be easier for me to also create a UserImporter service because the only thing missing  is the roles sync between Liferay and our custom LDAP tree. Thank you!