Package org.jboss.metadata.javaee.spec

Examples of org.jboss.metadata.javaee.spec.SecurityRolesMetaData


    *
    * @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;
   }
View Full Code Here


      if(override != null && override.methodPermissions != null)
         this.setMethodPermissions(override.methodPermissions);
      else if(original != null && original.getMethodPermissions() != null)
         this.setMethodPermissions(original.getMethodPermissions());

      SecurityRolesMetaData securityRolesMetaData = null;
      SecurityRolesMetaData jbossSecurityRolesMetaData = null;
      MessageDestinationsMetaData messageDestinationsMetaData = null;
      MessageDestinationsMetaData jbossMessageDestinationsMetaData = null;
      if(override != null )
      {
         jbossMessageDestinationsMetaData = override.getMessageDestinations();
         jbossSecurityRolesMetaData = override.getSecurityRoles();
      }
      if (original != null)
      {
         securityRolesMetaData = original.getSecurityRoles();
         messageDestinationsMetaData = original.getMessageDestinations();
      }

      if (jbossSecurityRolesMetaData == null || jbossSecurityRolesMetaData.isEmpty())
      {
         if (securityRolesMetaData != null)
            merged.setSecurityRoles(securityRolesMetaData);
      }
      else
      {
         SecurityRolesMetaData mergedSecurityRolesMetaData = new SecurityRolesMetaData();
         mergedSecurityRolesMetaData = JavaEEMetaDataUtil.mergeJBossXml(mergedSecurityRolesMetaData, securityRolesMetaData, jbossSecurityRolesMetaData, "security-role", false);
         if (mergedSecurityRolesMetaData != null && mergedSecurityRolesMetaData.isEmpty() == false)
            merged.setSecurityRoles(mergedSecurityRolesMetaData);
      }
     
      if (jbossMessageDestinationsMetaData == null || jbossMessageDestinationsMetaData.isEmpty())
      {
View Full Code Here

         overrideModules = override.getModules();
      if(original != null)
         originalModules = original.getModules();
      modules.merge(overrideModules, originalModules);

      SecurityRolesMetaData securityRolesMetaData = null;
      SecurityRolesMetaData overrideSecurityRolesMetaData = null;
      if (original != null)
         securityRolesMetaData = original.getSecurityRoles();
      if(override != null)
         overrideSecurityRolesMetaData = override.getSecurityRoles();
      if(securityRoles == null)
         securityRoles = new SecurityRolesMetaData();
      securityRoles.merge(overrideSecurityRolesMetaData, securityRolesMetaData);
   }
View Full Code Here

      throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException
   {
      JBossAssemblyDescriptorMetaData assembly = dd.getAssemblyDescriptor();
      if (assembly != null)
      {
         SecurityRolesMetaData securityRoles = assembly.getSecurityRoles();

         if (securityRoles != null && securityRoles.size() > 0)
         {
            List<String> roleList = new ArrayList<String>();
            for (SecurityRoleMetaData securityRole : securityRoles)
            {
               roleList.add(securityRole.getRoleName());
View Full Code Here

            if (securityRoleMetaDatas != null) {
                for (final SecurityRoleMetaData securityRoleMetaData : securityRoleMetaDatas) {
                    securityRoles.add(securityRoleMetaData.getRoleName());
                }
            }
            final SecurityRolesMetaData securityRolesMD = ejbJarMD.getAssemblyDescriptor().getSecurityRoles();
            if (securityRolesMD != null && securityRolesMD.size() > 0) {
                for (final SecurityRoleMetaData securityRoleMD : securityRolesMD) {
                    securityRoles.add(securityRoleMD.getRoleName());
                }
            }
        }
View Full Code Here

        final String authMethod = getAuthMethod(dep);
        final boolean hasAuthMethod = authMethod != null;

        if (hasAuthMethod) {
            final SecurityMetaDataAccessorEJB ejbMDAccessor = getEjbSecurityMetaDataAccessor(dep);
            final SecurityRolesMetaData securityRolesMD = ejbMDAccessor.getSecurityRoles(dep);
            final boolean hasSecurityRolesMD = securityRolesMD != null;

            if (hasSecurityRolesMD) {
                ROOT_LOGGER.creatingSecurityRoles();
                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);
                }
            }
        }
View Full Code Here

        return securityDomain;
    }

    public SecurityRolesMetaData getSecurityRoles(final Deployment dep) {
        final SecurityRolesMetaData securityRolesMD = new SecurityRolesMetaData();

        for (final EJBEndpoint ejbEndpoint : getEjbEndpoints(dep)) {
            for (final String roleName : ejbEndpoint.getSecurityRoles()) {
                final SecurityRoleMetaData securityRoleMD = new SecurityRoleMetaData();
                securityRoleMD.setRoleName(roleName);
                securityRolesMD.add(securityRoleMD);
            }
        }

        return securityRolesMD;
    }
View Full Code Here

            if (securityRoleMetaDatas != null) {
                for (final SecurityRoleMetaData securityRoleMetaData : securityRoleMetaDatas) {
                    securityRoles.add(securityRoleMetaData.getRoleName());
                }
            }
            final SecurityRolesMetaData securityRolesMD = ejbJarMD.getAssemblyDescriptor().getSecurityRoles();
            if (securityRolesMD != null && securityRolesMD.size() > 0) {
                for (final SecurityRoleMetaData securityRoleMD : securityRolesMD) {
                    securityRoles.add(securityRoleMD.getRoleName());
                }
            }
        }
View Full Code Here

        // no-op
    }

    @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);
View Full Code Here

            ROOT_LOGGER.trace("Using security domain: " + securityDomain + " for EJB " + ejbComponent.getComponentName());
        }
        final String runAs = securityMetaData.getRunAs();
        // TODO - We should do something with DeclaredRoles although it never has much meaning in JBoss AS
        final String runAsPrincipal = securityMetaData.getRunAsPrincipal();
        final SecurityRolesMetaData securityRoles = securityMetaData.getSecurityRoles();
        Set<String> extraRoles = null;
        Map<String,Set<String>> principalVsRolesMap = null;
        if (securityRoles != null) {
            principalVsRolesMap = securityRoles.getPrincipalVersusRolesMap();
            if (runAsPrincipal != null)
                extraRoles = securityRoles.getSecurityRoleNamesByPrincipal(runAsPrincipal);
        }
        SecurityContextInterceptorHolder holder = new SecurityContextInterceptorHolder();
        holder.setSecurityManager(securityManager).setSecurityDomain(securityDomain)
        .setRunAs(runAs).setRunAsPrincipal(runAsPrincipal)
        .setExtraRoles(extraRoles).setPrincipalVsRolesMap(principalVsRolesMap);
View Full Code Here

TOP

Related Classes of org.jboss.metadata.javaee.spec.SecurityRolesMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.