test_class.declarator: handler
test_class.modifier: private
test_class.original_string: private DefaultAuthenticationPostHandler handler;
test_class.type: DefaultAuthenticationPostHandler
test_class.var_name: handler
test_class.file: ki4so-core/src/test/java/com/github/ebnew/ki4so/core/authentication/DefaultAuthenticationPostHandlerTest.java
test_class.identifier: DefaultAuthenticationPostHandlerTest
test_case.body: @Test
      public void testPostAuthentication() {
  
          /**
           * 测试传入错误参数的情况。
           */
          Authentication authentication = this.handler.postAuthentication(null, null);
          assertNotNull(authentication);
          Assert.assertNull(authentication.getPrincipal());
  
          /**
           * 测试参数正确的情况，但是ki4so 服务器的app对象为空的情况。
           */
          String username = "test";
          String password = "pwdsssss";
          UsernamePasswordCredential credential = new UsernamePasswordCredential(username, password);
          DefaultUserPrincipal principal = new DefaultUserPrincipal();
          principal.setId(username);
          //设置模拟服务。
          AppService appService = Mockito.mock(AppService.class);
          Mockito.when(appService.findKi4soServerApp()).thenReturn(null);
          this.handler.setAppService(appService);
          try {
              this.handler.postAuthentication(credential, principal);
              fail("应该抛出异常");
          } catch (NoKi4soKeyException e) {
  
          }
  
           /**
           * 测试参数正确的情况，但是ki4so 服务器的app对象不为空的情况。
           * 服务对应的key信息不为的正常情况。
           */
          String appId = "1000";
          String app2Id = "1001";
          String keyId = "1000000";
          String encStringValue = "ssssdafdsafdsafdsafdasfdsafdsa";
          String service = "http://loacahost:8080/ki4so-app/home.do";
          Map<String, Object> parameters = new HashMap<String, Object>();
          parameters.put(WebConstants.SERVICE_PARAM_NAME, service);
          credential.setParameters(parameters);
          App app = new App();
          app.setAppId(appId);
          
          App clientApp = new App();
          clientApp.setAppId(app2Id);
          
          Ki4soKey key = new Ki4soKey();
          key.setKeyId(keyId);
          
          Mockito.when(appService.findKi4soServerApp()).thenReturn(app);
          Mockito.when(appService.findAppByHost(service)).thenReturn(clientApp);
           
          KeyService keyService = Mockito.mock(KeyService.class);
          Mockito.when(keyService.findKeyByAppId(appId)).thenReturn(key);
          Mockito.when(keyService.findKeyByAppId(app2Id)).thenReturn(key);
          
          this.handler.setKeyService(keyService);
          EncryCredentialManager encryCredentialManager = Mockito.mock(EncryCredentialManager.class);
          Mockito.when(encryCredentialManager.encrypt(Mockito.any(EncryCredentialInfo.class))).thenReturn(encStringValue);
          this.handler.setEncryCredentialManager(encryCredentialManager);
          
          UserLoggedStatusStore userLoggedStatusStore = Mockito.mock(UserLoggedStatusStore.class);
          this.handler.setUserLoggedStatusStore(userLoggedStatusStore);
          
          authentication = this.handler.postAuthentication(credential, principal);
          assertNotNull(authentication);
      }
test_case.class_method_signature: DefaultAuthenticationPostHandlerTest.testPostAuthentication()
test_case.full_signature: @Test public void testPostAuthentication()
test_case.identifier: testPostAuthentication
test_case.invocations: postAuthentication assertNotNull assertNull getPrincipal setId mock thenReturn when findKi4soServerApp setAppService postAuthentication fail put setParameters setAppId setAppId setKeyId thenReturn when findKi4soServerApp thenReturn when findAppByHost mock thenReturn when findKeyByAppId thenReturn when findKeyByAppId setKeyService mock thenReturn when encrypt any setEncryCredentialManager mock setUserLoggedStatusStore postAuthentication assertNotNull
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPostAuthentication()
focal_class.declarator: logger = Logger.getLogger(DefaultAuthenticationPostHandler.class.getName())
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = Logger.getLogger(DefaultAuthenticationPostHandler.class.getName());
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: DURATION = 3L*30*24*60*60*1000
focal_class.modifier: private static final
focal_class.original_string: private static final long DURATION = 3L*30*24*60*60*1000;
focal_class.type: long
focal_class.var_name: DURATION
focal_class.declarator: encryCredentialManager
focal_class.modifier: private
focal_class.original_string: private EncryCredentialManager encryCredentialManager;
focal_class.type: EncryCredentialManager
focal_class.var_name: encryCredentialManager
focal_class.declarator: keyService
focal_class.modifier: private
focal_class.original_string: private KeyService keyService;
focal_class.type: KeyService
focal_class.var_name: keyService
focal_class.declarator: appService
focal_class.modifier: private
focal_class.original_string: private AppService appService;
focal_class.type: AppService
focal_class.var_name: appService
focal_class.declarator: userLoggedStatusStore
focal_class.modifier: private
focal_class.original_string: private UserLoggedStatusStore userLoggedStatusStore;
focal_class.type: UserLoggedStatusStore
focal_class.var_name: userLoggedStatusStore
focal_class.file: ki4so-core/src/main/java/com/github/ebnew/ki4so/core/authentication/DefaultAuthenticationPostHandler.java
focal_class.identifier: DefaultAuthenticationPostHandler
focal_class.interfaces: implements
  		AuthenticationPostHandler
focal_class.class_method_signature: DefaultAuthenticationPostHandler.setUserLoggedStatusStore(UserLoggedStatusStore userLoggedStatusStore)
focal_class.full_signature: public void setUserLoggedStatusStore(UserLoggedStatusStore userLoggedStatusStore)
focal_class.identifier: setUserLoggedStatusStore
focal_class.modifiers: public
focal_class.parameters: (UserLoggedStatusStore userLoggedStatusStore)
focal_class.return: void
focal_class.signature: void setUserLoggedStatusStore(UserLoggedStatusStore userLoggedStatusStore)
focal_class.class_method_signature: DefaultAuthenticationPostHandler.getAppService()
focal_class.full_signature: public AppService getAppService()
focal_class.identifier: getAppService
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: AppService
focal_class.signature: AppService getAppService()
focal_class.class_method_signature: DefaultAuthenticationPostHandler.setAppService(AppService appService)
focal_class.full_signature: public void setAppService(AppService appService)
focal_class.identifier: setAppService
focal_class.modifiers: public
focal_class.parameters: (AppService appService)
focal_class.return: void
focal_class.signature: void setAppService(AppService appService)
focal_class.class_method_signature: DefaultAuthenticationPostHandler.getKeyService()
focal_class.full_signature: public KeyService getKeyService()
focal_class.identifier: getKeyService
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: KeyService
focal_class.signature: KeyService getKeyService()
focal_class.class_method_signature: DefaultAuthenticationPostHandler.setKeyService(KeyService keyService)
focal_class.full_signature: public void setKeyService(KeyService keyService)
focal_class.identifier: setKeyService
focal_class.modifiers: public
focal_class.parameters: (KeyService keyService)
focal_class.return: void
focal_class.signature: void setKeyService(KeyService keyService)
focal_class.class_method_signature: DefaultAuthenticationPostHandler.getEncryCredentialManager()
focal_class.full_signature: public EncryCredentialManager getEncryCredentialManager()
focal_class.identifier: getEncryCredentialManager
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: EncryCredentialManager
focal_class.signature: EncryCredentialManager getEncryCredentialManager()
focal_class.class_method_signature: DefaultAuthenticationPostHandler.setEncryCredentialManager(
  			EncryCredentialManager encryCredentialManager)
focal_class.full_signature: public void setEncryCredentialManager(
  			EncryCredentialManager encryCredentialManager)
focal_class.identifier: setEncryCredentialManager
focal_class.modifiers: public
focal_class.parameters: (
  			EncryCredentialManager encryCredentialManager)
focal_class.return: void
focal_class.signature: void setEncryCredentialManager(
  			EncryCredentialManager encryCredentialManager)
focal_class.class_method_signature: DefaultAuthenticationPostHandler.postAuthentication(Credential credential, Principal principal)
focal_class.full_signature: @Override public Authentication postAuthentication(Credential credential, Principal principal)
focal_class.identifier: postAuthentication
focal_class.modifiers: @Override public
focal_class.parameters: (Credential credential, Principal principal)
focal_class.return: Authentication
focal_class.signature: Authentication postAuthentication(Credential credential, Principal principal)
focal_class.class_method_signature: DefaultAuthenticationPostHandler.encryCredentialWithKi4soKey(AuthenticationImpl authentication, Credential credential, Principal principal)
focal_class.full_signature: private void encryCredentialWithKi4soKey(AuthenticationImpl authentication, Credential credential, Principal principal)
focal_class.identifier: encryCredentialWithKi4soKey
focal_class.modifiers: private
focal_class.parameters: (AuthenticationImpl authentication, Credential credential, Principal principal)
focal_class.return: void
focal_class.signature: void encryCredentialWithKi4soKey(AuthenticationImpl authentication, Credential credential, Principal principal)
focal_class.class_method_signature: DefaultAuthenticationPostHandler.encryCredentialWithAppKey(AuthenticationImpl authentication, Credential credential, Principal principal)
focal_class.full_signature: private void encryCredentialWithAppKey(AuthenticationImpl authentication, Credential credential, Principal principal)
focal_class.identifier: encryCredentialWithAppKey
focal_class.modifiers: private
focal_class.parameters: (AuthenticationImpl authentication, Credential credential, Principal principal)
focal_class.return: void
focal_class.signature: void encryCredentialWithAppKey(AuthenticationImpl authentication, Credential credential, Principal principal)
focal_class.class_method_signature: DefaultAuthenticationPostHandler.buildEncryCredentialInfo(String appId, AuthenticationImpl authentication, Principal principal)
focal_class.full_signature: private EncryCredentialInfo buildEncryCredentialInfo(String appId, AuthenticationImpl authentication, Principal principal)
focal_class.identifier: buildEncryCredentialInfo
focal_class.modifiers: private
focal_class.parameters: (String appId, AuthenticationImpl authentication, Principal principal)
focal_class.return: EncryCredentialInfo
focal_class.signature: EncryCredentialInfo buildEncryCredentialInfo(String appId, AuthenticationImpl authentication, Principal principal)
focal_method.body: @Override
  	public Authentication postAuthentication(Credential credential, Principal principal){
  		Date createTime = new Date();
  		//若认证通过，则返回认证结果对象。
  		AuthenticationImpl authentication = new AuthenticationImpl();
  		authentication.setAuthenticatedDate(createTime);
  		authentication.setPrincipal(principal);
  		encryCredentialWithKi4soKey(authentication, credential, principal);
  		encryCredentialWithAppKey(authentication, credential, principal);
  		return authentication;
  	}
focal_method.class_method_signature: DefaultAuthenticationPostHandler.postAuthentication(Credential credential, Principal principal)
focal_method.full_signature: @Override public Authentication postAuthentication(Credential credential, Principal principal)
focal_method.identifier: postAuthentication
focal_method.invocations: setAuthenticatedDate setPrincipal encryCredentialWithKi4soKey encryCredentialWithAppKey
focal_method.modifiers: @Override public
focal_method.parameters: (Credential credential, Principal principal)
focal_method.return: Authentication
focal_method.signature: Authentication postAuthentication(Credential credential, Principal principal)