@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); } }
final Map<String, Set<String>> principalVsRolesMap = securityRoles.getPrincipalVersusRolesMap(); if (! principalVsRolesMap.isEmpty()) { interceptorFactories.put(InterceptorOrder.View.SECURITY_ROLES, new ImmediateInterceptorFactory(new SecurityRolesAddingInterceptor("ejb", principalVsRolesMap))); final Set<String> extraRoles = securityRoles.getSecurityRoleNamesByPrincipal(runAsPrincipal); if (! extraRoles.isEmpty()) { interceptorFactories.put(InterceptorOrder.View.EXTRA_PRINCIPAL_ROLES, new ImmediateInterceptorFactory(new RoleAddingInterceptor("ejb", RoleMapper.constant(Roles.fromSet(extraRoles)))));
if (securityRoles != null && !securityRoles.isEmpty()) { return true;
if(earSecurityRolesMetaData != null) { if(mergedMetaData.getSecurityRoles() == null) { mergedMetaData.setSecurityRoles(new SecurityRolesMetaData());
/** * 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; }
final boolean hasSecurityRolesMD = securityRolesMD != null && !securityRolesMD.isEmpty(); if (earMetaData != null) { if (jbossWebMD.getSecurityRoles() == null) { jbossWebMD.setSecurityRoles(new SecurityRolesMetaData());
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); } } } } } }
securityRoles = new SecurityRolesMetaData(); securityRoles.merge(override != null ? override.securityRoles : null, original != null ? original.securityRoles : null);
securityRoles = new SecurityRolesMetaData(); SecurityRolesMetaData overrideRoles = null; SecurityRolesMetaData originalRoles = null; if(original != null) originalRoles = original.getSecurityRoles(); securityRoles.merge(overrideRoles, originalRoles); Set<String> extraRoles = securityRoles.getSecurityRoleNamesByPrincipal(principalName); RunAsIdentityMetaData runAsId = new RunAsIdentityMetaData(webXmlRunAs, principalName, extraRoles); runAsIdentity.put(servletName, runAsId);
SecurityRoleMetaData to = this.get(sr.getRoleName()); if(to != null) this.add(sr); SecurityRoleMetaData to = this.get(sr.getRoleName()); if(to != null) this.add(sr); rebuildPrincipalsVersusRolesMap();
/** * Get the security role names by principal * * @param userName the principal name * @return the security role names containing the principal * @throws IllegalArgumentException for a null user name */ public Set<String> getSecurityRoleNamesByPrincipal(String userName) { if (userName == null) throw new IllegalArgumentException("Null userName"); if (securityRoles == null) return Collections.emptySet(); return securityRoles.getSecurityRoleNamesByPrincipal(userName); }
/** * Get the security roles * * @return the security roles */ public Map<String, SecurityRoleMetaData> getSecurityRoles() { SecurityRolesMetaData roles = getDelegate().getSecurityRoles(); if (roles == null) return Collections.emptyMap(); Map<String, SecurityRoleMetaData> result = new LinkedHashMap<String, SecurityRoleMetaData>(roles.size()); for (org.jboss.metadata.javaee.spec.SecurityRoleMetaData role : roles) result.put(role.getRoleName(), new SecurityRoleMetaData(role)); return result; }
previousRolesAssociationMap = this.setSecurityRolesAssociation(rolesMetaData.getPrincipalVersusRolesMap());
/** * Get the security-role names from the web.xml descriptor * * @return Set<String> of the security-role names from the web.xml */ public Set<String> getSecurityRoleNames() { return new HashSet<String>(securityRoles.keySet()); }
earMetaData.setDescriptionGroup(new DescriptionGroupMetaData()); earMetaData.setModules(new ModulesMetaData()); earMetaData.setSecurityRoles(new SecurityRolesMetaData()); environmentRefsGroupMetaData.setMessageDestinations(new MessageDestinationsMetaData()); earMetaData.setEarEnvironmentRefsGroup(environmentRefsGroupMetaData);
/** * 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; }
final boolean hasSecurityRolesMD = securityRolesMD != null && !securityRolesMD.isEmpty(); if (earMetaData != null) { if (jbossWebMD.getSecurityRoles() == null) { jbossWebMD.setSecurityRoles(new SecurityRolesMetaData());
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); } } } } } }
securityRoles = new SecurityRolesMetaData(); securityRoles.merge(override != null ? override.securityRoles : null, original != null ? original.securityRoles : null);
securityRoles = new SecurityRolesMetaData(); SecurityRolesMetaData overrideRoles = null; SecurityRolesMetaData originalRoles = null; if(original != null) originalRoles = original.getSecurityRoles(); securityRoles.merge(overrideRoles, originalRoles); Set<String> extraRoles = securityRoles.getSecurityRoleNamesByPrincipal(principalName); RunAsIdentityMetaData runAsId = new RunAsIdentityMetaData(webXmlRunAs, principalName, extraRoles); runAsIdentity.put(servletName, runAsId);