01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: EZBSecurityContext.java 1970 2007-10-16 11:49:25Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.security.api;
25:
26: import java.security.Principal;
27:
28: import javax.security.auth.Subject;
29:
30: /**
31: * Interface used to describe operations on a security context.
32: * @author Florent Benoit
33: */
34: public interface EZBSecurityContext {
35:
36: /**
37: * Gets the caller's principal.
38: * @param runAsBean if true, the bean is a run-as bean.
39: * @return principal of the caller.
40: */
41: Principal getCallerPrincipal(final boolean runAsBean);
42:
43: /**
44: * Enters in run-as mode with the given subject.<br>
45: * The previous subject is stored and will be restored when run-as mode will
46: * be ended.
47: * @param runAsSubject the subject to used in run-as mode.
48: * @return the previous subject.
49: */
50: Subject enterRunAs(final Subject runAsSubject);
51:
52: /**
53: * Ends the run-as mode and then restore the context stored by container.
54: * @param oldSubject subject kept by container and restored.
55: */
56: void endsRunAs(final Subject oldSubject);
57:
58: /**
59: * Gets the caller's roles.
60: * @param runAsBean if true, the bean is a run-as bean.
61: * @return array of roles of the caller.
62: */
63: Principal[] getCallerRoles(final boolean runAsBean);
64:
65: }
|