Commit 1aa7b30b authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '2.1.x'

parents 738da8ff 8e6b4629
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -103,7 +103,9 @@ public class AuthenticationAuditListener extends AbstractAuthenticationAuditList ...@@ -103,7 +103,9 @@ public class AuthenticationAuditListener extends AbstractAuthenticationAuditList
if (event.getAuthentication().getDetails() != null) { if (event.getAuthentication().getDetails() != null) {
data.put("details", event.getAuthentication().getDetails()); data.put("details", event.getAuthentication().getDetails());
} }
if (event.getTargetUser() != null) {
data.put("target", event.getTargetUser().getUsername()); data.put("target", event.getTargetUser().getUsername());
}
listener.publish(new AuditEvent(event.getAuthentication().getName(), listener.publish(new AuditEvent(event.getAuthentication().getName(),
AUTHENTICATION_SWITCH, data)); AUTHENTICATION_SWITCH, data));
} }
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -92,6 +92,16 @@ public class AuthenticationAuditListenerTests { ...@@ -92,6 +92,16 @@ public class AuthenticationAuditListenerTests {
.isEqualTo(AuthenticationAuditListener.AUTHENTICATION_SWITCH); .isEqualTo(AuthenticationAuditListener.AUTHENTICATION_SWITCH);
} }
@Test
public void testAuthenticationSwitchBackToAnonymous() {
AuditApplicationEvent event = handleAuthenticationEvent(
new AuthenticationSwitchUserEvent(
new UsernamePasswordAuthenticationToken("user", "password"),
null));
assertThat(event.getAuditEvent().getType())
.isEqualTo(AuthenticationAuditListener.AUTHENTICATION_SWITCH);
}
@Test @Test
public void testDetailsAreIncludedInAuditEvent() { public void testDetailsAreIncludedInAuditEvent() {
Object details = new Object(); Object details = new Object();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment