mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-15 00:22:15 +00:00
SEC-1304: Removed compareTo method from GrantedAuthorityImpl
This method had been left by mistake when the Comparable interface was removed. See also SEC-1347.
This commit is contained in:
parent
c6b8fe5e55
commit
93973a4b75
@ -32,7 +32,6 @@ import org.springframework.util.Assert;
|
|||||||
* method will return -1, so the custom authority will take precedence.
|
* method will return -1, so the custom authority will take precedence.
|
||||||
*
|
*
|
||||||
* @author Ben Alex
|
* @author Ben Alex
|
||||||
* @version $Id$
|
|
||||||
*/
|
*/
|
||||||
public class GrantedAuthorityImpl implements GrantedAuthority, Serializable {
|
public class GrantedAuthorityImpl implements GrantedAuthority, Serializable {
|
||||||
//~ Instance fields ================================================================================================
|
//~ Instance fields ================================================================================================
|
||||||
@ -74,17 +73,4 @@ public class GrantedAuthorityImpl implements GrantedAuthority, Serializable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return this.role;
|
return this.role;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(GrantedAuthority ga) {
|
|
||||||
if (ga != null) {
|
|
||||||
String rhsRole = ga.getAuthority();
|
|
||||||
|
|
||||||
if (rhsRole == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return role.compareTo(rhsRole);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -61,30 +61,12 @@ public class GrantedAuthorityImplTests {
|
|||||||
assertEquals("TEST", auth.toString());
|
assertEquals("TEST", auth.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void compareToGrantedAuthorityWithSameValueReturns0() {
|
|
||||||
assertEquals(0, new GrantedAuthorityImpl("TEST").compareTo(new MockGrantedAuthority("TEST")));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void compareToNullReturnsNegativeOne() {
|
|
||||||
assertEquals(-1, new GrantedAuthorityImpl("TEST").compareTo(null));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* SEC-899 */
|
|
||||||
@Test
|
|
||||||
public void compareToHandlesCustomAuthorityWhichReturnsNullFromGetAuthority() {
|
|
||||||
assertEquals(-1, new GrantedAuthorityImpl("TEST").compareTo(new MockGrantedAuthority()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//~ Inner Classes ==================================================================================================
|
//~ Inner Classes ==================================================================================================
|
||||||
|
|
||||||
private class MockGrantedAuthority implements GrantedAuthority {
|
private class MockGrantedAuthority implements GrantedAuthority {
|
||||||
private String role;
|
private String role;
|
||||||
|
|
||||||
public MockGrantedAuthority() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public MockGrantedAuthority(String role) {
|
public MockGrantedAuthority(String role) {
|
||||||
this.role = role;
|
this.role = role;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user