Class LdapActorRegistrationMapper
java.lang.Object
de.gustavblass.fsu.fmi.roombooking.security.LdapActorRegistrationMapper
- All Implemented Interfaces:
org.springframework.security.ldap.userdetails.UserDetailsContextMapper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull LdapActormapUserFromContext(@NonNull org.springframework.ldap.core.DirContextOperations context, @NonNull String userName, @NonNull Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Creates anActorfrom the attributes returned by the LDAP server.voidmapUserToContext(org.springframework.security.core.userdetails.UserDetails ignoredUser, org.springframework.ldap.core.DirContextAdapter ignoredContext) Warning! Not implemented!parseEMailAddress(@NonNull org.springframework.ldap.core.DirContextOperations context) Determines theActor.eMailAddressfrom the givenDirContextOperations, tryingparseName(@NonNull org.springframework.ldap.core.DirContextOperations context) Determine's the user'sActor.namefrom the givenDirContextOperations, trying the attributes:parseRole(@NonNull org.springframework.ldap.core.DirContextOperations context, @NonNull Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Determines theActor.rolefrom the givenDirContextOperations(trying the attributeeduPersonAffiliation) and GrantedAuthorities.
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG
-
-
Constructor Details
-
LdapActorRegistrationMapper
public LdapActorRegistrationMapper()
-
-
Method Details
-
mapUserFromContext
@NonNull public @NonNull LdapActor mapUserFromContext(@NonNull @NonNull org.springframework.ldap.core.DirContextOperations context, @NonNull @NonNull String userName, @NonNull @NonNull Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Creates an
Actorfrom the attributes returned by the LDAP server.- The
Actor.password()will not be set. - If no
Actor.rolecould be found,ActorRole.UNKNOWNwill be used instead. - If no
Actor.namecould be found, theActor.userNamewill be used instead. - If no
Actor.eMailAddresscould be found,userName+@mail-box-01.rz.uni-jena.dewill be used instead.
Warning! It is possible that an Actor with the same user name already exists in the local database.
- Specified by:
mapUserFromContextin interfaceorg.springframework.security.ldap.userdetails.UserDetailsContextMapper- Parameters:
context- The actual LDAP attributes.userName- TheActor.userNamethat was used for authentication with the LDAP server.authorities- Other Spring authorities associated with the user. May be empty.- Returns:
- A new Actor object based on the LDAP response.
- The
-
parseRole
@NonNull private @NonNull Optional<ActorRole> parseRole(@NonNull @NonNull org.springframework.ldap.core.DirContextOperations context, @NonNull @NonNull Collection<? extends org.springframework.security.core.GrantedAuthority> authorities) Determines theActor.rolefrom the givenDirContextOperations(trying the attributeeduPersonAffiliation) and GrantedAuthorities.- Parameters:
context- The response from the LDAP server.authorities- Other Spring authorities associated with the user.- Returns:
- The user's role. Empty if it could not be found.
-
parseName
@NonNull private @NonNull Optional<String> parseName(@NonNull @NonNull org.springframework.ldap.core.DirContextOperations context) Determine's the user's
Actor.namefrom the givenDirContextOperations, trying the attributes:displaynamegivenName+FSUCompleteSurnameFSUFirstName+FSUCompleteSurname
- Parameters:
context- The response from the LDAP server.- Returns:
- The user's name. Empty if it could not be found.
-
parseEMailAddress
@NonNull private @NonNull Optional<String> parseEMailAddress(@NonNull @NonNull org.springframework.ldap.core.DirContextOperations context) Determines the
Actor.eMailAddressfrom the givenDirContextOperations, trying- the
mailattribute - the
mailLocalAddressattribute - the
mailRoutingAddressattribute.
- Parameters:
context- The response from the LDAP server.- Returns:
- The user's e-mail address. Empty if none could be found.
- the
-
mapUserToContext
@Contract("_, _ -> fail") public void mapUserToContext(org.springframework.security.core.userdetails.UserDetails ignoredUser, org.springframework.ldap.core.DirContextAdapter ignoredContext) throws org.apache.commons.lang3.NotImplementedException Warning! Not implemented!- Specified by:
mapUserToContextin interfaceorg.springframework.security.ldap.userdetails.UserDetailsContextMapper- Throws:
org.apache.commons.lang3.NotImplementedException- Always!
-