static Subject createSubject(final SubjectFactory subjectFactory,
                                final String domain,
                                final ManagedConnectionFactory mcf)
   {
      if (System.getSecurityManager() == null)
      {
         Subject subject = subjectFactory.createSubject(domain);
         Set<PasswordCredential> s = getPasswordCredentials(subject);
         if (s != null && !s.isEmpty())
         {
            for (PasswordCredential pc : s)
            {
               pc.setManagedConnectionFactory(mcf);
            }
         }
         return subject;
      }

      return AccessController.doPrivileged(new PrivilegedAction<Subject>() 
      {
         public Subject run()
         {
            Subject subject = subjectFactory.createSubject(domain);
            Set<PasswordCredential> s = getPasswordCredentials(subject);
            if (s != null && !s.isEmpty())
            {
               for (PasswordCredential pc : s)
               {
                  pc.setManagedConnectionFactory(mcf);
               }
            }
            return subject;
         }
      });
   }
static Subject createSubject ( final SubjectFactory subjectFactory , final String domain , final ManagedConnectionFactory mcf ) { if ( System . getSecurityManager ( ) == null ) { Subject subject = subjectFactory . createSubject ( domain ) ; Set < PasswordCredential > s = getPasswordCredentials ( subject ) ; if ( s != null && ! s . isEmpty ( ) ) { for ( PasswordCredential pc : s ) { pc . setManagedConnectionFactory ( mcf ) ; } } return subject ; } return AccessController . doPrivileged ( new PrivilegedAction < Subject > ( ) { public Subject run ( ) { Subject subject = subjectFactory . createSubject ( domain ) ; Set < PasswordCredential > s = getPasswordCredentials ( subject ) ; if ( s != null && ! s . isEmpty ( ) ) { for ( PasswordCredential pc : s ) { pc . setManagedConnectionFactory ( mcf ) ; } } return subject ; } } ) ; }
Get a Subject instance
@param subjectFactory The subject factory
@param domain The domain
@param mcf The ManagedConnectionFactory
@return The instance