コード例 #1
0
  private void testTimeout() {
    String[] roles = {"*"};
    securityProvider.setSessionTimeout(500L);
    String token;
    try {
      token = securityProvider.autheticate("admin", "NCB", roles);
    } catch (UserNotAutenticatedException e) {
      fail();
      return;
    }

    try {
      Thread.sleep(800);
    } catch (InterruptedException e) {
      fail();
      return;
    }

    try {
      securityProvider.checkSecurityToken("admin", token, "*");
    } catch (SessionTimedOutException e) {
      return;
    } catch (UserNotAutenticatedException e) {
      fail();
    }
    fail();
  }
コード例 #2
0
 private void testBadToken() {
   try {
     securityProvider.checkSecurityToken("admin", "badt token", "*");
   } catch (Exception e) {
     return; // passed;
   }
   fail();
 }
コード例 #3
0
 private void testGoodLogin() {
   String[] roles = {"*"};
   try {
     securityProvider.autheticate("admin", "NCB", roles);
   } catch (UserNotAutenticatedException e) {
     fail();
   }
 }
コード例 #4
0
  private void testBaddUserName() {
    String[] roles = {"*"};
    try {
      securityProvider.autheticate("admn", "NCB", roles);
    } catch (UserNotAutenticatedException e) {
      return; // passed
    }

    fail();
  }
コード例 #5
0
  private void testBadUser() {
    String[] roles = {"*"};
    String token;
    try {
      token = securityProvider.autheticate("admin", "NCB", roles);
    } catch (UserNotAutenticatedException e) {
      fail();
      return;
    }

    try {
      securityProvider.checkSecurityToken("admn", token, "*");
    } catch (UserNotAutenticatedException e) {
      return; // test passed
    } catch (SessionTimedOutException e) {
      fail();
    }

    fail();
  }