[jboss-cvs] jboss-docs/jbossas/j2ee/examples/src/main/org/jboss/book/security/ex3a ...
Norman Richards
norman.richards at jboss.com
Wed Nov 1 13:14:21 EST 2006
User: nrichards
Date: 06/11/01 13:14:21
Added: jbossas/j2ee/examples/src/main/org/jboss/book/security/ex3a
Echo.java EchoBean.java EchoHome.java ExClient.java
ejb-jar.xml jboss-service.xml jboss.xml
roles.properties users.properties
Log:
modified for j2ee guide
Revision Changes Path
1.1 date: 2006/11/01 18:14:21; author: nrichards; state: Exp;jboss-docs/jbossas/j2ee/examples/src/main/org/jboss/book/security/ex3a/Echo.java
Index: Echo.java
===================================================================
package org.jboss.book.security.ex3a;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
/**
*
* @author Scott.Stark at jboss.org
* @version $Revision: 1.1 $
*/
public interface Echo extends EJBObject
{
public String echo(String arg) throws RemoteException;
}
1.1 date: 2006/11/01 18:14:21; author: nrichards; state: Exp;jboss-docs/jbossas/j2ee/examples/src/main/org/jboss/book/security/ex3a/EchoBean.java
Index: EchoBean.java
===================================================================
package org.jboss.book.security.ex3a;
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import org.apache.log4j.Category;
public class EchoBean implements SessionBean
{
private static final Category log = Category.getInstance(EchoBean.class);
private SessionContext sessionCtx;
public void ejbCreate()
{
log.debug("ejbCreate: ");
}
public void ejbLoad()
{
log.debug("ejbLoad");
}
public void ejbRemove()
{
log.debug("ejbRemove");
}
public void ejbStore()
{
log.debug("ejbStore");
}
public void setSessionContext(SessionContext context)
{
sessionCtx = context;
log.debug("setSessionContext");
}
public void unsetSessionContext()
{
sessionCtx = null;
log.debug("unsetSessionContext");
}
public void ejbActivate()
{
log.debug("ejbActivate");
}
public void ejbPassivate()
{
log.debug("ejbPassivate");
}
public String echo(String arg)
{
log.debug("echo, arg="+arg);
return arg;
}
}
1.1 date: 2006/11/01 18:14:21; author: nrichards; state: Exp;jboss-docs/jbossas/j2ee/examples/src/main/org/jboss/book/security/ex3a/EchoHome.java
Index: EchoHome.java
===================================================================
package org.jboss.book.security.ex3a;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
/**
*
* @author Scott.Stark at jboss.org
* @version $Revision: 1.1 $
*/
public interface EchoHome extends EJBHome
{
public Echo create()
throws RemoteException, CreateException;
}
1.1 date: 2006/11/01 18:14:21; author: nrichards; state: Exp;jboss-docs/jbossas/j2ee/examples/src/main/org/jboss/book/security/ex3a/ExClient.java
Index: ExClient.java
===================================================================
package org.jboss.book.security.ex3a;
import java.rmi.RemoteException;
import javax.naming.InitialContext;
import javax.security.auth.login.LoginException;
import javax.security.auth.login.LoginContext;
import org.apache.log4j.Logger;
import org.apache.log4j.FileAppender;
import org.apache.log4j.PatternLayout;
import org.jboss.logging.XLevel;
import org.jboss.security.auth.callback.UsernamePasswordHandler;
/**
*
* @author Scott.Stark at jboss.org
* @version $Revision: 1.1 $
*/
public class ExClient
{
public static void main(String args[]) throws Exception
{
// Set up a simple configuration that logs on the console.
FileAppender fa = new FileAppender(new PatternLayout("%r[%c{1}], %m%n"), "ex3a-trace.log");
fa.setAppend(false);
Logger cat = Logger.getLogger("org.jboss.security");
cat.setLevel(XLevel.TRACE);
cat.setAdditivity(false);
cat.addAppender(fa);
cat = Logger.getLogger("org.jboss.invocation");
cat.setLevel(XLevel.TRACE);
cat.setAdditivity(false);
cat.addAppender(fa);
// Login using SRP
System.out.println("Logging in using the 'srpHA' configuration");
String username = args[0];
char[] password = args[1].toCharArray();
UsernamePasswordHandler handler = new UsernamePasswordHandler(username, password);
LoginContext lc = new LoginContext("srpHA", handler);
lc.login();
InitialContext iniCtx = new InitialContext();
Object ref = iniCtx.lookup("EchoBean3a");
EchoHome home = (EchoHome) ref;
Echo echo = home.create();
System.out.println("Created Echo");
// Make some calls across the cluster
for(int c = 1; c <= 4; c ++)
{
System.out.println("Echo.echo()#"+c+" = "+echo.echo("This is call "+c));
}
lc.logout();
}
}
1.1 date: 2006/11/01 18:14:21; author: nrichards; state: Exp;jboss-docs/jbossas/j2ee/examples/src/main/org/jboss/book/security/ex3a/ejb-jar.xml
Index: ejb-jar.xml
===================================================================
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>EchoBean3a</ejb-name>
<home>org.jboss.book.security.ex3a.EchoHome</home>
<remote>org.jboss.book.security.ex3a.Echo</remote>
<ejb-class>org.jboss.book.security.ex3a.EchoBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<security-role>
<role-name>Echo</role-name>
</security-role>
<method-permission>
<role-name>Echo</role-name>
<method>
<ejb-name>EchoBean3a</ejb-name>
<method-name>*</method-name>
</method>
</method-permission>
</assembly-descriptor>
</ejb-jar>
1.1 date: 2006/11/01 18:14:21; author: nrichards; state: Exp;jboss-docs/jbossas/j2ee/examples/src/main/org/jboss/book/security/ex3a/jboss-service.xml
Index: jboss-service.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!-- The clustered version of the SRP services
-->
<server>
<!-- The custom JAAS login configuration that installs
a Configuration capable of dynamically updating the
config settings
-->
<mbean code="org.jboss.book.security.service.SecurityConfig"
name="jboss.docs.security:service=LoginConfig-EX3a">
<attribute name="AuthConfig">META-INF/login-config.xml</attribute>
<attribute name="SecurityConfigName">jboss.security:service=XMLLoginConfig</attribute>
</mbean>
<!-- A service that establishes a distributed CachePolicy using the indicated
cluster partition state replication capabilities.
-->
<mbean code="org.jboss.book.security.ex3a.service.DistributedCacheService"
name="jboss.docs.security:service=SRPDistributedCache">
<attribute name="PartitionName">DefaultPartition</attribute>
<attribute name="CacheJndiName">srp-test/SRPDistributedCache</attribute>
<attribute name="CacheTimeout">600</attribute>
<depends>jboss:service=DefaultPartition</depends>
</mbean>
<!-- The SRP service that provides the SRP RMI server and server side
authentication cache -->
<mbean code="org.jboss.security.srp.SRPService"
name="jboss.docs.security:service=SRPServiceHA">
<attribute name="VerifierSourceJndiName">srp-test/security-ex3</attribute>
<attribute name="JndiName">srp-test/SRPServerInterface</attribute>
<attribute name="AuthenticationCacheJndiName">srp-test/SRPDistributedCache</attribute>
<attribute name="ServerPort">0</attribute>
<depends>jboss.docs.security:service=PropertiesVerifierStore</depends>
<depends>jboss.docs.security:service=SRPDistributedCache</depends>
</mbean>
<!-- The SRP store handler service that provides the user password verifier
information -->
<mbean code="org.jboss.book.security.ex3.service.PropertiesVerifierStore"
name="jboss.docs.security:service=PropertiesVerifierStore">
<attribute name="JndiName">srp-test/security-ex3</attribute>
</mbean>
<!-- Expose the SRP service interface via clustered HTTP -->
<mbean code="org.jboss.invocation.http.server.HttpProxyFactoryHA"
name="jboss.docs.security:service=SRP/HA-HTTP">
<!-- The SRP service we are proxying -->
<attribute name="InvokerName">jboss.docs.security:service=SRPServiceHA</attribute>
<!-- Compose the invoker URL from the cluster node address -->
<attribute name="InvokerURLPrefix">http://</attribute>
<attribute name="InvokerURLSuffix">:8080/invoker/SRPInvokerHAServlet</attribute>
<attribute name="UseHostName">false</attribute>
<attribute name="ExportedInterface">org.jboss.security.srp.SRPRemoteServerInterface</attribute>
<!-- The proxy will be available under this JNDI name -->
<attribute name="JndiName">srp-test/SRPServerInterfaceHA</attribute>
<!-- SRP is stateful and so the load balance policy must be sticky -->
<attribute name="LoadBalancePolicy">org.jboss.ha.framework.interfaces.FirstAvailable</attribute>
<attribute name="PartitionName">DefaultPartition</attribute>
</mbean>
</server>
1.1 date: 2006/11/01 18:14:21; author: nrichards; state: Exp;jboss-docs/jbossas/j2ee/examples/src/main/org/jboss/book/security/ex3a/jboss.xml
Index: jboss.xml
===================================================================
<?xml version="1.0"?>
<jboss>
<security-domain>java:/jaas/security-ex3a</security-domain>
<container-configurations>
<!-- A custom container configuration for HA-RMI/HTTP -->
<container-configuration extends="Clustered Stateless SessionBean">
<container-name>HA HTTP Stateless SessionBean</container-name>
<home-invoker>jboss:service=invoker,type=httpHA</home-invoker>
<bean-invoker>jboss:service=invoker,type=httpHA</bean-invoker>
</container-configuration>
</container-configurations>
<enterprise-beans>
<session>
<ejb-name>EchoBean3a</ejb-name>
<configuration-name>HA HTTP Stateless SessionBean</configuration-name>
</session>
</enterprise-beans>
</jboss>
1.1 date: 2006/11/01 18:14:21; author: nrichards; state: Exp;jboss-docs/jbossas/j2ee/examples/src/main/org/jboss/book/security/ex3a/roles.properties
Index: roles.properties
===================================================================
jduke=Echo,TheDuke
1.1 date: 2006/11/01 18:14:21; author: nrichards; state: Exp;jboss-docs/jbossas/j2ee/examples/src/main/org/jboss/book/security/ex3a/users.properties
Index: users.properties
===================================================================
jduke=theduke
More information about the jboss-cvs-commits
mailing list