Package org.jboss.security.mapping.config

Examples of org.jboss.security.mapping.config.MappingModuleEntry


                mappingType = module.get(TYPE).asString();
            else
                mappingType = MappingType.ROLE.toString();

            Map<String, Object> options = extractOptions(module);
            MappingModuleEntry entry = new MappingModuleEntry(codeName, options, mappingType);
            mappingInfo.add(entry);
            applicationPolicy.setMappingInfo(mappingType, mappingInfo);

            String moduleName = module.get(MODULE).asString();
            if(module.hasDefined(MODULE) && moduleName != null &&  moduleName.length() > 0 ) {
View Full Code Here


                mappingType = module.get(TYPE).asString();
            else
                mappingType = MappingType.ROLE.toString();

            Map<String, Object> options = extractOptions(module);
            MappingModuleEntry entry = new MappingModuleEntry(codeName, options, mappingType);
            mappingInfo.add(entry);
            applicationPolicy.setMappingInfo(mappingType, mappingInfo);

            String moduleName = module.get(MODULE).asString();
            if(module.hasDefined(MODULE) && moduleName != null &&  moduleName.length() > 0 ) {
View Full Code Here

      // Mapping
      MappingInfo mappingInfo = completeConfig.getMappingInfo(MappingType.PRINCIPAL.toString());
      assertNotNull("MappingInfo is not null", mappingInfo);
      MappingModuleEntry[] mappingEntries = mappingInfo.getMappingModuleEntry();
      assertEquals("Invalid number of entries", 1, mappingEntries.length);
      MappingModuleEntry mappingEntry = mappingEntries[0];
      assertEquals("org.jboss.test.mapping.MappingModule1", mappingEntry.getMappingModuleName());
      Map<String, ?> mappingOptions = mappingEntry.getOptions();
      assertEquals("Invalid number of options", 1, mappingOptions.size());
      Assert.assertTrue("Option option1 was not found", mappingOptions.containsKey("option1"));
      assertEquals("value1", mappingOptions.get("option1"));

      // Role Mapping
      mappingInfo = completeConfig.getMappingInfo(MappingType.ROLE.toString());
      assertNotNull("MappingInfo is not null", mappingInfo);
      MappingModuleEntry[] mmearr = mappingInfo.getMappingModuleEntry();
      assertEquals("Mapping entry length=1", 1, mmearr.length);
      MappingModuleEntry mme = mmearr[0];
      assertEquals("TestMappingModule", "org.jboss.test.TestMappingModule", mme.getMappingModuleName());
      Map<String, ?> mmOptions = mme.getOptions();
      assertEquals("Number of options = 2", 2, mmOptions.size());
      assertEquals("name=rolemap", "rolemap", mmOptions.get("name"));
      assertEquals("succeed=true", "true", mmOptions.get("succeed"));

      // Audit
      AuditInfo ai = completeConfig.getAuditInfo();
      assertNotNull("AuditInfo", ai);
      AuditProviderEntry[] apelist = ai.getAuditProviderEntry();
      assertEquals("Audit entry length=1", 1, apelist.length);
      AuditProviderEntry ape = apelist[0];
      assertEquals("TestMappingModule", "org.jboss.test.TestMappingModule", mme.getMappingModuleName());
      Map<String, ?> auditOptions = ape.getOptions();
      assertEquals("Number of options = 2", 2, auditOptions.size());
      assertEquals("name=auditprovider", "auditprovider", auditOptions.get("name"));
      assertEquals("succeed=false", "false", auditOptions.get("succeed"));

      // Identity Trust
      IdentityTrustInfo iti = completeConfig.getIdentityTrustInfo();
      assertNotNull("IdentityTrustInfo", iti);
      IdentityTrustModuleEntry[] itilist = iti.getIdentityTrustModuleEntry();
      assertEquals("IdentityTrustModuleEntry length=1", 1, itilist.length);
      IdentityTrustModuleEntry itie = itilist[0];
      assertEquals("TestMappingModule", "org.jboss.test.TestMappingModule", mme.getMappingModuleName());
      Map<String, ?> itieOptions = itie.getOptions();
      assertEquals("Number of options = 3", 3, itieOptions.size());
      assertEquals("name=trustprovider", "trustprovider", itieOptions.get("name"));
      assertEquals("succeed=true", "true", itieOptions.get("succeed"));
      assertEquals("dummy=dr", "dr", itieOptions.get("dummy"));
View Full Code Here

   }
  
   public void testX509() throws Exception
  
      ApplicationPolicy ap = SecurityConfiguration.getApplicationPolicy("test");
      MappingModuleEntry mme = new MappingModuleEntry(SubjectDNMapper.class.getName());
      MappingInfo principalMappingInfo = new MappingInfo();
      principalMappingInfo.add(mme);
      ap.setPrincipalMappingInfo(principalMappingInfo);
    
      String issuerDN = "CN=Fedora,OU=JBoss,O=Red Hat,C=US";
View Full Code Here

   }
  
   public void testLDAPAttributes() throws Exception
  
      ApplicationPolicy ap = SecurityConfiguration.getApplicationPolicy("test");
      MappingModuleEntry mme = new MappingModuleEntry(LdapAttributeMappingProvider.class.getName());
     
      String attributeList = "mail,cn,commonname,givenname,surname,employeeType," +
                       "employeeNumber,facsimileTelephoneNumber";
      mme.add(new ModuleOption("bindDN",this.adminDN));
      mme.add(new ModuleOption("bindCredential",this.adminPW));
      mme.add(new ModuleOption("baseFilter","(uid={0})"));
      mme.add(new ModuleOption("java.naming.provider.url", "ldap://" + serverHost  + ":" + port));
      mme.add(new ModuleOption("baseCtxDN", "ou=People,dc=jboss,dc=org"));
      mme.add(new ModuleOption("attributeList", attributeList));

      MappingInfo attributeMappingInfo = new MappingInfo();
      attributeMappingInfo.add(mme);
      ap.setMappingInfo(MappingType.ATTRIBUTE.name(),attributeMappingInfo);
     
View Full Code Here

                if (module.hasDefined(MODULE_OPTIONS)) {
                    for (Property prop : module.get(MODULE_OPTIONS).asPropertyList()) {
                        options.put(prop.getName(), prop.getValue().asString());
                    }
                }
                MappingModuleEntry entry = new MappingModuleEntry(codeName, options, mappingType);
                mappingInfo.add(entry);
                applicationPolicy.setMappingInfo(mappingType, mappingInfo);
            }
        }

        // authentication-jaspi
        node = operation.get(Element.AUTHENTICATION_JASPI.getLocalName());
        if (node.isDefined()) {
            JASPIAuthenticationInfo authenticationInfo = new JASPIAuthenticationInfo(securityDomain);
            Map<String, LoginModuleStackHolder> holders = new HashMap<String, LoginModuleStackHolder>();
            ModelNode moduleStack = node.get(Element.LOGIN_MODULE_STACK.getLocalName());
            modules = moduleStack.asList();
            Iterator<ModelNode> iter = modules.iterator();
            ModelNode nameNode = iter.next();
            String name = nameNode.get(Attribute.NAME.getLocalName()).asString();
            LoginModuleStackHolder holder = new LoginModuleStackHolder(name, null);
            holders.put(name, holder);
            authenticationInfo.add(holder);
            while (iter.hasNext()) {
                ModelNode module = iter.next();
                String code = module.require(Attribute.CODE.getLocalName()).asString();
                LoginModuleControlFlag controlFlag = getControlFlag(module.require(Attribute.FLAG.getLocalName()).asString());
                Map<String, Object> options = new HashMap<String, Object>();
                if (module.hasDefined(MODULE_OPTIONS)) {
                    for (Property prop : module.get(MODULE_OPTIONS).asPropertyList()) {
                        options.put(prop.getName(), prop.getValue().asString());
                    }
                }
                AppConfigurationEntry entry = new AppConfigurationEntry(code, controlFlag, options);
                holder.addAppConfigurationEntry(entry);
            }
            ModelNode authModule = node.get(Element.AUTH_MODULE.getLocalName());
            String code = authModule.require(Attribute.CODE.getLocalName()).asString();
            String loginStackRef = null;
            if (authModule.hasDefined(Attribute.LOGIN_MODULE_STACK_REF.getLocalName()))
                loginStackRef = authModule.get(Attribute.LOGIN_MODULE_STACK_REF.getLocalName()).asString();
            Map<String, Object> options = new HashMap<String, Object>();
            if (authModule.hasDefined(MODULE_OPTIONS)) {
                for (Property prop : authModule.get(MODULE_OPTIONS).asPropertyList()) {
                    options.put(prop.getName(), prop.getValue().asString());
                }
            }
            AuthModuleEntry entry = new AuthModuleEntry(code, options, loginStackRef);
            if (loginStackRef != null) {
                if (!holders.containsKey(loginStackRef)) {
                    throw new IllegalArgumentException("auth-module references a login module stack that doesn't exist: "
                            + loginStackRef);
                }
                entry.setLoginModuleStackHolder(holders.get(loginStackRef));
            }
            authenticationInfo.add(entry);
            applicationPolicy.setAuthenticationInfo(authenticationInfo);
        }
View Full Code Here

         log.trace("newChild.RoleMappingInfo, localName: "+localName);
      if("mapping-module".equals(localName))
      {
         String code = attrs.getValue("code");
         code = StringPropertyReplacer.replaceProperties(code.trim());
         MappingModuleEntry entry = new MappingModuleEntry(code)
         child = entry;
         if( trace )
            log.trace("newChild.RoleMappingInfo, mapping-module code: "+code);
      }
     
View Full Code Here

                if (module.hasDefined(MODULE_OPTIONS)) {
                    for (Property prop : module.get(MODULE_OPTIONS).asPropertyList()) {
                        options.put(prop.getName(), prop.getValue().asString());
                    }
                }
                MappingModuleEntry entry = new MappingModuleEntry(codeName, options, mappingType);
                mappingInfo.add(entry);
                applicationPolicy.setMappingInfo(mappingType, mappingInfo);
            }
        }

        // authentication-jaspi
        node = operation.get(AUTHENTICATION_JASPI);
        if (node.isDefined()) {
            if (applicationPolicy == null)
                applicationPolicy = new ApplicationPolicy(securityDomain);
            JASPIAuthenticationInfo authenticationInfo = new JASPIAuthenticationInfo(securityDomain);
            Map<String, LoginModuleStackHolder> holders = new HashMap<String, LoginModuleStackHolder>();
            ModelNode moduleStack = node.get(LOGIN_MODULE_STACK);
            modules = moduleStack.asList();
            for (ModelNode loginModuleStack : modules) {
                List<ModelNode> nodes = loginModuleStack.asList();
                Iterator<ModelNode> iter = nodes.iterator();
                ModelNode nameNode = iter.next();
                String name = nameNode.get(NAME).asString();
                LoginModuleStackHolder holder = new LoginModuleStackHolder(name, null);
                holders.put(name, holder);
                authenticationInfo.add(holder);
                while (iter.hasNext()) {
                    ModelNode lmsNode = iter.next();
                    List<ModelNode> lms = lmsNode.asList();
                    for (ModelNode lmNode : lms) {
                        String code = lmNode.require(CODE).asString();
                        LoginModuleControlFlag controlFlag = getControlFlag(lmNode.require(FLAG).asString());
                        Map<String, Object> options = new HashMap<String, Object>();
                        if (lmNode.hasDefined(MODULE_OPTIONS)) {
                            for (Property prop : lmNode.get(MODULE_OPTIONS).asPropertyList()) {
                                options.put(prop.getName(), prop.getValue().asString());
                            }
                        }
                        AppConfigurationEntry entry = new AppConfigurationEntry(code, controlFlag, options);
                        holder.addAppConfigurationEntry(entry);
                    }
                }
            }
            ModelNode authModuleNode = node.get(AUTH_MODULE);
            List<ModelNode> authModules = authModuleNode.asList();
            for (ModelNode authModule : authModules) {
                String code = authModule.require(CODE).asString();
                String loginStackRef = null;
                if (authModule.hasDefined(LOGIN_MODULE_STACK_REF))
                    loginStackRef = authModule.get(LOGIN_MODULE_STACK_REF).asString();
                Map<String, Object> options = new HashMap<String, Object>();
                if (authModule.hasDefined(MODULE_OPTIONS)) {
                    for (Property prop : authModule.get(MODULE_OPTIONS).asPropertyList()) {
                        options.put(prop.getName(), prop.getValue().asString());
                    }
                }
                AuthModuleEntry entry = new AuthModuleEntry(code, options, loginStackRef);
                if (loginStackRef != null) {
                    if (!holders.containsKey(loginStackRef)) {
                        throw new IllegalArgumentException("auth-module references a login module stack that doesn't exist: "
                                + loginStackRef);
                    }
                    entry.setLoginModuleStackHolder(holders.get(loginStackRef));
                }
                authenticationInfo.add(entry);
            }
            applicationPolicy.setAuthenticationInfo(authenticationInfo);
        }
View Full Code Here

                if (module.hasDefined(MODULE_OPTIONS)) {
                    for (Property prop : module.get(MODULE_OPTIONS).asPropertyList()) {
                        options.put(prop.getName(), prop.getValue().asString());
                    }
                }
                MappingModuleEntry entry = new MappingModuleEntry(codeName, options, mappingType);
                mappingInfo.add(entry);
                applicationPolicy.setMappingInfo(mappingType, mappingInfo);
            }
        }

        // authentication-jaspi
        node = operation.get(Element.AUTHENTICATION_JASPI.getLocalName());
        if (node.isDefined()) {
            JASPIAuthenticationInfo authenticationInfo = new JASPIAuthenticationInfo(securityDomain);
            Map<String, LoginModuleStackHolder> holders = new HashMap<String, LoginModuleStackHolder>();
            ModelNode moduleStack = node.get(Element.LOGIN_MODULE_STACK.getLocalName());
            modules = moduleStack.asList();
            for (ModelNode loginModuleStack : modules) {
                List<ModelNode> nodes = loginModuleStack.asList();
                Iterator<ModelNode> iter = nodes.iterator();
                ModelNode nameNode = iter.next();
                String name = nameNode.get(Attribute.NAME.getLocalName()).asString();
                LoginModuleStackHolder holder = new LoginModuleStackHolder(name, null);
                holders.put(name, holder);
                authenticationInfo.add(holder);
                while (iter.hasNext()) {
                    ModelNode lmsNode = iter.next();
                    List<ModelNode> lms = lmsNode.asList();
                    for (ModelNode lmNode : lms) {
                        String code = lmNode.require(Attribute.CODE.getLocalName()).asString();
                        LoginModuleControlFlag controlFlag = getControlFlag(lmNode.require(Attribute.FLAG.getLocalName())
                                .asString());
                        Map<String, Object> options = new HashMap<String, Object>();
                        if (lmNode.hasDefined(MODULE_OPTIONS)) {
                            for (Property prop : lmNode.get(MODULE_OPTIONS).asPropertyList()) {
                                options.put(prop.getName(), prop.getValue().asString());
                            }
                        }
                        AppConfigurationEntry entry = new AppConfigurationEntry(code, controlFlag, options);
                        holder.addAppConfigurationEntry(entry);
                    }
                }
            }
            ModelNode authModuleNode = node.get(Element.AUTH_MODULE.getLocalName());
            List<ModelNode> authModules = authModuleNode.asList();
            for (ModelNode authModule : authModules) {
                String code = authModule.require(Attribute.CODE.getLocalName()).asString();
                String loginStackRef = null;
                if (authModule.hasDefined(Attribute.LOGIN_MODULE_STACK_REF.getLocalName()))
                    loginStackRef = authModule.get(Attribute.LOGIN_MODULE_STACK_REF.getLocalName()).asString();
                Map<String, Object> options = new HashMap<String, Object>();
                if (authModule.hasDefined(MODULE_OPTIONS)) {
                    for (Property prop : authModule.get(MODULE_OPTIONS).asPropertyList()) {
                        options.put(prop.getName(), prop.getValue().asString());
                    }
                }
                AuthModuleEntry entry = new AuthModuleEntry(code, options, loginStackRef);
                if (loginStackRef != null) {
                    if (!holders.containsKey(loginStackRef)) {
                        throw new IllegalArgumentException("auth-module references a login module stack that doesn't exist: "
                                + loginStackRef);
                    }
                    entry.setLoginModuleStackHolder(holders.get(loginStackRef));
                }
                authenticationInfo.add(entry);
            }
            applicationPolicy.setAuthenticationInfo(authenticationInfo);
        }
View Full Code Here

/* 184 */       log.trace("newChild.RoleMappingInfo, localName: " + localName);
/* 185 */     if ("mapping-module".equals(localName))
/*     */     {
/* 187 */       String code = attrs.getValue("code");
/* 188 */       code = StringPropertyReplacer.replaceProperties(code.trim());
/* 189 */       MappingModuleEntry entry = new MappingModuleEntry(code);
/* 190 */       child = entry;
/* 191 */       if (this.trace) {
/* 192 */         log.trace("newChild.RoleMappingInfo, mapping-module code: " + code);
/*     */       }
/*     */     }
View Full Code Here

TOP

Related Classes of org.jboss.security.mapping.config.MappingModuleEntry

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.