[jboss-cvs] JBossAS SVN: r83685 - in projects/ejb3/trunk/docs/tutorial/ssl/src/org/jboss/tutorial/ssl: client and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 30 09:58:07 EST 2009
Author: jaikiran
Date: 2009-01-30 09:58:07 -0500 (Fri, 30 Jan 2009)
New Revision: 83685
Modified:
projects/ejb3/trunk/docs/tutorial/ssl/src/org/jboss/tutorial/ssl/bean/CalculatorBean.java
projects/ejb3/trunk/docs/tutorial/ssl/src/org/jboss/tutorial/ssl/client/Client.java
Log:
Minor changes to include an example for multiple RemoteBinding for the bean
Modified: projects/ejb3/trunk/docs/tutorial/ssl/src/org/jboss/tutorial/ssl/bean/CalculatorBean.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/ssl/src/org/jboss/tutorial/ssl/bean/CalculatorBean.java 2009-01-30 14:37:24 UTC (rev 83684)
+++ projects/ejb3/trunk/docs/tutorial/ssl/src/org/jboss/tutorial/ssl/bean/CalculatorBean.java 2009-01-30 14:58:07 UTC (rev 83685)
@@ -21,18 +21,19 @@
*/
package org.jboss.tutorial.ssl.bean;
-import org.jboss.ejb3.annotation.*;
-
-
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
import javax.ejb.Stateless;
-import javax.ejb.Remote;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
-import javax.annotation.security.PermitAll;
-import javax.annotation.security.RolesAllowed;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.RemoteBindings;
+import org.jboss.ejb3.annotation.SecurityDomain;
+
@Stateless
- at RemoteBinding(clientBindUrl="sslsocket://0.0.0.0:3843")
+ at RemoteBindings(
+{@RemoteBinding(clientBindUrl = "sslsocket://0.0.0.0:3843"), @RemoteBinding(jndiBinding = "CalculatorNormal")})
@SecurityDomain("other")
public class CalculatorBean implements Calculator
{
@@ -43,13 +44,15 @@
return x + y;
}
- @RolesAllowed({"student"})
+ @RolesAllowed(
+ {"student"})
public int subtract(int x, int y)
{
return x - y;
}
- @RolesAllowed({"teacher"})
+ @RolesAllowed(
+ {"teacher"})
public int divide(int x, int y)
{
return x / y;
Modified: projects/ejb3/trunk/docs/tutorial/ssl/src/org/jboss/tutorial/ssl/client/Client.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/ssl/src/org/jboss/tutorial/ssl/client/Client.java 2009-01-30 14:37:24 UTC (rev 83684)
+++ projects/ejb3/trunk/docs/tutorial/ssl/src/org/jboss/tutorial/ssl/client/Client.java 2009-01-30 14:58:07 UTC (rev 83685)
@@ -41,13 +41,14 @@
securityClient.login();
InitialContext ctx = new InitialContext();
- Calculator calculator = (Calculator) ctx.lookup("CalculatorBean/remote");
-
+ // let's use the bean whose proxy communicates via ssl
+ Calculator sslCalculator = (Calculator) ctx.lookup("CalculatorBean/remote");
+ System.out.println("Invoking bean methods on a proxy through sslsocket");
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));
+ System.out.println("1 + 1 = " + sslCalculator.add(1, 1));
throw new RuntimeException("ERROR - User with incorrect password allowed to operate on bean");
}
catch (EJBAccessException ex)
@@ -64,12 +65,12 @@
securityClient.login();
- System.out.println("1 + 1 = " + calculator.add(1, 1));
+ System.out.println("1 + 1 = " + sslCalculator.add(1, 1));
System.out.println("Kabir is not a teacher so he cannot do division");
try
{
- calculator.divide(16, 4);
+ sslCalculator.divide(16, 4);
throw new RuntimeException("ERROR - User with insufficient role was allowed to operate on bean");
}
catch (EJBAccessException ex)
@@ -78,6 +79,13 @@
}
System.out.println("Kabir is a student, and students are allowed to do subtraction");
- System.out.println("1 - 1 = " + calculator.subtract(1, 1));
+ System.out.println("1 - 1 = " + sslCalculator.subtract(1, 1));
+
+ // Now let's use the bean whose proxy communicates via normal socket: protocol
+ Calculator normalCalculator = (Calculator) ctx.lookup("CalculatorNormal");
+ // do some operation
+ System.out.println("Invoking bean methods on a proxy through normal socket");
+ System.out.println("Kabir is a student. So he can do addition");
+ System.out.println("2 + 2 = " + normalCalculator.add(2, 2));
}
}
More information about the jboss-cvs-commits
mailing list