Subject theSubject = null;
Subject activeSubject = SecurityAssociation.getSubject();
if( activeSubject != null )
{
Set principalsSet = null;
RunAsIdentity callerRunAsIdentity = (RunAsIdentity)
SecurityAssociation.peekRunAsIdentity(1);
if( callerRunAsIdentity == null )
{
principalsSet = activeSubject.getPrincipals();
}
else
{
principalsSet = callerRunAsIdentity.getPrincipalsSet();
}
theSubject = new Subject(true, principalsSet,
activeSubject.getPublicCredentials(),
activeSubject.getPrivateCredentials());
}
else
{
RunAsIdentity callerRunAsIdentity = (RunAsIdentity)
SecurityAssociation.peekRunAsIdentity(1);
if( callerRunAsIdentity != null )
{
Set principalsSet = callerRunAsIdentity.getPrincipalsSet();
theSubject = new Subject(true, principalsSet, EMPTY_SET, EMPTY_SET);
}
}
return theSubject;
}