mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-30 16:52:13 +00:00
SEC-2690: Polish LdapAuthority
- Make dn required (as javadoc inidicates) - Simplify .equals since role cannot be null - Formatting polish
This commit is contained in:
parent
aac4ede3a4
commit
0f6235bbe0
@ -16,6 +16,7 @@
|
||||
package org.springframework.security.ldap.userdetails;
|
||||
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -52,7 +53,9 @@ public class LdapAuthority implements GrantedAuthority {
|
||||
* @param attributes
|
||||
*/
|
||||
public LdapAuthority(String role, String dn, Map<String, List<String>> attributes) {
|
||||
if (role == null) throw new NullPointerException("role can not be null");
|
||||
Assert.notNull(role, "role can not be null");
|
||||
Assert.notNull(dn, "dn can not be null");
|
||||
|
||||
this.role = role;
|
||||
this.dn = dn;
|
||||
this.attributes = attributes;
|
||||
@ -121,15 +124,19 @@ public class LdapAuthority implements GrantedAuthority {
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof LdapAuthority)) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof LdapAuthority)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LdapAuthority that = (LdapAuthority) o;
|
||||
|
||||
if (!dn.equals(that.dn)) return false;
|
||||
if (role != null ? !role.equals(that.role) : that.role != null) return false;
|
||||
|
||||
return true;
|
||||
if (!dn.equals(that.dn)) {
|
||||
return false;
|
||||
}
|
||||
return role.equals(that.role);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user