01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * 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.jbas1852;
23:
24: import java.security.Principal;
25: import javax.ejb.CreateException;
26: import javax.ejb.SessionBean;
27: import javax.ejb.SessionContext;
28:
29: /** An implmentation of the Session interface that should not
30: be accessible by external users.
31:
32: @author Scott.Stark@jboss.org
33: @version $Revision: 57211 $
34: */
35: public class PrivateSessionBean implements SessionBean {
36: private SessionContext sessionContext;
37:
38: public void ejbCreate() throws CreateException {
39: System.out.println("PrivateSessionBean.ejbCreate() called");
40: }
41:
42: public void ejbActivate() {
43: System.out.println("PrivateSessionBean.ejbActivate() called");
44: }
45:
46: public void ejbPassivate() {
47: System.out.println("PrivateSessionBean.ejbPassivate() called");
48: }
49:
50: public void ejbRemove() {
51: System.out.println("PrivateSessionBean.ejbRemove() called");
52: }
53:
54: public void setSessionContext(SessionContext context) {
55: sessionContext = context;
56: }
57:
58: public String echo(String arg) {
59: System.out.println("PrivateSessionBean.echo, arg=" + arg);
60: Principal p = sessionContext.getCallerPrincipal();
61: System.out.println("PrivateSessionBean.echo, callerPrincipal="
62: + p);
63: System.out
64: .println("PrivateSessionBean.echo, isCallerInRole('InternalUser')="
65: + sessionContext.isCallerInRole("InternalUser"));
66: return arg;
67: }
68:
69: public void noop() {
70: System.out.println("PrivateSessionBean.noop");
71: Principal p = sessionContext.getCallerPrincipal();
72: System.out.println("PrivateSessionBean.noop, callerPrincipal="
73: + p);
74: }
75:
76: public void restricted() {
77: System.out.println("PrivateSessionBean.restricted");
78: Principal p = sessionContext.getCallerPrincipal();
79: System.out
80: .println("PrivateSessionBean.restricted, callerPrincipal="
81: + p);
82: }
83: }
|