test_class.declarator: resolver
test_class.modifier: private
test_class.original_string: private EncryCredentialResolver resolver;
test_class.type: EncryCredentialResolver
test_class.var_name: resolver
test_class.file: ki4so-web/src/test/java/com/github/ebnew/ki4so/web/action/EncryCredentialResolverTest.java
test_class.identifier: EncryCredentialResolverTest
test_case.body: @Test
  	public void testResolveCredential(){
  		String cookie = "VS032SDAFDAFD";
  	
  		//测试传入null的情况。
  		Assert.assertNull(resolver.resolveCredential(null));
  		
  		//测试不存在cookie的情况。
  		MockHttpServletRequest request = new MockHttpServletRequest();
  		Assert.assertNull(resolver.resolveCredential(request));
  	
  		//测试存在cookie，但是cookie中值是的元素为null的情况。
  		request = new MockHttpServletRequest();
  		request.setCookies(null, null, null, null);
  		Assert.assertNull(resolver.resolveCredential(request));
  		
  		//测试存在cookie数组，但是有2个不为null的情况。
  		request = new MockHttpServletRequest();
  		request.setCookies(new Cookie("C1", null), null, null, new Cookie("C2", "dafdafdada"));
  		Assert.assertNull(resolver.resolveCredential(request));
  		
  		
  		//测试存在cookie数组，但是有1个不为null的情况，且cookie名称为KI4SO服务端写入的cookie值,但是cookie的值为Null.
  		request = new MockHttpServletRequest();
  		request.setCookies(new Cookie("C1", null), null, null, new Cookie(WebConstants.KI4SO_SERVER_ENCRYPTED_CREDENTIAL_COOKIE_KEY, null));
  		Assert.assertNull(resolver.resolveCredential(request));
  		
  		
  		//测试存在cookie数组，但是有1个不为null的情况，且cookie名称为KI4SO服务端写入的cookie值,但是cookie的值不是Null.
  		request = new MockHttpServletRequest();
  		request.setCookies(new Cookie("C1", null), null, null, new Cookie(WebConstants.KI4SO_SERVER_ENCRYPTED_CREDENTIAL_COOKIE_KEY, cookie));
  		EncryCredential credential = (EncryCredential)resolver.resolveCredential(request);
  		Assert.assertNotNull(credential);
  		Assert.assertEquals(cookie, credential.getCredential());
  	}
test_case.class_method_signature: EncryCredentialResolverTest.testResolveCredential()
test_case.full_signature: @Test public void testResolveCredential()
test_case.identifier: testResolveCredential
test_case.invocations: assertNull resolveCredential assertNull resolveCredential setCookies assertNull resolveCredential setCookies assertNull resolveCredential setCookies assertNull resolveCredential setCookies resolveCredential assertNotNull assertEquals getCredential
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testResolveCredential()
focal_class.file: ki4so-web/src/main/java/com/github/ebnew/ki4so/web/action/EncryCredentialResolver.java
focal_class.identifier: EncryCredentialResolver
focal_class.interfaces: implements CredentialResolver
focal_class.class_method_signature: EncryCredentialResolver.resolveCredential(HttpServletRequest request)
focal_class.full_signature: @Override public Credential resolveCredential(HttpServletRequest request)
focal_class.identifier: resolveCredential
focal_class.modifiers: @Override public
focal_class.parameters: (HttpServletRequest request)
focal_class.return: Credential
focal_class.signature: Credential resolveCredential(HttpServletRequest request)
focal_method.body: @Override
  	public Credential resolveCredential(HttpServletRequest request) {
  		if(request!=null){
  			//查找请求中的cookie。
  			Cookie[] cookies = request.getCookies();
  			if(cookies!=null){
  				String value = null;
  				for(Cookie cookie:cookies){
  					//若查找到KI4SO写入的cookie值。
  					if(cookie!=null && cookie.getName().equalsIgnoreCase(WebConstants.KI4SO_SERVER_ENCRYPTED_CREDENTIAL_COOKIE_KEY)){
  						value = cookie.getValue();
  						break;
  					}
  				}
  				//如果cookie中没有凭据值，则从请求参数中获取凭据值。
  				if(StringUtils.isEmpty(value)){
  					value = request.getParameter(WebConstants.KI4SO_SERVER_ENCRYPTED_CREDENTIAL_COOKIE_KEY);
  				}
  				//最终如果加密凭据有值，则直接返回凭据对象。
  				if(!StringUtils.isEmpty(value)){
  					//去除空串后返回。
  					return new EncryCredential(value.trim());
  				}
  			}
  		}
  		return null;
  	}
focal_method.class_method_signature: EncryCredentialResolver.resolveCredential(HttpServletRequest request)
focal_method.full_signature: @Override public Credential resolveCredential(HttpServletRequest request)
focal_method.identifier: resolveCredential
focal_method.invocations: getCookies equalsIgnoreCase getName getValue isEmpty getParameter isEmpty trim
focal_method.modifiers: @Override public
focal_method.parameters: (HttpServletRequest request)
focal_method.return: Credential
focal_method.signature: Credential resolveCredential(HttpServletRequest request)