-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new signUi + userList + fix ldap user search
- Loading branch information
1 parent
7e219c1
commit 745b225
Showing
26 changed files
with
504 additions
and
217 deletions.
There are no files selected for viewing
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
13 changes: 13 additions & 0 deletions
13
src/main/java/org/esupportail/esupsignature/repository/ldap/AliasLdapRepository.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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.esupportail.esupsignature.repository.ldap; | ||
|
||
import org.esupportail.esupsignature.service.ldap.AliasLdap; | ||
import org.springframework.data.ldap.repository.LdapRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface AliasLdapRepository extends LdapRepository<AliasLdap> { | ||
|
||
List<AliasLdap> findByMailAliasStartingWithOrCnStartingWithAndMailAliasNotNull(String mailAlias, String cn); | ||
} |
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
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
43 changes: 43 additions & 0 deletions
43
src/main/java/org/esupportail/esupsignature/service/ldap/AliasLdap.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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.esupportail.esupsignature.service.ldap; | ||
|
||
import org.springframework.ldap.odm.annotations.Attribute; | ||
import org.springframework.ldap.odm.annotations.Entry; | ||
import org.springframework.ldap.odm.annotations.Id; | ||
|
||
import javax.naming.Name; | ||
import java.util.List; | ||
|
||
@Entry(objectClasses = {"nisMailAlias"}, base = "ou=aliases-list") | ||
public class AliasLdap { | ||
|
||
@Id | ||
private Name dn; | ||
private @Attribute(name = "mail") String mailAlias; | ||
private @Attribute(name = "rfc822MailMember") | ||
List<String> memberMails; | ||
private @Attribute(name = "cn") String cn; | ||
|
||
public String getMailAlias() { | ||
return mailAlias; | ||
} | ||
|
||
public void setMailAlias(String mailAlias) { | ||
this.mailAlias = mailAlias; | ||
} | ||
|
||
public List<String> getMemberMails() { | ||
return memberMails; | ||
} | ||
|
||
public void setMemberMails(List<String> memberMails) { | ||
this.memberMails = memberMails; | ||
} | ||
|
||
public String getCn() { | ||
return cn; | ||
} | ||
|
||
public void setCn(String cn) { | ||
this.cn = cn; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/org/esupportail/esupsignature/service/ldap/LdapAliasService.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.esupportail.esupsignature.service.ldap; | ||
|
||
import org.esupportail.esupsignature.repository.ldap.AliasLdapRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
public class LdapAliasService { | ||
|
||
@Autowired(required = false) | ||
private AliasLdapRepository aliasLdapRepository; | ||
|
||
|
||
public List<AliasLdap> searchAlias(String searchString) { | ||
return aliasLdapRepository.findByMailAliasStartingWithOrCnStartingWithAndMailAliasNotNull(searchString, searchString); | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
src/main/java/org/esupportail/esupsignature/service/ldap/PersonLdapAttributesMapper.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.esupportail.esupsignature.service.ldap; | ||
|
||
import org.springframework.ldap.core.AttributesMapper; | ||
|
||
import javax.naming.NamingException; | ||
import javax.naming.directory.Attribute; | ||
import javax.naming.directory.Attributes; | ||
|
||
|
||
public class PersonLdapAttributesMapper implements AttributesMapper<PersonLdap> { | ||
|
||
public PersonLdap mapFromAttributes(Attributes attrs) throws NamingException { | ||
PersonLdap person = new PersonLdap(); | ||
person.setCn((String)attrs.get("cn").get()); | ||
Attribute sn = attrs.get("sn"); | ||
if (sn != null){ | ||
person.setSn((String) sn.get()); | ||
} | ||
Attribute givenName = attrs.get("givenName"); | ||
if (givenName != null){ | ||
person.setGivenName((String) givenName.get()); | ||
} | ||
Attribute mail = attrs.get("mail"); | ||
if (mail != null){ | ||
person.setMail((String) mail.get()); | ||
} | ||
Attribute eduPersonPrincipalName = attrs.get("eduPersonPrincipalName"); | ||
if (eduPersonPrincipalName != null){ | ||
person.setEduPersonPrincipalName((String) eduPersonPrincipalName.get()); | ||
} | ||
return person; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/org/esupportail/esupsignature/service/list/UserList.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.esupportail.esupsignature.service.list; | ||
|
||
import java.util.List; | ||
|
||
public interface UserList { | ||
public String getName(); | ||
public List<String> getUsersEmailFromList(String listName); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/esupportail/esupsignature/service/list/UserListService.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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.esupportail.esupsignature.service.list; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Service | ||
public class UserListService { | ||
|
||
@Autowired(required = false) | ||
UserList userList; | ||
|
||
public List<String> getUsersEmailFromList(String listName) { | ||
if(userList != null) { | ||
return userList.getUsersEmailFromList(listName); | ||
} else { | ||
return new ArrayList<>(); | ||
} | ||
|
||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/org/esupportail/esupsignature/service/list/impl/SympaUserList.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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.esupportail.esupsignature.service.list.impl; | ||
|
||
import org.esupportail.esupsignature.service.extdb.ExtDbService; | ||
import org.esupportail.esupsignature.service.list.UserList; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.annotation.Resource; | ||
import java.sql.ResultSet; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Component | ||
@ConditionalOnProperty(name = "extdb.datasources.userListDataSource.name", havingValue = "sympa") | ||
public class SympaUserList implements UserList { | ||
|
||
JdbcTemplate jdbcTemplate; | ||
|
||
@Resource | ||
ExtDbService extDbService; | ||
|
||
@PostConstruct | ||
public void initJdbcTemplate() { | ||
this.jdbcTemplate = extDbService.getJdbcTemplateByName("userListDataSource"); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "sympa"; | ||
} | ||
|
||
@Override | ||
public List<String> getUsersEmailFromList(String listName) { | ||
List<String> userEmails = new ArrayList<>(); | ||
jdbcTemplate.query("select user_subscriber from subscriber_table where list_subscriber=" + "'" + listName.split("@")[0] + "'", (ResultSet rs) -> { | ||
userEmails.add(rs.getString("user_subscriber")); | ||
while (rs.next()) { | ||
userEmails.add(rs.getString("user_subscriber")); | ||
} | ||
}); | ||
return userEmails; | ||
} | ||
} |
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
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
Oops, something went wrong.