use of org.jboss.metadata.ear.spec.EarMetaData in project wildfly by wildfly.
the class SecurityDomainMergingProcessor method getJBossAppSecurityDomain.
/**
* Try to obtain the security domain configured in jboss-app.xml at the ear level if available
*
* @param deploymentUnit
* @return
*/
private String getJBossAppSecurityDomain(final DeploymentUnit deploymentUnit) {
String securityDomain = null;
DeploymentUnit parent = deploymentUnit.getParent();
if (parent != null) {
final EarMetaData jbossAppMetaData = parent.getAttachment(Attachments.EAR_METADATA);
if (jbossAppMetaData instanceof JBossAppMetaData) {
securityDomain = ((JBossAppMetaData) jbossAppMetaData).getSecurityDomain();
}
}
return securityDomain;
}
use of org.jboss.metadata.ear.spec.EarMetaData in project wildfly by wildfly.
the class SecurityRolesMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(DeploymentUnit deploymentUnit, DeploymentReflectionIndex deploymentReflectionIndex, Class<?> componentClass, EJBComponentDescription ejbComponentDescription) throws DeploymentUnitProcessingException {
final SecurityRolesMetaData roleMappings = new SecurityRolesMetaData();
final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (ejbJarMetaData != null) {
final AssemblyDescriptorMetaData assemblyDescriptorMetaData = ejbJarMetaData.getAssemblyDescriptor();
if (assemblyDescriptorMetaData != null) {
// get the mapping between principal to rolename, defined in the assembly descriptor
final List<SecurityRoleMetaData> securityRoleMetaDatas = assemblyDescriptorMetaData.getAny(SecurityRoleMetaData.class);
if (securityRoleMetaDatas != null) {
for (SecurityRoleMetaData securityRoleMetaData : securityRoleMetaDatas) {
roleMappings.add(securityRoleMetaData);
}
}
}
}
//Let us look at the ear metadata also
DeploymentUnit parent = deploymentUnit.getParent();
if (parent != null) {
final EarMetaData earMetaData = parent.getAttachment(Attachments.EAR_METADATA);
if (earMetaData != null) {
SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles();
SecurityRolesMetaDataMerger.merge(roleMappings, roleMappings, earSecurityRolesMetaData);
}
}
// add it to the EJB component description
ejbComponentDescription.setSecurityRoles(roleMappings);
}
Aggregations