当前位置: 首页>>代码示例>>Java>>正文


Java SessionRegistry类代码示例

本文整理汇总了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();
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:17,代码来源:ConcurrentSessionControlStrategyImpl.java

示例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);
    }};
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:12,代码来源:SessionConfig.java

示例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;
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:8,代码来源:WebSecurityConfig.java

示例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;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:8,代码来源:UserSessionController.java

示例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);
        }};
    }
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:12,代码来源:SessionConfig.java

示例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;
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:31,代码来源:NoneLoginException.java

示例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));
        }
    }
}
 
开发者ID:helicalinsight,项目名称:helicalinsight,代码行数:11,代码来源:SystemInformationProvider.java

示例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);
            }
        }
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-wm,代码行数:10,代码来源:SpringAwareWebFilter.java

示例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);
}
 
开发者ID:hazelcast,项目名称:hazelcast-wm,代码行数:40,代码来源:SpringAwareWebFilterTest.java

示例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();
    }
}
 
开发者ID:ozoneplatform,项目名称:owf-security,代码行数:34,代码来源:OzoneConcurrentSessionControlStrategy.java

示例11: ProfileRestController

import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
public ProfileRestController(ProfileService profileService, SessionRegistry sessionRegistry) {
	this.profileService = profileService;
	this.sessionRegistry = sessionRegistry;
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:5,代码来源:ProfileRestController.java

示例12: sessionRegistry

import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
@Bean
public SessionRegistry sessionRegistry() {
	return new SessionRegistryImpl();
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:5,代码来源:WebSessionConfig.java

示例13: sessionRegistry

import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
@Bean
protected SessionRegistry sessionRegistry() {
    return new SessionRegistryImpl();
}
 
开发者ID:chaokunyang,项目名称:amanda,代码行数:5,代码来源:SecurityConfiguration.java

示例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;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:7,代码来源:UserSessionController.java

示例15: sessionRegistry

import org.springframework.security.core.session.SessionRegistry; //导入依赖的package包/类
@Bean
public SessionRegistry sessionRegistry(){
    return new SessionRegistryImpl();
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:5,代码来源:SessionConfig.java


注:本文中的org.springframework.security.core.session.SessionRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。