test_class.declarator: resolver = new UsernamePasswordCredentialToPrincipalResolver()
test_class.modifier: private
test_class.original_string: private UsernamePasswordCredentialToPrincipalResolver resolver = new UsernamePasswordCredentialToPrincipalResolver();
test_class.type: UsernamePasswordCredentialToPrincipalResolver
test_class.var_name: resolver
test_class.file: ki4so-core/src/test/java/com/github/ebnew/ki4so/core/authentication/resolvers/UsernamePasswordCredentialToPrincipalResolverTest.java
test_class.identifier: UsernamePasswordCredentialToPrincipalResolverTest
test_case.body: @Test
  	public void testResolvePrincipal(){
  		//测试传入null的情况。
  		Assert.assertNull(resolver.resolvePrincipal(null));
  		
  		//测试传入不支持的凭据类型的情况。
  		Credential credential = Mockito.mock(Credential.class);
  		Assert.assertNull(resolver.resolvePrincipal(credential));
  		
  		//测试传入正确的凭据对象的情况。
  		String username = "admin";
  		UsernamePasswordCredential usernamePasswordCredential = new UsernamePasswordCredential();
  		usernamePasswordCredential.setUsername(username);
  		DefaultUserPrincipal principal = (DefaultUserPrincipal)resolver.resolvePrincipal(usernamePasswordCredential);
  		Assert.assertNotNull(principal);
  		Assert.assertEquals(username, principal.getId());
  		
  		
  	}
test_case.class_method_signature: UsernamePasswordCredentialToPrincipalResolverTest.testResolvePrincipal()
test_case.full_signature: @Test public void testResolvePrincipal()
test_case.identifier: testResolvePrincipal
test_case.invocations: assertNull resolvePrincipal mock assertNull resolvePrincipal setUsername resolvePrincipal assertNotNull assertEquals getId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testResolvePrincipal()
focal_class.declarator: DEFAULT_CLASS = UsernamePasswordCredential.class
focal_class.modifier: private static final
focal_class.original_string: private static final Class<UsernamePasswordCredential> DEFAULT_CLASS = UsernamePasswordCredential.class;
focal_class.type: Class<UsernamePasswordCredential>
focal_class.var_name: DEFAULT_CLASS
focal_class.declarator: classToSupport = DEFAULT_CLASS
focal_class.modifier: private
focal_class.original_string: private Class<?> classToSupport = DEFAULT_CLASS;
focal_class.type: Class<?>
focal_class.var_name: classToSupport
focal_class.declarator: supportSubClasses = true
focal_class.modifier: private
focal_class.original_string: private boolean supportSubClasses = true;
focal_class.type: boolean
focal_class.var_name: supportSubClasses
focal_class.file: ki4so-core/src/main/java/com/github/ebnew/ki4so/core/authentication/resolvers/UsernamePasswordCredentialToPrincipalResolver.java
focal_class.identifier: UsernamePasswordCredentialToPrincipalResolver
focal_class.interfaces: implements CredentialToPrincipalResolver
focal_class.class_method_signature: UsernamePasswordCredentialToPrincipalResolver.setSupportSubClasses(boolean supportSubClasses)
focal_class.full_signature: public void setSupportSubClasses(boolean supportSubClasses)
focal_class.identifier: setSupportSubClasses
focal_class.modifiers: public
focal_class.parameters: (boolean supportSubClasses)
focal_class.return: void
focal_class.signature: void setSupportSubClasses(boolean supportSubClasses)
focal_class.class_method_signature: UsernamePasswordCredentialToPrincipalResolver.resolvePrincipal(Credential credential)
focal_class.full_signature: @Override public Principal resolvePrincipal(Credential credential)
focal_class.identifier: resolvePrincipal
focal_class.modifiers: @Override public
focal_class.parameters: (Credential credential)
focal_class.return: Principal
focal_class.signature: Principal resolvePrincipal(Credential credential)
focal_class.class_method_signature: UsernamePasswordCredentialToPrincipalResolver.supports(Credential credential)
focal_class.full_signature: @Override public boolean supports(Credential credential)
focal_class.identifier: supports
focal_class.modifiers: @Override public
focal_class.parameters: (Credential credential)
focal_class.return: boolean
focal_class.signature: boolean supports(Credential credential)
focal_method.body: @Override
  	public Principal resolvePrincipal(Credential credential) {
  		//若类型匹配，则进行转换。
  		if(credential!=null && this.supports(credential)){
  			UsernamePasswordCredential usernamePasswordCredential = (UsernamePasswordCredential)credential;
  			DefaultUserPrincipal principal = new DefaultUserPrincipal();
  			//设置用户名为唯一标识。
  			principal.setId(usernamePasswordCredential.getUsername());
  			//设置参数表为用户属性。
  			principal.setAttributes(usernamePasswordCredential.getParameters());
  			return principal;
  		}
  		return null;
  	}
focal_method.class_method_signature: UsernamePasswordCredentialToPrincipalResolver.resolvePrincipal(Credential credential)
focal_method.full_signature: @Override public Principal resolvePrincipal(Credential credential)
focal_method.identifier: resolvePrincipal
focal_method.invocations: supports setId getUsername setAttributes getParameters
focal_method.modifiers: @Override public
focal_method.parameters: (Credential credential)
focal_method.return: Principal
focal_method.signature: Principal resolvePrincipal(Credential credential)