SubjectInfo si = sc.getSubjectInfo();
if(si != null)
{
Subject activeSubject = si.getAuthenticatedSubject();
RunAsIdentity callerRunAsIdentity = (RunAsIdentity)sc.getIncomingRunAs();
if( activeSubject != null )
{
Set<Principal> 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<Principal> principalsSet = callerRunAsIdentity.getPrincipalsSet();
theSubject = new Subject(true, principalsSet, EMPTY_SET, EMPTY_SET);
}
}
}
}