KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > security > ejb > StatelessSessionBean4


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.security.ejb;
23
24 import java.rmi.RemoteException JavaDoc;
25 import java.security.Principal JavaDoc;
26 import javax.ejb.CreateException JavaDoc;
27 import javax.ejb.EJBException JavaDoc;
28 import javax.ejb.SessionBean JavaDoc;
29 import javax.ejb.SessionContext JavaDoc;
30
31 import org.jboss.logging.Logger;
32
33 /** A simple session bean for testing declarative security and
34 the use of getCallerPrincipal in ejbCreate
35
36 @author Scott.Stark@jboss.org
37 @version $Revision: 58115 $
38 */

39 public class StatelessSessionBean4 implements SessionBean JavaDoc
40 {
41     private static Logger log = Logger.getLogger(StatelessSessionBean4.class);
42
43     private SessionContext JavaDoc sessionContext;
44
45     public void ejbCreate() throws CreateException JavaDoc
46     {
47         log.debug("ejbCreate() called");
48     }
49
50     public void ejbActivate()
51     {
52         log.debug("ejbActivate() called");
53     }
54
55     public void ejbPassivate()
56     {
57         log.debug("ejbPassivate() called");
58     }
59
60     public void ejbRemove()
61     {
62         log.debug("ejbRemove() called");
63     }
64
65     public void setSessionContext(SessionContext JavaDoc context)
66     {
67         sessionContext = context;
68     }
69
70     public String JavaDoc echo(String JavaDoc arg)
71     {
72         log.debug("echo, arg="+arg);
73         Principal JavaDoc p = sessionContext.getCallerPrincipal();
74         log.debug("echo, callerPrincipal="+p);
75         return arg;
76     }
77     public String JavaDoc forward(String JavaDoc echoArg)
78     {
79         log.debug("forward, echoArg="+echoArg);
80         return echo(echoArg);
81     }
82
83     public void noop()
84     {
85         log.debug("noop");
86     }
87     public void npeError()
88     {
89         log.debug("npeError");
90         Object JavaDoc obj = null;
91         obj.toString();
92     }
93
94     public void unchecked()
95     {
96         Principal JavaDoc p = sessionContext.getCallerPrincipal();
97         log.debug("unchecked, callerPrincipal="+p);
98     }
99
100     public void excluded()
101     {
102         Principal JavaDoc p = sessionContext.getCallerPrincipal();
103         log.debug("excluded, callerPrincipal="+p);
104     }
105
106 }
107
108
Popular Tags