test_class.declarator: logoutAction
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private LogoutAction logoutAction;
test_class.type: LogoutAction
test_class.var_name: logoutAction
test_class.file: ki4so-web/src/test/java/com/github/ebnew/ki4so/web/action/LogoutActionTest.java
test_class.identifier: LogoutActionTest
test_case.body: @Test
  	public void testLogout() {
  		MockHttpServletRequest request = new MockHttpServletRequest();
  		MockHttpServletResponse response = new MockHttpServletResponse();
  		
  		CredentialResolver credentialResolver = Mockito.mock(CredentialResolver.class);
  		logoutAction.setCredentialResolver(credentialResolver);
  		
  		Ki4soService ki4soService = Mockito.mock(Ki4soService.class);
  		logoutAction.setKi4soService(ki4soService);
  		
  		//测试没有cookie的情况。
  		logoutAction.logout(request, response);
  		Assert.assertEquals(0, response.getCookies().length);
  		
  		//测试存在cookie，登出后要清除cookie值。
  		request = new MockHttpServletRequest();
  		response = new MockHttpServletResponse();
  		request.setCookies(new Cookie(WebConstants.KI4SO_SERVER_ENCRYPTED_CREDENTIAL_COOKIE_KEY, "dddsd"));
  		logoutAction.logout(request, response);
  		Assert.assertEquals(1, response.getCookies().length);
  		Assert.assertEquals(0, response.getCookies()[0].getMaxAge());
  	}
test_case.class_method_signature: LogoutActionTest.testLogout()
test_case.full_signature: @Test public void testLogout()
test_case.identifier: testLogout
test_case.invocations: mock setCredentialResolver mock setKi4soService logout assertEquals getCookies setCookies logout assertEquals getCookies assertEquals getMaxAge getCookies
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testLogout()
focal_class.declarator: credentialResolver
focal_class.modifier: @Autowired
  	protected
focal_class.original_string: @Autowired
  	protected CredentialResolver credentialResolver;
focal_class.type: CredentialResolver
focal_class.var_name: credentialResolver
focal_class.declarator: ki4soService
focal_class.modifier: @Autowired
  	protected
focal_class.original_string: @Autowired
  	protected Ki4soService ki4soService;
focal_class.type: Ki4soService
focal_class.var_name: ki4soService
focal_class.file: ki4so-web/src/main/java/com/github/ebnew/ki4so/web/action/LogoutAction.java
focal_class.identifier: LogoutAction
focal_class.class_method_signature: LogoutAction.setKi4soService(Ki4soService ki4soService)
focal_class.full_signature: public void setKi4soService(Ki4soService ki4soService)
focal_class.identifier: setKi4soService
focal_class.modifiers: public
focal_class.parameters: (Ki4soService ki4soService)
focal_class.return: void
focal_class.signature: void setKi4soService(Ki4soService ki4soService)
focal_class.class_method_signature: LogoutAction.setCredentialResolver(CredentialResolver credentialResolver)
focal_class.full_signature: public void setCredentialResolver(CredentialResolver credentialResolver)
focal_class.identifier: setCredentialResolver
focal_class.modifiers: public
focal_class.parameters: (CredentialResolver credentialResolver)
focal_class.return: void
focal_class.signature: void setCredentialResolver(CredentialResolver credentialResolver)
focal_class.class_method_signature: LogoutAction.getAppList(HttpServletRequest request,
  			HttpServletResponse response)
focal_class.full_signature: @RequestMapping("/getAppList") public void getAppList(HttpServletRequest request,
  			HttpServletResponse response)
focal_class.identifier: getAppList
focal_class.modifiers: @RequestMapping("/getAppList") public
focal_class.parameters: (HttpServletRequest request,
  			HttpServletResponse response)
focal_class.return: void
focal_class.signature: void getAppList(HttpServletRequest request,
  			HttpServletResponse response)
focal_class.class_method_signature: LogoutAction.getCallbackName(String defalutCallbackName, HttpServletRequest request)
focal_class.full_signature: private String getCallbackName(String defalutCallbackName, HttpServletRequest request)
focal_class.identifier: getCallbackName
focal_class.modifiers: private
focal_class.parameters: (String defalutCallbackName, HttpServletRequest request)
focal_class.return: String
focal_class.signature: String getCallbackName(String defalutCallbackName, HttpServletRequest request)
focal_class.class_method_signature: LogoutAction.logout(HttpServletRequest request,
  			HttpServletResponse response)
focal_class.full_signature: @RequestMapping("/logout") public void logout(HttpServletRequest request,
  			HttpServletResponse response)
focal_class.identifier: logout
focal_class.modifiers: @RequestMapping("/logout") public
focal_class.parameters: (HttpServletRequest request,
  			HttpServletResponse response)
focal_class.return: void
focal_class.signature: void logout(HttpServletRequest request,
  			HttpServletResponse response)
focal_method.body: @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) {
  		}
  	}
focal_method.class_method_signature: LogoutAction.logout(HttpServletRequest request,
  			HttpServletResponse response)
focal_method.full_signature: @RequestMapping("/logout") public void logout(HttpServletRequest request,
  			HttpServletResponse response)
focal_method.identifier: logout
focal_method.invocations: resolveCredential logout getCookies equals getName setMaxAge addCookie append append append append getCallbackName setContentType setCharacterEncoding println getWriter toString
focal_method.modifiers: @RequestMapping("/logout") public
focal_method.parameters: (HttpServletRequest request,
  			HttpServletResponse response)
focal_method.return: void
focal_method.signature: void logout(HttpServletRequest request,
  			HttpServletResponse response)