mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-08-20 04:30:42 +02:00
Minor fix to enable LDAP customization of first and last name.
This commit is contained in:
parent
9ab0637690
commit
846ad24bf3
@ -19,6 +19,8 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
|
|||||||
|
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
private String adminUser;
|
private String adminUser;
|
||||||
|
private String ldapAttributeFirstName;
|
||||||
|
private String ldapAttributeLastName;
|
||||||
|
|
||||||
|
|
||||||
public UserService getUserService() {
|
public UserService getUserService() {
|
||||||
@ -51,10 +53,10 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
|
|||||||
user = new User();
|
user = new User();
|
||||||
user.setEmail(email);
|
user.setEmail(email);
|
||||||
|
|
||||||
final String firstName = userData.getStringAttribute("givenName");
|
final String firstName = userData.getStringAttribute(ldapAttributeFirstName);
|
||||||
user.setFirstname(firstName);
|
user.setFirstname(firstName);
|
||||||
|
|
||||||
final String lastName = userData.getStringAttribute("sn");
|
final String lastName = userData.getStringAttribute(ldapAttributeLastName);
|
||||||
user.setLastname(lastName);
|
user.setLastname(lastName);
|
||||||
|
|
||||||
user.setPassword(email);
|
user.setPassword(email);
|
||||||
@ -62,7 +64,7 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
|
|||||||
user.setActivationDate(now);
|
user.setActivationDate(now);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
userService.createUser(user, false,false);
|
userService.createUser(user, false, false);
|
||||||
} catch (WiseMappingException e) {
|
} catch (WiseMappingException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
@ -70,6 +72,22 @@ public class LdapUserDetailsContextMapper implements UserDetailsContextMapper {
|
|||||||
return new UserDetails(user, isAdmin(email));
|
return new UserDetails(user, isAdmin(email));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLdapAttributeLastName() {
|
||||||
|
return ldapAttributeLastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLdapAttributeLastName(String ldapAttributLastName) {
|
||||||
|
this.ldapAttributeLastName = ldapAttributLastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLdapAttrbutFirstName() {
|
||||||
|
return ldapAttributeFirstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLdapAttributeFirstName(String ldapAttributeFirstName) {
|
||||||
|
this.ldapAttributeFirstName = ldapAttributeFirstName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mapUserToContext(org.springframework.security.core.userdetails.UserDetails userDetails, DirContextAdapter dirContextAdapter) {
|
public void mapUserToContext(org.springframework.security.core.userdetails.UserDetails userDetails, DirContextAdapter dirContextAdapter) {
|
||||||
// To be implemented ...
|
// To be implemented ...
|
||||||
|
@ -128,6 +128,10 @@ security.ldap.basedn=dc=wisemapping,dc=com
|
|||||||
security.ldap.subDn=people
|
security.ldap.subDn=people
|
||||||
security.ldap.auth.attribute=mail
|
security.ldap.auth.attribute=mail
|
||||||
|
|
||||||
|
security.ldap.lastName.attribute=sn
|
||||||
|
security.ldap.firstName.attribute=givenName
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
<bean id="userDetailsContextMapper" class="com.wisemapping.security.ldap.LdapUserDetailsContextMapper">
|
<bean id="userDetailsContextMapper" class="com.wisemapping.security.ldap.LdapUserDetailsContextMapper">
|
||||||
<property name="userService" ref="userService"/>
|
<property name="userService" ref="userService"/>
|
||||||
|
<property name="ldapAttributeFirstName" value="${security.ldap.firstName.attribute}"/>
|
||||||
|
<property name="ldapAttributeLastName" value="${security.ldap.lastName.attribute}"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="ldapUserSearch"
|
<bean id="ldapUserSearch"
|
||||||
|
Loading…
Reference in New Issue
Block a user