-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UBO-263 FSU040THUL-405 Allow to search arbitrary realm in LocalService
- Loading branch information
Showing
3 changed files
with
63 additions
and
34 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
ubo-common/src/main/java/org/mycore/ubo/ldap/picker/LDAPWithLocalService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
package org.mycore.ubo.ldap.picker; | ||
|
||
import java.util.Optional; | ||
|
||
import javax.naming.OperationNotSupportedException; | ||
|
||
import org.mycore.common.config.MCRConfiguration2; | ||
import org.mycore.ubo.local.LocalService; | ||
import org.mycore.ubo.picker.PersonSearchResult; | ||
import org.mycore.user2.MCRRealmFactory; | ||
|
||
public class LDAPWithLocalService extends LDAPService { | ||
|
||
public static final String LDAP_REALM = MCRConfiguration2.getString( | ||
"MCR.user2.IdentityManagement.UserCreation.LDAP.Realm").orElse(null); | ||
|
||
@Override | ||
public PersonSearchResult searchPerson(String query) throws OperationNotSupportedException { | ||
PersonSearchResult results = super.searchPerson(query); | ||
LocalService localService = new LocalService(); | ||
PersonSearchResult personSearchResult = localService.searchPerson(query); | ||
results.join(personSearchResult, 0); | ||
|
||
if (LDAP_REALM != null) { | ||
Optional.ofNullable(MCRRealmFactory.getRealm(LDAP_REALM)) | ||
.ifPresent(realm -> results.join(localService.searchPerson(query, realm), 0)); | ||
} | ||
|
||
return results; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters