Package org.jboss.tutorial.security.bean

Examples of org.jboss.tutorial.security.bean.Calculator


      SecurityClient securityClient = SecurityClientFactory.getSecurityClient();
      securityClient.setSimple("kabir", "invalidpassword");
      securityClient.login();

      InitialContext ctx = new InitialContext();
      Calculator calculator = (Calculator) ctx.lookup("CalculatorBean/remote");

      System.out.println("Kabir is a student.");
      System.out.println("Kabir types in the wrong password");
      try
      {
         System.out.println("1 + 1 = " + calculator.add(1, 1));
      }
      catch (EJBAccessException ex)
      {
         System.out.println("Saw expected SecurityException: " + ex.getMessage());
      }

      System.out.println("Kabir types in correct password.");
      System.out.println("Kabir does unchecked addition.");

      // Re-establish the proxy with the correct security identity
      securityClient.logout();
      securityClient.setSimple("kabir", "validpassword");
      securityClient.login();

      calculator = (Calculator) ctx.lookup("CalculatorBean/remote");

      System.out.println("1 + 1 = " + calculator.add(1, 1));

      System.out.println("Kabir is not a teacher so he cannot do division");
      try
      {
         calculator.divide(16, 4);
      }
      catch (javax.ejb.EJBAccessException ex)
      {
         System.out.println(ex.getMessage());
      }

      System.out.println("Students are allowed to do subtraction");
      System.out.println("1 - 1 = " + calculator.subtract(1, 1));
   }
View Full Code Here

TOP

Related Classes of org.jboss.tutorial.security.bean.Calculator

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.