Added tests for SpringSecurityAuthenticationSource.
This commit is contained in:
@@ -59,11 +59,11 @@ public class SpringSecurityAuthenticationSource implements AuthenticationSource
|
||||
public String getCredentials() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
if (authentication != null) {
|
||||
return (String) authentication.getCredentials();
|
||||
} else {
|
||||
if (authentication == null) {
|
||||
log.warn("No Authentication object set in SecurityContext - returning empty String as Credentials");
|
||||
return "";
|
||||
}
|
||||
|
||||
return (String) authentication.getCredentials();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.springframework.security.util.AuthorityUtils;
|
||||
import org.springframework.ldap.core.DirContextOperations;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.naming.Name;
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.BasicAttributes;
|
||||
import java.util.ArrayList;
|
||||
@@ -110,7 +111,7 @@ public class LdapUserDetailsImpl implements LdapUserDetails {
|
||||
public Essence() { }
|
||||
|
||||
public Essence(DirContextOperations ctx) {
|
||||
setDn(ctx.getDn().toString());
|
||||
setDn(ctx.getDn());
|
||||
}
|
||||
|
||||
public Essence(LdapUserDetails copyMe) {
|
||||
@@ -190,6 +191,10 @@ public class LdapUserDetailsImpl implements LdapUserDetails {
|
||||
instance.dn = dn;
|
||||
}
|
||||
|
||||
public void setDn(Name dn) {
|
||||
instance.dn = dn.toString();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
instance.enabled = enabled;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user