class LogoutAction {

	@RequestMapping("/logout")
	public void logout(HttpServletRequest request,
			HttpServletResponse response) {
		//清除用户登录应用列表。
		//解析用户凭据。
		Credential credential = credentialResolver.resolveCredential(request);
		this.ki4soService.logout(credential);
		
		//清除cookie值。
		Cookie[] cookies = request.getCookies();
		if(cookies!=null && cookies.length>0){
			for(Cookie cookie:cookies){
				if(WebConstants.KI4SO_SERVER_ENCRYPTED_CREDENTIAL_COOKIE_KEY.equals(cookie.getName())){
					//设置过期时间为立即。
					cookie.setMaxAge(0);
					response.addCookie(cookie);
				}
			}
		}
		String json = "{result:true}";
		//拼接jsonp格式的数据。
		StringBuffer sb = new StringBuffer();
		sb.append(getCallbackName("logoutKi4soServer", request))
		.append("(")
		.append(json)
		.append(");");
		//写入jsonp格式的数据。
		try {
			response.setContentType("application/x-javascript");
			response.setCharacterEncoding("UTF-8");
			response.getWriter().println(sb.toString());
		} catch (IOException e) {
		}
	}

}