mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-04 01:32:14 +00:00
SEC-688: java.lang.NullPointerException in AbstractAuthenticationToken.equals()
http://jira.springframework.org/browse/SEC-688
This commit is contained in:
parent
e6e1f2586f
commit
709f78e481
@ -111,8 +111,15 @@ public abstract class AbstractAuthenticationToken implements Authentication {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (this.getPrincipal().equals(test.getPrincipal())
|
if (this.getPrincipal() == null && test.getPrincipal() != null) {
|
||||||
&& (this.isAuthenticated() == test.isAuthenticated()));
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.getPrincipal() != null && !this.getPrincipal().equals(test.getPrincipal())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.isAuthenticated() == test.isAuthenticated();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -45,4 +45,8 @@ public class X509AuthenticationTokenTests extends TestCase {
|
|||||||
token.setAuthenticated(true);
|
token.setAuthenticated(true);
|
||||||
assertTrue(token.isAuthenticated());
|
assertTrue(token.isAuthenticated());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testEquals() throws Exception {
|
||||||
|
assertEquals(X509TestUtils.createToken(), X509TestUtils.createToken());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,8 +100,7 @@ public class X509TestUtils {
|
|||||||
return (X509Certificate) cf.generateCertificate(in);
|
return (X509Certificate) cf.generateCertificate(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static X509AuthenticationToken createToken()
|
public static X509AuthenticationToken createToken() throws Exception {
|
||||||
throws Exception {
|
|
||||||
return new X509AuthenticationToken(buildTestCertificate());
|
return new X509AuthenticationToken(buildTestCertificate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user