final String authMethod = getAuthMethod(dep);
final boolean hasAuthMethod = authMethod != null;
if (hasAuthMethod) {
final SecurityMetaDataAccessorEJB ejbMDAccessor = getEjbSecurityMetaDataAccessor(dep);
final SecurityRolesMetaData securityRolesMD = ejbMDAccessor.getSecurityRoles(dep);
final boolean hasSecurityRolesMD = securityRolesMD != null;
if (hasSecurityRolesMD) {
ROOT_LOGGER.creatingSecurityRoles();
jbossWebMD.setSecurityRoles(securityRolesMD);
}
}
//merge security roles from the ear
//TODO: is there somewhere better to put this?
final DeploymentUnit unit = dep.getAttachment(DeploymentUnit.class);
DeploymentUnit parent = unit.getParent();
if (parent != null) {
final EarMetaData earMetaData = parent.getAttachment(org.jboss.as.ee.structure.Attachments.EAR_METADATA);
if (earMetaData != null) {
if (jbossWebMD.getSecurityRoles() == null) {
jbossWebMD.setSecurityRoles(new SecurityRolesMetaData());
}
SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles();
if (earSecurityRolesMetaData != null) {
SecurityRolesMetaDataMerger.merge(jbossWebMD.getSecurityRoles(), jbossWebMD.getSecurityRoles(), earSecurityRolesMetaData);
}
}
}