FileDocCategorySizeDatePackage
SubjectActions.javaAPI DocJBoss 4.2.15475Fri Jul 13 21:01:18 BST 2007org.jboss.resource.security

SubjectActions

public class SubjectActions extends Object
Common package privileged actions.
author
Scott.Stark@jboss.org
version
$Revision: 57189 $

Fields Summary
Constructors Summary
Methods Summary
static voidaddCredentials(javax.security.auth.Subject subject, javax.resource.spi.security.PasswordCredential cred)

      AddCredentialsAction action = new AddCredentialsAction(subject, cred);
      AccessController.doPrivileged(action);
   
static voidaddPrincipals(javax.security.auth.Subject subject, java.security.Principal p)

      AddPrincipalsAction action = new AddPrincipalsAction(subject, p);
      AccessController.doPrivileged(action);
   
static voidaddRoles(javax.security.auth.Subject subject, java.util.Set runAsRoles)

      if( System.getSecurityManager() != null )
      {
         AddRolesActions.PRIVILEGED.addRoles(subject, runAsRoles);
      }
      else
      {
         AddRolesActions.NON_PRIVILEGED.addRoles(subject, runAsRoles);         
      }
   
private static java.security.acl.GroupaddSubjectRoles(javax.security.auth.Subject theSubject, java.util.Set roles)

      Set subjectGroups = theSubject.getPrincipals(Group.class);
      Iterator iter = subjectGroups.iterator();
      Group roleGrp = null;
      while (iter.hasNext())
      {
         Group grp = (Group) iter.next();
         String name = grp.getName();
         if (name.equals("Roles"))
            roleGrp = grp;
      }

      // Create the Roles group if it was not found
      if (roleGrp == null)
      {
         roleGrp = new SimpleGroup("Roles");
         theSubject.getPrincipals().add(roleGrp);
      }

      iter = roles.iterator();
      while (iter.hasNext())
      {
         Principal role = (Principal) iter.next();
         roleGrp.addMember(role);
      }
      return roleGrp;
   
static voidremoveCredentials(javax.security.auth.Subject subject, javax.resource.spi.ManagedConnectionFactory mcf)

      RemoveCredentialsAction action = new RemoveCredentialsAction(subject, mcf);
      AccessController.doPrivileged(action);