T t = null;
final String securityDomain = serviceSecurity.getSecurityDomain();
final Subject subject = securityContext.getSubject(securityDomain);
final Principal principal = securityContext.getCallerPrincipal(securityDomain);
final Group rolesGroup = getRolesGroup(subject);
RolePrincipal runAsPrincipal = null;
boolean runAsAdded = false;
final String runAs = serviceSecurity.getRunAs();
if (runAs != null) {
runAsPrincipal = new RolePrincipal(runAs);
if (!rolesGroup.isMember(runAsPrincipal)) {
rolesGroup.addMember(runAsPrincipal);
runAsAdded = true;
}
}