mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-25 05:22:16 +00:00
Polish SessionIdChangedEvent
Add AbstractSessionEvent; clean up license headers and Javadocs Fixes: gh-5438
This commit is contained in:
parent
5fc6414377
commit
b2ea0ba775
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2020 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.security.core.session;
|
||||||
|
|
||||||
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract superclass for all session related events.
|
||||||
|
*
|
||||||
|
* @author Eleftheria Stein
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public class AbstractSessionEvent extends ApplicationEvent {
|
||||||
|
|
||||||
|
public AbstractSessionEvent(Object source) {
|
||||||
|
super(source);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2020 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.
|
||||||
@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.security.core.session;
|
package org.springframework.security.core.session;
|
||||||
|
|
||||||
import org.springframework.context.ApplicationEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic session creation event which indicates that a session (potentially represented
|
* Generic session creation event which indicates that a session (potentially represented
|
||||||
* by a security context) has begun.
|
* by a security context) has begun.
|
||||||
@ -24,7 +22,7 @@ import org.springframework.context.ApplicationEvent;
|
|||||||
* @author Luke Taylor
|
* @author Luke Taylor
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public abstract class SessionCreationEvent extends ApplicationEvent {
|
public abstract class SessionCreationEvent extends AbstractSessionEvent {
|
||||||
|
|
||||||
public SessionCreationEvent(Object source) {
|
public SessionCreationEvent(Object source) {
|
||||||
super(source);
|
super(source);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2020 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.
|
||||||
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.security.core.session;
|
package org.springframework.security.core.session;
|
||||||
|
|
||||||
import org.springframework.context.ApplicationEvent;
|
|
||||||
import org.springframework.security.core.context.SecurityContext;
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -27,7 +26,7 @@ import java.util.*;
|
|||||||
* @author Luke Taylor
|
* @author Luke Taylor
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public abstract class SessionDestroyedEvent extends ApplicationEvent {
|
public abstract class SessionDestroyedEvent extends AbstractSessionEvent {
|
||||||
|
|
||||||
public SessionDestroyedEvent(Object source) {
|
public SessionDestroyedEvent(Object source) {
|
||||||
super(source);
|
super(source);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2016 the original author or authors.
|
* Copyright 2002-2020 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.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@ -15,15 +15,30 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.security.core.session;
|
package org.springframework.security.core.session;
|
||||||
|
|
||||||
import org.springframework.context.ApplicationEvent;
|
/**
|
||||||
|
* Generic "session ID changed" event which indicates that a session
|
||||||
public abstract class SessionIdChangedEvent extends ApplicationEvent {
|
* identifier (potentially represented by a security context) has changed.
|
||||||
|
*
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public abstract class SessionIdChangedEvent extends AbstractSessionEvent {
|
||||||
|
|
||||||
public SessionIdChangedEvent(Object source) {
|
public SessionIdChangedEvent(Object source) {
|
||||||
super(source);
|
super(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the old session ID.
|
||||||
|
*
|
||||||
|
* @return the identifier that was previously associated with
|
||||||
|
* the session.
|
||||||
|
*/
|
||||||
public abstract String getOldSessionId();
|
public abstract String getOldSessionId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the new session ID.
|
||||||
|
*
|
||||||
|
* @return the new identifier that is associated with the session.
|
||||||
|
*/
|
||||||
public abstract String getNewSessionId();
|
public abstract String getNewSessionId();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ package org.springframework.security.core.session;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.context.ApplicationEvent;
|
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
* @author Luke Taylor
|
* @author Luke Taylor
|
||||||
*/
|
*/
|
||||||
public class SessionRegistryImpl implements SessionRegistry,
|
public class SessionRegistryImpl implements SessionRegistry,
|
||||||
ApplicationListener<ApplicationEvent> {
|
ApplicationListener<AbstractSessionEvent> {
|
||||||
|
|
||||||
// ~ Instance fields
|
// ~ Instance fields
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
@ -102,7 +101,7 @@ public class SessionRegistryImpl implements SessionRegistry,
|
|||||||
return sessionIds.get(sessionId);
|
return sessionIds.get(sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onApplicationEvent(ApplicationEvent event) {
|
public void onApplicationEvent(AbstractSessionEvent event) {
|
||||||
if (event instanceof SessionDestroyedEvent) {
|
if (event instanceof SessionDestroyedEvent) {
|
||||||
SessionDestroyedEvent sessionDestroyedEvent = (SessionDestroyedEvent) event;
|
SessionDestroyedEvent sessionDestroyedEvent = (SessionDestroyedEvent) event;
|
||||||
String sessionId = sessionDestroyedEvent.getId();
|
String sessionId = sessionDestroyedEvent.getId();
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
|
* Copyright 2002-2020 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.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@ -16,33 +16,33 @@
|
|||||||
|
|
||||||
package org.springframework.security.web.session;
|
package org.springframework.security.web.session;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import org.springframework.security.core.session.SessionIdChangedEvent;
|
import org.springframework.security.core.session.SessionIdChangedEvent;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Published by the {@link HttpSessionEventPublisher} when an {@code HttpSession} id
|
* Published by the {@link HttpSessionEventPublisher} when an {@link HttpSession} ID
|
||||||
* is changed
|
* is changed.
|
||||||
*
|
*
|
||||||
|
* @since 5.4
|
||||||
*/
|
*/
|
||||||
public class HttpSessionIdChangedEvent extends SessionIdChangedEvent {
|
public class HttpSessionIdChangedEvent extends SessionIdChangedEvent {
|
||||||
private final String oldSessionId;
|
private final String oldSessionId;
|
||||||
private final String newSessionid;
|
private final String newSessionId;
|
||||||
// ~ Constructors
|
|
||||||
// ===================================================================================================
|
|
||||||
|
|
||||||
public HttpSessionIdChangedEvent(HttpSession session, String oldSessionId) {
|
public HttpSessionIdChangedEvent(HttpSession session, String oldSessionId) {
|
||||||
super(session);
|
super(session);
|
||||||
this.oldSessionId = oldSessionId;
|
this.oldSessionId = oldSessionId;
|
||||||
this.newSessionid = session.getId();
|
this.newSessionId = session.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getOldSessionId() {
|
public String getOldSessionId() {
|
||||||
return oldSessionId;
|
return oldSessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNewSessionId() {
|
public String getNewSessionId() {
|
||||||
return newSessionid;
|
return newSessionId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user