test_class.declarator: resolver
test_class.modifier: private
test_class.original_string: private EncryCredentialToPrincipalResolver resolver;
test_class.type: EncryCredentialToPrincipalResolver
test_class.var_name: resolver
test_class.file: ki4so-core/src/test/java/com/github/ebnew/ki4so/core/authentication/resolvers/EncryCredentialToPrincipalResolverTest.java
test_class.identifier: EncryCredentialToPrincipalResolverTest
test_case.body: @Test
      public void testResolvePrincipal() {
          //测试null情况。
          assertNull(this.resolver.resolvePrincipal(null));
  
          //测试不只是的用户凭据对象。
          Credential credential = Mockito.mock(Credential.class);
          assertNull(this.resolver.resolvePrincipal(credential));
  
          //测试正常情况。
          String userId = "test";
          EncryCredential encryCredential = new EncryCredential("ddd");
          Map<String, Object> param = new HashMap<String, Object>();
          encryCredential.setParameters(param);
          EncryCredentialInfo encryCredentialInfo = new EncryCredentialInfo();
          encryCredentialInfo.setUserId(userId);
          encryCredential.setEncryCredentialInfo(encryCredentialInfo);
          Principal principal = this.resolver.resolvePrincipal(encryCredential);
          assertNotNull(principal);
          assertEquals(userId, principal.getId());
          assertEquals(param, principal.getAttributes());
      }
test_case.class_method_signature: EncryCredentialToPrincipalResolverTest.testResolvePrincipal()
test_case.full_signature: @Test public void testResolvePrincipal()
test_case.identifier: testResolvePrincipal
test_case.invocations: assertNull resolvePrincipal mock assertNull resolvePrincipal setParameters setUserId setEncryCredentialInfo resolvePrincipal assertNotNull assertEquals getId assertEquals getAttributes
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testResolvePrincipal()
focal_class.declarator: DEFAULT_CLASS = EncryCredential.class
focal_class.modifier: private static final
focal_class.original_string: private static final Class<EncryCredential> DEFAULT_CLASS = EncryCredential.class;
focal_class.type: Class<EncryCredential>
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/EncryCredentialToPrincipalResolver.java
focal_class.identifier: EncryCredentialToPrincipalResolver
focal_class.interfaces: implements CredentialToPrincipalResolver
focal_class.class_method_signature: EncryCredentialToPrincipalResolver.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: EncryCredentialToPrincipalResolver.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: EncryCredentialToPrincipalResolver.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)) {
              EncryCredential encryCredential = (EncryCredential) credential;
              DefaultUserPrincipal principal = new DefaultUserPrincipal();
              //解析加密后凭据信息。
              EncryCredentialInfo encryCredentialInfo = encryCredential.getEncryCredentialInfo();
              //设置用户名为唯一标识。
              if (encryCredentialInfo != null) {
                  principal.setId(encryCredentialInfo.getUserId());
                  //设置参数表为用户属性。
                  principal.setAttributes(encryCredential.getParameters());
              }
              return principal;
          }
          return null;
      }
focal_method.class_method_signature: EncryCredentialToPrincipalResolver.resolvePrincipal(Credential credential)
focal_method.full_signature: @Override public Principal resolvePrincipal(Credential credential)
focal_method.identifier: resolvePrincipal
focal_method.invocations: supports getEncryCredentialInfo setId getUserId setAttributes getParameters
focal_method.modifiers: @Override public
focal_method.parameters: (Credential credential)
focal_method.return: Principal
focal_method.signature: Principal resolvePrincipal(Credential credential)