本文整理汇总了Java中org.springframework.security.core.session.SessionRegistry类的典型用法代码示例。如果您正苦于以下问题:Java SessionRegistry类的具体用法?Java SessionRegistry怎么用?Java SessionRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionRegistry类属于org.springframework.security.core.session包,在下文中一共展示了SessionRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: allowableSessionsExceeded
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
@Override
protected void allowableSessionsExceeded(List<SessionInformation> sessions, int allowableSessions,
SessionRegistry registry) throws SessionAuthenticationException {
SessionInformation leastRecentlyUsed = null;
for (SessionInformation session : sessions) {
if ((leastRecentlyUsed == null)
|| session.getLastRequest().before(leastRecentlyUsed.getLastRequest())) {
leastRecentlyUsed = session;
}
}
if(leastRecentlyUsed instanceof SessionInformationObject){
SessionInformationObject sessionObject=(SessionInformationObject)leastRecentlyUsed;
sessionObject.setKickAway(true);
}
leastRecentlyUsed.expireNow();
}
示例2: sessionAuthenticationStrategy
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
/**
* sessionAuthenticationStrategy does not work in JavaConfig
* @param sessionRegistry
* @return
*/
@Bean
public SessionAuthenticationStrategy sessionAuthenticationStrategy(SessionRegistry sessionRegistry){
return new ConcurrentSessionControlAuthenticationStrategy(sessionRegistry){{
setMaximumSessions(-1);
}};
}
示例3: WebSecurityConfig
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
public WebSecurityConfig(UserService userService, PasswordEncoder passwordEncoder,
RememberMeServices rememberMeServices, SessionRegistry sessionRegistry) {
this.userService = userService;
this.passwordEncoder = passwordEncoder;
this.rememberMeServices = rememberMeServices;
this.sessionRegistry = sessionRegistry;
}
示例4: UserSessionController
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
@Autowired
public UserSessionController(SessionRegistry sessionRegistry) {
if (sessionRegistry == null) {
throw new IllegalArgumentException("sessionRegistry cannot be null");
}
this.sessionRegistry = sessionRegistry;
}
示例5: sessionAuthenticationStrategy
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
/**
* sessionAuthenticationStrategy does not work in JavaConfig
* @param sessionRegistry
* @return
*/
// @Bean
public SessionAuthenticationStrategy sessionAuthenticationStrategy(SessionRegistry sessionRegistry){
return new ConcurrentSessionControlAuthenticationStrategy(sessionRegistry){{
setMaximumSessions(-1);
}};
}
示例6: NoneLoginException
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
public NoneLoginException(String msg) {
super(msg);
HttpServletRequest request=ContextHolder.getRequest();
if(request==null){
return;
}
HttpSession session = request.getSession(false);
if (session == null) {
return;
}
String state=(String)session.getAttribute(SessionStateConstants.SESSION_STATE);
if(state==null){
SessionRegistry sessionRegistry=ContextHolder.getBean("bdf2.sessionRegistry");
SessionInformation info = sessionRegistry.getSessionInformation(session.getId());
if(info==null){
return;
}
if(info instanceof SessionInformationObject){
SessionInformationObject obj=(SessionInformationObject)info;
if(obj.isKickAway()){
session.setAttribute(SessionStateConstants.SESSION_STATE, SessionStateConstants.KICKAWAY);
this.sessionKickAway=true;
}
}else if(info.isExpired()){
session.setAttribute(SessionStateConstants.SESSION_STATE, SessionStateConstants.EXPIRED);
}
}else if(state.equals(SessionStateConstants.KICKAWAY)){
this.sessionKickAway=true;
}
}
示例7: getAllUsers
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
private void getAllUsers(JSONObject sysInfo) {
SessionRegistry sessionRegistry = (SessionRegistry) ApplicationContextAccessor.getBean("sessionRegistry");
List<Object> principals = sessionRegistry.getAllPrincipals();
for (Object principal : principals) {
if (principal instanceof User) {
User user = ((User) principal);
sysInfo.accumulate("users", JSONObject.fromObject(user));
}
}
}
示例8: ensureSessionRegistryInitialized
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
protected void ensureSessionRegistryInitialized(ApplicationContext appContext) {
if (sessionRegistry == null) {
synchronized (this) {
if (sessionRegistry == null) {
sessionRegistry = appContext.getBean(SessionRegistry.class);
}
}
}
}
示例9: test_issue_3049
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
@Test
public void test_issue_3049() throws Exception {
Set<ApplicationContext> applicationContextSet =
SpringApplicationContextProvider.getApplicationContextSet();
Iterator<ApplicationContext> i = applicationContextSet.iterator();
ApplicationContext applicationContext1 = i.next();
ApplicationContext applicationContext2 = i.next();
SessionRegistry sessionRegistry1 = applicationContext1.getBean(SessionRegistry.class);
SessionRegistry sessionRegistry2 = applicationContext2.getBean(SessionRegistry.class);
SpringSecuritySession sss = login(null, false);
request("hello", serverPort1, sss.cookieStore);
String sessionId = sss.getSessionId();
String hazelcastSessionId = sss.getHazelcastSessionId();
assertTrue(
"Native session must not exist in both Spring session registry of Node-1 and Node-2 after login",
sessionRegistry1.getSessionInformation(sessionId) == null &&
sessionRegistry2.getSessionInformation(sessionId) == null);
assertTrue(
"Hazelcast session must exist locally in one of the Spring session registry of Node-1 and Node-2 after login",
sessionRegistry1.getSessionInformation(hazelcastSessionId) != null ||
sessionRegistry2.getSessionInformation(hazelcastSessionId) != null);
logout(sss);
assertTrue(
"Native session must not exist in both Spring session registry of Node-1 and Node-2 after logout",
sessionRegistry1.getSessionInformation(sessionId) == null &&
sessionRegistry2.getSessionInformation(sessionId) == null);
assertTrue(
"Hazelcast session must not exist in both Spring session registry of Node-1 and Node-2 after logout",
sessionRegistry1.getSessionInformation(hazelcastSessionId) == null &&
sessionRegistry2.getSessionInformation(hazelcastSessionId) == null);
}
示例10: allowableSessionsExceeded
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
/**
* This method has been copied from ConcurrentSessionControlStrategy and modified to
* better ensure that more that the allowed number of sessions are never valid
* at the same time.
*
* @see ConcurentSessionControlStrategy.allowableSessionsExceeded
*/
protected void allowableSessionsExceeded(List<SessionInformation> sessions,
int allowableSessions, SessionRegistry registry)
throws SessionAuthenticationException {
if (exceptionIfMaximumExceeded || (sessions == null)) {
throw new SessionAuthenticationException(messages.getMessage(
"ConcurrentSessionControlStrategy.exceededAllowed",
new Object[] {new Integer(allowableSessions)},
"Maximum sessions of {0} for this principal exceeded"));
}
//BEGIN CUSTOMIZATIONS
log.debug("allowableSessionExceeded. allowed: " + allowableSessions + " Current: " +
sessions.size());
//sort the session by recency, increasing
Collections.sort(sessions, comparator);
//note - sessions does not include the new session being authenticated
int sessionsToExpire = sessions.size() - allowableSessions + 1;
//remove the first sessionToExpire sessions from the sorted list
for (int i = 0; i < sessionsToExpire; i++) {
sessions.get(i).expireNow();
}
}
示例11: ProfileRestController
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
public ProfileRestController(ProfileService profileService, SessionRegistry sessionRegistry) {
this.profileService = profileService;
this.sessionRegistry = sessionRegistry;
}
示例12: sessionRegistry
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
@Bean
public SessionRegistry sessionRegistry() {
return new SessionRegistryImpl();
}
示例13: sessionRegistry
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
@Bean
protected SessionRegistry sessionRegistry() {
return new SessionRegistryImpl();
}
示例14: UserSessionController
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
public UserSessionController(SessionRegistry sessionRegistry) {
if (sessionRegistry == null) {
throw new IllegalArgumentException("sessionRegistry cannot be null");
}
this.sessionRegistry = sessionRegistry;
}
示例15: sessionRegistry
import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
@Bean
public SessionRegistry sessionRegistry(){
return new SessionRegistryImpl();
}