appfuse中的远程认证

最近两天查看了appfuse中的源码,利用断点追踪了解里面的security内部实现。

如果玩家登陆成功后,会在session放一个securityContext对象,key为HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY=”SPRING_SECURITY_CONTEXT”;

以下为认证成功后登陆代码:

	protected void loginSuccess(User user) {
		HttpSession session = getSession();
		SecurityContext securityContext = SecurityContextHolder
				.createEmptyContext();
		UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken(
				user, "password", user.getAuthorities());
		// result.setDetails(user);
		securityContext.setAuthentication(result);

		session.setAttribute(SECURITY_CONTEXT_KEY, securityContext);
	}
发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


Warning: Use of undefined constant XML - assumed 'XML' (this will throw an Error in a future version of PHP) in /opt/wordpress/wp-content/plugins/wp-syntaxhighlighter/wp-syntaxhighlighter.php on line 1048