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);
}
use of org.jboss.metadata.ear.spec.EarMetaData in project wildfly by wildfly.
the class UndertowDeploymentProcessor method getJBossAppSecurityDomain.
/**
* Try to obtain the security domain configured in jboss-app.xml at the ear level if available
*/
private String getJBossAppSecurityDomain(final DeploymentUnit deploymentUnit) {
String securityDomain = null;
DeploymentUnit parent = deploymentUnit.getParent();
if (parent != null) {
final EarMetaData jbossAppMetaData = parent.getAttachment(org.jboss.as.ee.structure.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 EarContextRootProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData == null) {
// Nothing we can do without WarMetaData
return;
}
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
if (deploymentRoot == null) {
// We don't have a root to work with
return;
}
final DeploymentUnit parent = deploymentUnit.getParent();
if (parent == null || !DeploymentTypeMarker.isType(DeploymentType.EAR, parent)) {
// Only care if this war is nested in an EAR
return;
}
final EarMetaData earMetaData = parent.getAttachment(Attachments.EAR_METADATA);
if (earMetaData == null) {
// Nothing to see here
return;
}
final ModulesMetaData modulesMetaData = earMetaData.getModules();
if (modulesMetaData != null)
for (ModuleMetaData moduleMetaData : modulesMetaData) {
if (Web.equals(moduleMetaData.getType()) && moduleMetaData.getFileName().equals(deploymentRoot.getRootName())) {
String contextRoot = WebModuleMetaData.class.cast(moduleMetaData.getValue()).getContextRoot();
if (contextRoot == null && (warMetaData.getJBossWebMetaData() == null || warMetaData.getJBossWebMetaData().getContextRoot() == null)) {
contextRoot = "/" + parent.getName().substring(0, parent.getName().length() - 4) + "/" + deploymentUnit.getName().substring(0, deploymentUnit.getName().length() - 4);
}
if (contextRoot != null) {
JBossWebMetaData jBossWebMetaData = warMetaData.getJBossWebMetaData();
if (jBossWebMetaData == null) {
jBossWebMetaData = new JBoss70WebMetaData();
warMetaData.setJBossWebMetaData(jBossWebMetaData);
}
jBossWebMetaData.setContextRoot(contextRoot);
}
return;
}
}
}
use of org.jboss.metadata.ear.spec.EarMetaData in project wildfly by wildfly.
the class AbstractSecurityMetaDataAccessorEJB method getSecurityDomain.
/**
* @see org.jboss.webservices.integration.tomcat.AbstractSecurityMetaDataAccessorEJB#getSecurityDomain(Deployment)
*
* @param dep webservice deployment
* @return security domain associated with EJB 3 deployment
*/
public String getSecurityDomain(final Deployment dep) {
String securityDomain = null;
for (final EJBEndpoint ejbEndpoint : getEjbEndpoints(dep)) {
String nextSecurityDomain = ejbEndpoint.getSecurityDomain();
if (nextSecurityDomain == null || nextSecurityDomain.isEmpty()) {
nextSecurityDomain = null;
}
securityDomain = getDomain(securityDomain, nextSecurityDomain);
}
if (securityDomain == null) {
final DeploymentUnit unit = WSHelper.getRequiredAttachment(dep, DeploymentUnit.class);
if (unit.getParent() != null) {
final EarMetaData jbossAppMD = unit.getParent().getAttachment(Attachments.EAR_METADATA);
return jbossAppMD instanceof JBossAppMetaData ? ((JBossAppMetaData) jbossAppMD).getSecurityDomain() : null;
}
}
return securityDomain;
}
use of org.jboss.metadata.ear.spec.EarMetaData in project wildfly by wildfly.
the class WebMetaDataCreator method createSecurityRoles.
/**
* Creates security roles part of web.xml descriptor.
* <p/>
* <pre>
* <security-role>
* <role-name>role1</role-name>
* ...
* <role-name>roleN</role-name>
* </security-role>
* </pre>
*
* @param dep webservice deployment
* @param jbossWebMD jboss web meta data
*/
private void createSecurityRoles(final Deployment dep, final JBossWebMetaData jbossWebMD) {
final String authMethod = getAuthMethod(dep);
final boolean hasAuthMethod = authMethod != null;
if (hasAuthMethod) {
final SecurityRolesMetaData securityRolesMD = ejb3SecurityAccessor.getSecurityRoles(dep);
final boolean hasSecurityRolesMD = securityRolesMD != null && !securityRolesMD.isEmpty();
if (hasSecurityRolesMD) {
WSLogger.ROOT_LOGGER.trace("Setting security roles");
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);
}
}
}
}
Aggregations