Skip to content

Commit 7bc87cf

Browse files
committed
SEC-2002: Polishing
1 parent d89ace2 commit 7bc87cf

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

web/src/main/java/org/springframework/security/web/authentication/session/SessionFixationProtectionStrategy.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,16 @@ private HashMap<String, Object> createMigratedAttributeMap(HttpSession session)
214214
return attributesToMigrate;
215215
}
216216

217+
/**
218+
* Sets the {@link ApplicationEventPublisher} to use for submitting
219+
* {@link SessionFixationProtectionEvent}. The default is to not submit the
220+
* {@link SessionFixationProtectionEvent}.
221+
*
222+
* @param applicationEventPublisher
223+
* the {@link ApplicationEventPublisher}. Cannot be null.
224+
*/
217225
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
226+
Assert.notNull(applicationEventPublisher, "applicationEventPublisher cannot be null");
218227
this.applicationEventPublisher = applicationEventPublisher;
219228
}
220229

web/src/test/java/org/springframework/security/web/authentication/session/ConcurrentSessionControlStrategyTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,14 @@ public void onAuthenticationChangeSessionWithEventPublisher() {
103103
assertEquals(request.getSession().getId(), event.getNewSessionId());
104104
assertSame(authentication, event.getAuthentication());
105105
}
106+
107+
@Test(expected=IllegalArgumentException.class)
108+
public void setApplicationEventPublisherForbidsNulls() {
109+
strategy.setApplicationEventPublisher(null);
110+
}
111+
112+
@Test
113+
public void onAuthenticationNoExceptionWhenRequireApplicationEventPublisherSet() {
114+
strategy.onAuthentication(authentication, request, response);
115+
}
106116
}

0 commit comments

Comments
 (0)