@SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(RunAsSecurityInterceptorFactory.class);
protected RunAsIdentity getRunAsIdentity(EJBContainer container)
{
RunAs runAs = (RunAs) container.getAnnotation(RunAs.class);
if (runAs == null)
return null;
String runAsPrincipal = runAs.value();
Set<String> extraRoles = new HashSet<String>();
JBossEnterpriseBeanMetaData jbEnterpriseBeanMetaData = container.getXml();
if(jbEnterpriseBeanMetaData != null)
{
SecurityIdentityMetaData securityIdentity = jbEnterpriseBeanMetaData.getSecurityIdentity();
if(securityIdentity.isUseCallerId())
return null; //Overriden in xml
runAsPrincipal = securityIdentity.getRunAsPrincipal();
Map<String,Set<String>> principalVsRoleMap =
jbEnterpriseBeanMetaData.getSecurityRolesPrincipalVersusRolesMap();
extraRoles = principalVsRoleMap.get(runAsPrincipal);
}
JBossAssemblyDescriptorMetaData ad = container.getAssemblyDescriptor();
if(ad != null && runAsPrincipal != null)
{
extraRoles.addAll(ad.getSecurityRoleNamesByPrincipal(runAsPrincipal));
}
return new RunAsIdentity(runAs.value(), runAsPrincipal, extraRoles);
}