[seam-commits] Seam SVN: r9542 - trunk/src/main/org/jboss/seam/security.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Nov 10 21:07:22 EST 2008
Author: shane.bryzak at jboss.com
Date: 2008-11-10 21:07:21 -0500 (Mon, 10 Nov 2008)
New Revision: 9542
Modified:
trunk/src/main/org/jboss/seam/security/RunAsOperation.java
Log:
add roles directly to subject
Modified: trunk/src/main/org/jboss/seam/security/RunAsOperation.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/RunAsOperation.java 2008-11-11 00:01:50 UTC (rev 9541)
+++ trunk/src/main/org/jboss/seam/security/RunAsOperation.java 2008-11-11 02:07:21 UTC (rev 9542)
@@ -2,8 +2,6 @@
import java.security.Principal;
import java.security.acl.Group;
-import java.util.HashSet;
-import java.util.Set;
import javax.security.auth.Subject;
@@ -18,15 +16,12 @@
private Principal principal;
private Subject subject;
- private Set<String> roles;
-
private boolean systemOp = false;
-
+
public RunAsOperation()
{
principal = new SimplePrincipal(null);
subject = new Subject();
- roles = new HashSet<String>();
}
/**
@@ -54,7 +49,19 @@
public RunAsOperation addRole(String role)
{
- roles.add(role);
+ for ( Group sg : getSubject().getPrincipals(Group.class) )
+ {
+ if ( Identity.ROLES_GROUP.equals( sg.getName() ) )
+ {
+ sg.addMember(new SimplePrincipal(role));
+ break;
+ }
+ }
+
+ SimpleGroup roleGroup = new SimpleGroup(Identity.ROLES_GROUP);
+ roleGroup.addMember(new SimplePrincipal(role));
+ getSubject().getPrincipals().add(roleGroup);
+
return this;
}
@@ -65,22 +72,6 @@
public void run()
{
- for (String role : roles)
- {
- for ( Group sg : getSubject().getPrincipals(Group.class) )
- {
- if ( Identity.ROLES_GROUP.equals( sg.getName() ) )
- {
- sg.addMember(new SimplePrincipal(role));
- break;
- }
- }
-
- SimpleGroup roleGroup = new SimpleGroup(Identity.ROLES_GROUP);
- roleGroup.addMember(new SimplePrincipal(role));
- getSubject().getPrincipals().add(roleGroup);
- }
-
Identity.instance().runAs(this);
}
}
More information about the seam-commits
mailing list