예제 #1
0
  private void initSFSB(String[] args) {

    System.out.println("[apiClient] Inside init....");
    try {
      Context ic = null;
      Object objref = null;
      if ((args[0] == null) || (args[1] == null)) {
        ic = new InitialContext();
        System.out.println("[apiClient] Lookingup Bean apiClient ");
        objref = ic.lookup("java:comp/env/ejb/apiSecurity");
      } else {
        Properties env = new Properties();
        env.put("java.naming.provider.url", args[0]);
        env.put("java.naming.factory.initial", args[1]);
        ic = new InitialContext(env);
        objref = ic.lookup(args[2]);
      }

      RpaHome home = (RpaHome) PortableRemoteObject.narrow(objref, RpaHome.class);

      hr = home.create("LizHurley");

      System.out.println("[passivateactivate] Initalization done");
      // stat.addStatus("init apiClient", stat.PASS);
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("[apiClient] Exception in init....");
      e.printStackTrace();
      // stat.addStatus("client initSFSB", stat.FAIL);
    }
  }
예제 #2
0
  public String doTest() {

    RpaRemote hr = null;
    String res = null;
    Context ic = null;
    LoginContext lc = null;
    RpaHome home = null;
    String testId = "Sec:: LDAP realm";
    try {
      stat.addDescription("Security:: LDAP realm");
      ic = new InitialContext();
      // create EJB using factory from container
      java.lang.Object objref = ic.lookup("rpaLoginBean");

      System.err.println("Looked up home!!");

      home = (RpaHome) PortableRemoteObject.narrow(objref, RpaHome.class);
      System.err.println("Narrowed home!!");

      hr = home.create("LizHurley");
      System.out.println("Got the EJB!!");

      // invoke 3 overloaded methods on the EJB
      System.out.println("Calling authorized method - addItem");
      hr.addItem("lipstick", 30);
      hr.addItem("mascara", 40);
      hr.addItem("lipstick2", 50);
      hr.addItem("sandals", 200);
      System.out.println(hr.getTotalCost());
      hr.deleteItem("lipstick2");
      java.lang.String[] shoppingList = hr.getItems();
      System.out.println("Shopping list for LizHurley");
      for (int i = 0; i < shoppingList.length; i++) {
        System.out.println(shoppingList[i]);
      }
      System.out.println("Total Cost for Ms Hurley = " + hr.getTotalCost());
      stat.addStatus(testId, stat.PASS);
      System.out.println("LDAP Realm:RpaLoginBean Test Passed");
    } catch (Exception re) {
      re.printStackTrace();
      stat.addStatus(testId, stat.FAIL);
      System.out.println("LDAP Realm:RpaLoginBean Test Failed");
      System.exit(-1);
    } finally {
      stat.printSummary();
    }
    return res;
  }