Issue
On 7.3 we are using this class to Import users from a SamlProvider:
com.liferay.portal.security.exportimport.UserImporter.importUser(long companyId, String emailAddress, String screenName)
We call the service by using the @Reference annotation
@Reference(unbind = "-")
public void setUserImporter(UserImporter userImporter) {
this.userImporter = userImporter;
}
private UserImporter userImporter;
Declarative Service {id: 6667, name: com.infor.rhythm.portal.hooks.saml.override.RhythmUserResolver, unsatisfied references:
{name: UserImporter, target: null}
}
I look on the source code and found that UserImporter @ProvidedType was added but I can't find the Service method associated with the UserImporter interface.
This is the github link reference: LPS-123218 Expand UserImporter API to allow user import by UUID · liferay/liferay-portal@a0c7cd1 (github.com)
This might be why it has a Null reference I saw on Gogoshell. I also saw that LDAPUserImporter is extending UserImporter. Although the method I need is
importUser(long companyId, String emailAddress, String screenName)
which is not callable on LDAPUserImporter. The only method on that class is
public User importUser(
long ldapServerId, long companyId, SafeLdapContext safeLdapContext,
Attributes attributes, String password)
Environment
- 2024.q1
Resolution
We believe the issue is that the only implementation of UserImporter (LDAPUserImporterImpl) doesn't advertise itself as providing the UserImporter service, and so the reference cannot be satisfied.
- LDAPUserImporterImpl - implementation of LDAPUserImporter
- LDAPUserImporter - interface extends com.liferay.portal.security.exportimport.UserImporter
So anything that uses those methods ends up waiting for the LDAPUserImporter service instead.
- RequestHeaderAutoLogin.java#L179-L180 - reference to LDAPUserImporter
-
RequestHeaderAutoLogin.java#L84-L85 - invokes
importUser(companyId, emailAddress, screenName)from the base interface
Additionally, you will need to include the below in to pom.xml file:
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.portal.security.exportimport.api</artifactId>
<scope>provided</scope>
</dependency>