Package com.github.ebnew.ki4so.core.authentication

Examples of com.github.ebnew.ki4so.core.authentication.Authentication


    if(result==null || request==null || response==null){
      return mv;
    }
    if (result.isSuccess()) {
      //登录结果对象。
      Authentication authentication = result.getAuthentication();

      //清除session中的状态信息service值。
      request.getSession().removeAttribute(WebConstants.KI4SO_SERVICE_KEY_IN_SESSION);
     
      // 如果有加密凭据信息,则写入加密凭据值到cookie中。
      if (authentication != null
          && authentication.getAttributes() != null) {
        Map<String, Object> attributes = authentication.getAttributes();
        // ki4so服务端加密的凭据存在,则写入cookie中。
        if (attributes
            .get(AuthenticationPostHandler.KI4SO_SERVER_EC_KEY) != null) {
          response.addCookie(new Cookie(
              WebConstants.KI4SO_SERVER_ENCRYPTED_CREDENTIAL_COOKIE_KEY,
View Full Code Here


    //当调用认证方法则抛出异常信息。模拟测试数据。
    authenticationManager = Mockito.mock(AuthenticationManager.class);
    this.ki4soService.setAuthenticationManager(authenticationManager);
   
   
    Authentication authentication = Mockito.mock(Authentication.class);
    Mockito.when(exception.getCode()).thenReturn(msgKey);
    Mockito.when(exception.getCode()).thenReturn(code);
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    loginResult = ki4soService.login(credential);
    expected = new LoginResult();
View Full Code Here

    this.ki4soService.logout(credential);
   
    /**
     * 测试正常参数情况,但是验证成功。
     */
    Authentication authentication = Mockito.mock(Authentication.class);
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    this.ki4soService.logout(credential);
   
    /**
     * 测试正常参数情况,但是验证成功。
     */
    authentication = Mockito.mock(Authentication.class);
    Mockito.when(authentication.getPrincipal()).thenReturn(Mockito.mock(Principal.class));
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    this.ki4soService.logout(credential);
   
   
    /**
 
View Full Code Here

   
    /**
     * 测试正确参数,但是返回值的属principal为空的情况。
     */
    credential = Mockito.mock(Credential.class);
    Authentication authentication = Mockito.mock(Authentication.class);
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    Assert.assertEquals(0, this.ki4soService.getAppList(credential).size());
   
   
    /**
     * 测试正确参数,但是返回值的属principal不是空的情况。
     */
    credential = Mockito.mock(Credential.class);
    authentication = Mockito.mock(Authentication.class);
    Mockito.when(authenticationManager.authenticate(credential)).thenReturn(authentication);
    Mockito.when(authentication.getPrincipal()).thenReturn(Mockito.mock(Principal.class));
    List<UserLoggedStatus> list = new ArrayList<UserLoggedStatus>();
    UserLoggedStatus loggedStatus = new UserLoggedStatus("test", "1001");
    list.add(loggedStatus);
    Mockito.when(userLoggedStatusStore.findUserLoggedStatus(Mockito.anyString())).thenReturn(list);
    App app = new App();
View Full Code Here

    }
    LoginResult loginResult = new LoginResult();
    loginResult.setSuccess(false);
    //调用认证处理器进行认证。
    try{
      Authentication authentication = authenticationManager.authenticate(credential);
      //登录成功。
      loginResult.setSuccess(true);
      loginResult.setAuthentication(authentication);
    }catch (InvalidCredentialException e) {
      //登录失败。
View Full Code Here

    try{
      if(credential==null){
        return;
      }
      //对凭据做一次认证。
      Authentication authentication = authenticationManager.authenticate(credential);
      //清除用户登录状态。
      if(authentication!=null && authentication.getPrincipal()!=null){
        this.userLoggedStatusStore.clearUpUserLoggedStatus(authentication.getPrincipal().getId());
      }
    }catch (InvalidCredentialException e) {
    }
  }
View Full Code Here

    if(credential==null){
      return apps;
    }
    try{
      //对凭据做一次认证。
      Authentication authentication = authenticationManager.authenticate(credential);
      if(authentication!=null && authentication.getPrincipal()!=null){
        List<UserLoggedStatus> list = this.userLoggedStatusStore.findUserLoggedStatus(authentication.getPrincipal().getId());
        //批量查询对应的应用信息。
        if(list!=null&& list.size()>0){
          for(UserLoggedStatus status:list){
            App app = appService.findAppById(status.getAppId());
            if(app!=null){
View Full Code Here

TOP

Related Classes of com.github.ebnew.ki4so.core.authentication.Authentication

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.