@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); } }
SecurityRoleMetaData sr = new SecurityRoleMetaData(); sr.setRoleName(role); securityRoles.add(sr);
/** * Get the security roles by principal * * @param userName the principal name * @return the security roles containing the principal or null for no roles * @throws IllegalArgumentException for a null user name */ @Deprecated public SecurityRolesMetaData getSecurityRolesByPrincipal(String userName) { if (userName == null) throw new IllegalArgumentException("Null userName"); if (isEmpty()) return null; SecurityRolesMetaData result = new SecurityRolesMetaData(); for (SecurityRoleMetaData role : this) { if (role.hasPrincipal(userName)) result.add(role); } return result; }
/** * Get the security roles by principal * * @param userName the principal name * @return the security roles containing the principal or null for no roles * @throws IllegalArgumentException for a null user name */ @Deprecated public SecurityRolesMetaData getSecurityRolesByPrincipal(String userName) { if (userName == null) throw new IllegalArgumentException("Null userName"); if (isEmpty()) return null; SecurityRolesMetaData result = new SecurityRolesMetaData(); for (SecurityRoleMetaData role : this) { if (role.hasPrincipal(userName)) result.add(role); } return result; }
public void addSecurityRoles(JBossWebMetaData webApp, Deployment dep) { WebServiceDeployment webServiceDeployment = dep.getAttachment(WebServiceDeployment.class); if (webServiceDeployment != null) { Iterator<WebServiceDeclaration> it = webServiceDeployment.getServiceEndpoints().iterator(); while (it.hasNext()) { WebServiceDeclaration container = it.next(); RolesAllowed anRolesAllowed = container.getAnnotation(RolesAllowed.class); if (anRolesAllowed != null) { SecurityRolesMetaData securityRoles = webApp.getSecurityRoles(); for (String roleName : anRolesAllowed.value()) { SecurityRoleMetaData role = new SecurityRoleMetaData(); role.setRoleName(roleName); securityRoles.add(role); } } } } } }
public void addSecurityRoles(JBossWebMetaData webApp, Deployment dep) { WebServiceDeployment webServiceDeployment = dep.getAttachment(WebServiceDeployment.class); if (webServiceDeployment != null) { Iterator<WebServiceDeclaration> it = webServiceDeployment.getServiceEndpoints().iterator(); while (it.hasNext()) { WebServiceDeclaration container = it.next(); RolesAllowed anRolesAllowed = container.getAnnotation(RolesAllowed.class); if (anRolesAllowed != null) { SecurityRolesMetaData securityRoles = webApp.getSecurityRoles(); for (String roleName : anRolesAllowed.value()) { SecurityRoleMetaData role = new SecurityRoleMetaData(); role.setRoleName(roleName); securityRoles.add(role); } } } } } }
public void addSecurityRoles(JBossWebMetaData webApp, Deployment dep) { WebServiceDeployment webServiceDeployment = dep.getAttachment(WebServiceDeployment.class); if (webServiceDeployment != null) { Iterator<WebServiceDeclaration> it = webServiceDeployment.getServiceEndpoints().iterator(); while (it.hasNext()) { WebServiceDeclaration container = it.next(); RolesAllowed anRolesAllowed = container.getAnnotation(RolesAllowed.class); if (anRolesAllowed != null) { SecurityRolesMetaData securityRoles = webApp.getSecurityRoles(); for (String roleName : anRolesAllowed.value()) { SecurityRoleMetaData role = new SecurityRoleMetaData(); role.setRoleName(roleName); securityRoles.add(role); } } } } } }
public void addSecurityRoles(JBossWebMetaData webApp, Deployment dep) { WebServiceDeployment webServiceDeployment = dep.getAttachment(WebServiceDeployment.class); if (webServiceDeployment != null) { Iterator<WebServiceDeclaration> it = webServiceDeployment.getServiceEndpoints().iterator(); while (it.hasNext()) { WebServiceDeclaration container = it.next(); RolesAllowed anRolesAllowed = container.getAnnotation(RolesAllowed.class); if (anRolesAllowed != null) { SecurityRolesMetaData securityRoles = webApp.getSecurityRoles(); for (String roleName : anRolesAllowed.value()) { SecurityRoleMetaData role = new SecurityRoleMetaData(); role.setRoleName(roleName); securityRoles.add(role); } } } } } }
/** * @see org.jboss.webservices.integration.tomcat.AbstractSecurityMetaDataAccessorEJB#getSecurityRoles(Deployment) * * @param dep webservice deployment * @return security roles associated with EJB 21 deployment */ public SecurityRolesMetaData getSecurityRoles(final Deployment dep) { final WebServiceDeployment wsDeployment = WSHelper.getRequiredAttachment(dep, WebServiceDeployment.class); final SecurityRolesMetaData securityRolesMD = new SecurityRolesMetaData(); final Iterator<WebServiceDeclaration> ejbContainers = wsDeployment.getServiceEndpoints().iterator(); while (ejbContainers.hasNext()) { final WebServiceDeclaration ejbContainer = ejbContainers.next(); final RolesAllowed allowedRoles = ejbContainer.getAnnotation(RolesAllowed.class); final boolean hasAllowedRoles = allowedRoles != null; if (hasAllowedRoles) { for (final String roleName : allowedRoles.value()) { final SecurityRoleMetaData securityRoleMD = new SecurityRoleMetaData(); securityRoleMD.setRoleName(roleName); securityRolesMD.add(securityRoleMD); } } } return securityRolesMD; }
/** * @see org.jboss.webservices.integration.tomcat.AbstractSecurityMetaDataAccessorEJB#getSecurityRoles(Deployment) * * @param dep webservice deployment * @return security roles associated with EJB 21 deployment */ public SecurityRolesMetaData getSecurityRoles(final Deployment dep) { final WebServiceDeployment wsDeployment = WSHelper.getRequiredAttachment(dep, WebServiceDeployment.class); final SecurityRolesMetaData securityRolesMD = new SecurityRolesMetaData(); final Iterator<WebServiceDeclaration> ejbContainers = wsDeployment.getServiceEndpoints().iterator(); while (ejbContainers.hasNext()) { final WebServiceDeclaration ejbContainer = ejbContainers.next(); final RolesAllowed allowedRoles = ejbContainer.getAnnotation(RolesAllowed.class); final boolean hasAllowedRoles = allowedRoles != null; if (hasAllowedRoles) { for (final String roleName : allowedRoles.value()) { final SecurityRoleMetaData securityRoleMD = new SecurityRoleMetaData(); securityRoleMD.setRoleName(roleName); securityRolesMD.add(securityRoleMD); } } } return securityRolesMD; }
/** * @see org.jboss.webservices.integration.tomcat.AbstractSecurityMetaDataAccessorEJB#getSecurityRoles(Deployment) * * @param dep webservice deployment * @return security roles associated with EJB 21 deployment */ public SecurityRolesMetaData getSecurityRoles(final Deployment dep) { final WebServiceDeployment wsDeployment = WSHelper.getRequiredAttachment(dep, WebServiceDeployment.class); final SecurityRolesMetaData securityRolesMD = new SecurityRolesMetaData(); final Iterator<WebServiceDeclaration> ejbContainers = wsDeployment.getServiceEndpoints().iterator(); while (ejbContainers.hasNext()) { final WebServiceDeclaration ejbContainer = ejbContainers.next(); final RolesAllowed allowedRoles = ejbContainer.getAnnotation(RolesAllowed.class); final boolean hasAllowedRoles = allowedRoles != null; if (hasAllowedRoles) { for (final String roleName : allowedRoles.value()) { final SecurityRoleMetaData securityRoleMD = new SecurityRoleMetaData(); securityRoleMD.setRoleName(roleName); securityRolesMD.add(securityRoleMD); } } } return securityRolesMD; }
public void process(SecurityRolesMetaData metaData, Class element) { DeclareRoles roles = finder.getAnnotation(element, DeclareRoles.class); if(roles == null) return; for(String role : roles.value()) { SecurityRoleMetaData sr = new SecurityRoleMetaData(); sr.setRoleName(role); Descriptions descriptions = ProcessorUtils.getDescription("DeclareRoles("+roles.value()+") on class: "+element.getName()); sr.setDescriptions(descriptions); metaData.add(sr); } }
public void process(SecurityRolesMetaData metaData, Class<?> element) { DeclareRoles roles = finder.getAnnotation(element, DeclareRoles.class); if(roles == null) return; for(String role : roles.value()) { SecurityRoleMetaData sr = new SecurityRoleMetaData(); sr.setRoleName(role); Descriptions descriptions = ProcessorUtils.getDescription("DeclareRoles("+roles.value()+") on class: "+element.getName()); sr.setDescriptions(descriptions); metaData.add(sr); } }
public SecurityRolesMetaData getSecurityRoles(final Deployment dep) { final SecurityRolesMetaData securityRolesMD = new SecurityRolesMetaData(); Set<String> firstEndpointDeclaredSecurityRoles = null; for (final EJBEndpoint ejbEndpoint : getEjbEndpoints(dep)) { final Set<String> declaredSecurityRoles = ejbEndpoint.getDeclaredSecurityRoles(); if (firstEndpointDeclaredSecurityRoles == null) { firstEndpointDeclaredSecurityRoles = declaredSecurityRoles; } else if (!firstEndpointDeclaredSecurityRoles.equals(declaredSecurityRoles)) { WSLogger.ROOT_LOGGER.multipleEndpointsWithDifferentDeclaredSecurityRoles(); } //union of declared security roles from all endpoints... for (final String roleName : declaredSecurityRoles) { final SecurityRoleMetaData securityRoleMD = new SecurityRoleMetaData(); securityRoleMD.setRoleName(roleName); securityRolesMD.add(securityRoleMD); } } return securityRolesMD; }
public SecurityRolesMetaData getSecurityRoles(final Deployment dep) { final SecurityRolesMetaData securityRolesMD = new SecurityRolesMetaData(); Set<String> firstEndpointDeclaredSecurityRoles = null; for (final EJBEndpoint ejbEndpoint : getEjbEndpoints(dep)) { final Set<String> declaredSecurityRoles = ejbEndpoint.getDeclaredSecurityRoles(); if (firstEndpointDeclaredSecurityRoles == null) { firstEndpointDeclaredSecurityRoles = declaredSecurityRoles; } else if (!firstEndpointDeclaredSecurityRoles.equals(declaredSecurityRoles)) { WSLogger.ROOT_LOGGER.multipleEndpointsWithDifferentDeclaredSecurityRoles(); } //union of declared security roles from all endpoints... for (final String roleName : declaredSecurityRoles) { final SecurityRoleMetaData securityRoleMD = new SecurityRoleMetaData(); securityRoleMD.setRoleName(roleName); securityRolesMD.add(securityRoleMD); } } return securityRolesMD; }
public SecurityRolesMetaData getSecurityRoles(final Deployment dep) { final SecurityRolesMetaData securityRolesMD = new SecurityRolesMetaData(); Set<String> firstEndpointDeclaredSecurityRoles = null; for (final EJBEndpoint ejbEndpoint : getEjbEndpoints(dep)) { final Set<String> declaredSecurityRoles = ejbEndpoint.getDeclaredSecurityRoles(); if (firstEndpointDeclaredSecurityRoles == null) { firstEndpointDeclaredSecurityRoles = declaredSecurityRoles; } else if (!firstEndpointDeclaredSecurityRoles.equals(declaredSecurityRoles)) { WSLogger.ROOT_LOGGER.multipleEndpointsWithDifferentDeclaredSecurityRoles(); } //union of declared security roles from all endpoints... for (final String roleName : declaredSecurityRoles) { final SecurityRoleMetaData securityRoleMD = new SecurityRoleMetaData(); securityRoleMD.setRoleName(roleName); securityRolesMD.add(securityRoleMD); } } return securityRolesMD; }
@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); } }
earMetaData.getSecurityRoles().add(SecurityRoleMetaDataParser.parse(reader, propertyReplacer)); break;