Search in sources :

Example 11 with EarMetaData

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;
}
Also used : JBossAppMetaData(org.jboss.metadata.ear.jboss.JBossAppMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) EarMetaData(org.jboss.metadata.ear.spec.EarMetaData)

Example 12 with EarMetaData

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);
}
Also used : SecurityRoleMetaData(org.jboss.metadata.javaee.spec.SecurityRoleMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) SecurityRolesMetaData(org.jboss.metadata.javaee.spec.SecurityRolesMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) EarMetaData(org.jboss.metadata.ear.spec.EarMetaData)

Aggregations

DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)12 EarMetaData (org.jboss.metadata.ear.spec.EarMetaData)12 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)6 JBossAppMetaData (org.jboss.metadata.ear.jboss.JBossAppMetaData)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 ModuleMetaData (org.jboss.metadata.ear.spec.ModuleMetaData)3 SecurityRolesMetaData (org.jboss.metadata.javaee.spec.SecurityRolesMetaData)3 VirtualFile (org.jboss.vfs.VirtualFile)3 DeploymentDescriptorEnvironment (org.jboss.as.ee.component.DeploymentDescriptorEnvironment)2 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)2 WarMetaData (org.jboss.as.web.common.WarMetaData)2 JBossWebMetaData (org.jboss.metadata.web.jboss.JBossWebMetaData)2 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 ExecutorService (java.util.concurrent.ExecutorService)1 Manifest (java.util.jar.Manifest)1