[jboss-cvs] jboss-seam/src/main/org/jboss/seam/security ...
Gavin King
gavin.king at jboss.com
Thu Feb 1 14:21:38 EST 2007
User: gavin
Date: 07/02/01 14:21:38
Modified: src/main/org/jboss/seam/security Identity.java
Log:
fix npe
Revision Changes Path
1.43 +22 -9 jboss-seam/src/main/org/jboss/seam/security/Identity.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Identity.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/security/Identity.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- Identity.java 1 Feb 2007 12:33:05 -0000 1.42
+++ Identity.java 1 Feb 2007 19:21:38 -0000 1.43
@@ -279,9 +279,11 @@
PermissionCheck check = new PermissionCheck(name, action);
- synchronized( getSecurityContext() )
+ WorkingMemory securityContext = getSecurityContext();
+ assertSecurityContextExists();
+ synchronized( securityContext )
{
- handles.add( getSecurityContext().assertObject(check) );
+ handles.add( securityContext.assertObject(check) );
for (int i = 0; i < arg.length; i++)
{
@@ -289,22 +291,22 @@
{
for (Object value : (Collection) arg[i])
{
- if ( getSecurityContext().getFactHandle(value) == null )
+ if ( securityContext.getFactHandle(value) == null )
{
- handles.add( getSecurityContext().assertObject(value) );
+ handles.add( securityContext.assertObject(value) );
}
}
}
else
{
- handles.add( getSecurityContext().assertObject(arg[i]) );
+ handles.add( securityContext.assertObject(arg[i]) );
}
}
- getSecurityContext().fireAllRules();
+ securityContext.fireAllRules();
for (FactHandle handle : handles)
- getSecurityContext().retractObject(handle);
+ securityContext.retractObject(handle);
}
return check.isGranted();
@@ -366,6 +368,9 @@
protected void populateSecurityContext()
{
+ WorkingMemory securityContext = getSecurityContext();
+ assertSecurityContextExists();
+
// Populate the working memory with the user's principals
for ( Principal p : getSubject().getPrincipals() )
{
@@ -375,7 +380,7 @@
while ( e.hasMoreElements() )
{
Principal role = (Principal) e.nextElement();
- getSecurityContext().assertObject( new Role( role.getName() ) );
+ securityContext.assertObject( new Role( role.getName() ) );
}
}
else
@@ -385,9 +390,17 @@
principal = p;
setDirty();
}
- getSecurityContext().assertObject(p);
+ securityContext.assertObject(p);
+ }
+
+ }
}
+ private void assertSecurityContextExists()
+ {
+ if (securityContext==null)
+ {
+ throw new IllegalStateException("no security rule base available - please install a RuleBase with the name 'securityContext'");
}
}
More information about the jboss-cvs-commits
mailing list