User: starksm
Date: 01/06/21 21:10:22
Modified: src/main/org/jboss/ejb Tag: Branch_2_4
EnterpriseContext.java
Log:
Update getCallerPrincipal() to check for a getUnauthenticatedPrincipal()
value in the absence of a caller principal and a security domain
Revision Changes Path
No revision
No revision
1.31.2.1 +35 -16 jboss/src/main/org/jboss/ejb/EnterpriseContext.java
Index: EnterpriseContext.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/EnterpriseContext.java,v
retrieving revision 1.31
retrieving revision 1.31.2.1
diff -u -r1.31 -r1.31.2.1
--- EnterpriseContext.java 2001/06/12 20:09:01 1.31
+++ EnterpriseContext.java 2001/06/22 04:10:22 1.31.2.1
@@ -29,7 +29,9 @@
import javax.transaction.HeuristicRollbackException;
import org.jboss.logging.Logger;
+import org.jboss.metadata.ApplicationMetaData;
import org.jboss.metadata.SecurityRoleRefMetaData;
+import org.jboss.security.RealmMapping;
import org.jboss.security.SimplePrincipal;
/**
@@ -42,7 +44,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
- * @version $Revision: 1.31 $
+ * @version $Revision: 1.31.2.1 $
*/
public abstract class EnterpriseContext
{
@@ -62,10 +64,10 @@
Transaction transaction;
// The principal associated with the call
- Principal principal;
+ private Principal principal;
// The principal for the bean associated with the call
- Principal beanPrincipal;
+ private Principal beanPrincipal;
// Only StatelessSession beans have no Id, stateful and entity do
Object id;
@@ -188,21 +190,38 @@
throw new EJBException("Deprecated");
}
- public Principal getCallerPrincipal()
- {
- if (beanPrincipal == null && principal != null)
+ /** Get the Principal for the current caller. This method
+ cannot return null according to the ejb-spec.
+ */
+ public Principal getCallerPrincipal()
+ {
+ if( beanPrincipal == null )
+ {
+ RealmMapping rm = con.getRealmMapping();
+ if( principal != null )
{
- if( con.getRealmMapping() == null ) {
- beanPrincipal = principal;
- } else {
- beanPrincipal = con.getRealmMapping().getPrincipal(principal);
- }
+ if( rm != null )
+ beanPrincipal = rm.getPrincipal(principal);
+ else
+ beanPrincipal = principal;
}
- else if( beanPrincipal == null && con.getRealmMapping() == null )
- throw new IllegalStateException("No security context set");
- return beanPrincipal;
- }
-
+ else if( rm != null )
+ { // Let the RealmMapping map the null principal
+ beanPrincipal = rm.getPrincipal(principal);
+ }
+ else
+ { // Check for a unauthenticated principal value
+ ApplicationMetaData appMetaData =
con.getBeanMetaData().getApplicationMetaData();
+ String name = appMetaData.getUnauthenticatedPrincipal();
+ if( name != null )
+ beanPrincipal = new SimplePrincipal(name);
+ }
+ }
+ if( beanPrincipal == null )
+ throw new IllegalStateException("No security context set");
+ return beanPrincipal;
+ }
+
public EJBHome getEJBHome()
{
if (con instanceof EntityContainer)
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development