SubjectInfo si = sc.getSubjectInfo();
if(si != null)
{
Subject activeSubject = si.getAuthenticatedSubject();
RunAsIdentity callerRunAsIdentity = (RunAsIdentity)sc.getIncomingRunAs();
if( activeSubject != null )
{
Set principalsSet = null;
if( callerRunAsIdentity == null )
{
principalsSet = activeSubject.getPrincipals();
}
else
{
principalsSet = callerRunAsIdentity.getPrincipalsSet();
}
theSubject = new Subject(true, principalsSet,
activeSubject.getPublicCredentials(),
activeSubject.getPrivateCredentials());
}
else
{
if( callerRunAsIdentity != null )
{
Set principalsSet = callerRunAsIdentity.getPrincipalsSet();
theSubject = new Subject(true, principalsSet, EMPTY_SET, EMPTY_SET);
}
}
}
}