Package com.github.ebnew.ki4so.core.app

Examples of com.github.ebnew.ki4so.core.app.App


    Assert.assertNull(appServiceImpl.findAppById(""));
    Assert.assertNull(appServiceImpl.findAppById(null));
   
    Assert.assertNull(appServiceImpl.findAppById("not exsited"));
   
    App app = appServiceImpl.findAppById("1001");
    Assert.assertNotNull(app);
    Assert.assertEquals("http://localhost:8080/ki4so-app/", app.getHost());
    System.out.println(app);
  }
View Full Code Here


    System.out.println(app);
  }

  @Test
  public void testFindKi4soServerApp() {
    App app = appServiceImpl.findKi4soServerApp();
    Assert.assertNotNull(app);
    System.out.println(app);
  }
View Full Code Here

    Assert.assertNull(appServiceImpl.findAppByHost(null));
   
    Assert.assertNull(appServiceImpl.findAppByHost("ddddddddddd"));
   
    //查询带斜线和不带斜线的情况。
    App app = appServiceImpl.findAppByHost("http://localhost:8080/ki4so-app/");
    Assert.assertNotNull(app);
    Assert.assertEquals("1001", app.getAppId());
   
    app = appServiceImpl.findAppByHost("http://localhost:8080/ki4so-app");
    Assert.assertNotNull(app);
    Assert.assertEquals("1001", app.getAppId());
   
    app = appServiceImpl.findAppByHost("http://localhost:8080/ki4so-app/dafdasfdas");
    Assert.assertNotNull(app);
    Assert.assertEquals("1001", app.getAppId());
   
    app = appServiceImpl.findAppByHost("http://localhost:8080/ki4so-app/hell/w3d.htm?a=b");
    Assert.assertNotNull(app);
    Assert.assertEquals("1001", app.getAppId());
  }
View Full Code Here

        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);
View Full Code Here

    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();
    Mockito.when(appService.findAppById(Mockito.anyString())).thenReturn(app);
    Assert.assertEquals(1, this.ki4soService.getAppList(credential).size());
  }
View Full Code Here

    Credential credential = Mockito.mock(Credential.class);
   
    //设置预期结果。
    Mockito.when(credentialResolver.resolveCredential(request)).thenReturn(credential);
    List<App> list = new ArrayList<App>();
    App app = new App();
    app.setAppId("1000");
    app.setAppName("测试应用程序1");
    app.setHost("app.com");
    app.setLogoutUrl("http://app.com/logout.do");
    list.add(app);
    Mockito.when(ki4soService.getAppList(credential)).thenReturn(list);
   
    //执行查询。
    logoutAction.getAppList(request, response);
View Full Code Here

      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){
              apps.add(app);
            }
          }
        }
View Full Code Here

   */
  private void encryCredentialWithKi4soKey(AuthenticationImpl authentication, Credential credential, Principal principal){
    //如果是原始凭据,则需要进行加密处理。
    if(credential!=null && credential.isOriginal()){
      //查找ki4so服务对应的应用信息。
      App ki4soApp = appService.findKi4soServerApp();
      if(ki4soApp==null){
        logger.log(Level.SEVERE, "no ki4so key info.");
        throw NoKi4soKeyException.INSTANCE;
      }
      String encryCredential = encryCredentialManager.encrypt(buildEncryCredentialInfo(ki4soApp.getAppId(), authentication, principal));
      //加密后的凭据信息写入到动态属性中。
      Map<String, Object> attributes = authentication.getAttributes();
      if(attributes==null){
        attributes = new HashMap<String, Object>();
      }
View Full Code Here

    if(authentication!=null && abstractParameter!=null && abstractParameter.getParameterValue(WebConstants.SERVICE_PARAM_NAME)!=null){
      String service = abstractParameter.getParameterValue(WebConstants.SERVICE_PARAM_NAME).toString().trim().toLowerCase();
      //service不为空,且符合Http协议URL格式,则继续加密。
      if(service.length()>0){
        //查找ki4so服务对应的应用信息。
        App clientApp = appService.findAppByHost(service);
        if(clientApp!=null){
          String encryCredential = encryCredentialManager.encrypt(buildEncryCredentialInfo(clientApp.getAppId(), authentication, principal));
          //加密后的凭据信息写入到动态属性中。
          Map<String, Object> attributes = authentication.getAttributes();
          if(attributes==null){
            attributes = new HashMap<String, Object>();
          }
          attributes.put(KI4SO_CLIENT_EC_KEY, encryCredential);
          attributes.put(WebConstants.SERVICE_PARAM_NAME, service);
          authentication.setAttributes(attributes);
         
          //更新用户登录状态到存储器中。
          UserLoggedStatus status = new UserLoggedStatus(principal.getId(), clientApp.getAppId(), authentication.getAuthenticatedDate());
          userLoggedStatusStore.addUserLoggedStatus(status);
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.github.ebnew.ki4so.core.app.App

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.