[jboss-cvs] JBossAS SVN: r64611 - in projects/security/security-jboss-sx/trunk/src: main/org/jboss/security/config and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 15 16:10:03 EDT 2007


Author: anil.saldhana at jboss.com
Date: 2007-08-15 16:10:03 -0400 (Wed, 15 Aug 2007)
New Revision: 64611

Modified:
   projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/auth/login/LoginConfigObjectModelFactory.java
   projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/config/ApplicationPolicyContainer.java
   projects/security/security-jboss-sx/trunk/src/resources/schema/security-config_5_0.xsd
   projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/security/config/JBossXBSchemaBindingUnitTestCase.java
   projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/security/config/SecurityConfigurationUnitTestCase.java
   projects/security/security-jboss-sx/trunk/src/tests/resources/config/securityConfig5.xml
Log:
JBossXB XSD work

Modified: projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/auth/login/LoginConfigObjectModelFactory.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/auth/login/LoginConfigObjectModelFactory.java	2007-08-15 20:08:58 UTC (rev 64610)
+++ projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/auth/login/LoginConfigObjectModelFactory.java	2007-08-15 20:10:03 UTC (rev 64611)
@@ -138,7 +138,8 @@
          String code = attrs.getValue("code");
          code = StringPropertyReplacer.replaceProperties(code.trim());
          String flag = attrs.getValue("flag");
-         flag = StringPropertyReplacer.replaceProperties(flag.trim());
+         if(flag != null)
+            flag = StringPropertyReplacer.replaceProperties(flag.trim());
          AppConfigurationEntryHolder holder = new AppConfigurationEntryHolder(code, flag);
          child = holder;
          if( trace )

Modified: projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/config/ApplicationPolicyContainer.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/config/ApplicationPolicyContainer.java	2007-08-15 20:08:58 UTC (rev 64610)
+++ projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/config/ApplicationPolicyContainer.java	2007-08-15 20:10:03 UTC (rev 64611)
@@ -30,6 +30,8 @@
 import javax.security.auth.login.AppConfigurationEntry;
 
 import org.jboss.logging.Logger;
+import org.jboss.security.audit.config.AuditConfigEntryHolder;
+import org.jboss.security.audit.config.AuditProviderEntry;
 import org.jboss.security.auth.container.config.AuthModuleEntry;
 import org.jboss.security.auth.login.AppConfigurationEntryHolder;
 import org.jboss.security.auth.login.AuthenticationInfo;
@@ -38,6 +40,8 @@
 import org.jboss.security.auth.login.LoginModuleStackHolder;
 import org.jboss.security.authorization.config.AuthorizationConfigEntryHolder;
 import org.jboss.security.authorization.config.AuthorizationModuleEntry; 
+import org.jboss.security.identitytrust.config.IdentityTrustConfigEntryHolder;
+import org.jboss.security.identitytrust.config.IdentityTrustModuleEntry;
 import org.jboss.xb.binding.GenericValueContainer;
 
 //$Id$
@@ -59,15 +63,22 @@
     
    List authenticationModuleEntries = new ArrayList();
    List authorizationModuleEntries = new ArrayList(); 
+   List auditProviderEntries = new ArrayList(); 
+   List identityTrustModuleEntries = new ArrayList();
+   
    Map loginModuleStackMap = new HashMap();
    
    boolean isJASPIAuthentication = false;
    boolean isJAASAuthentication = false;
    boolean isAuthorization = false;
+   boolean containsAudit = false;
+   boolean containsIdentityTrust = false;
    boolean containsRoleMapping = false;
    
    //Mapping Info Object
    RoleMappingInfo roleMappingInfo = null;
+   AuditInfo auditInfo = null;
+   IdentityTrustInfo identityTrustInfo = null;
    
    /**
     * @see GenericValueContainer#addChild(javax.xml.namespace.QName, java.lang.Object)
@@ -122,6 +133,20 @@
             authorizationModuleEntries.add(ameEntry);
          isAuthorization = true;
       } 
+      else if( value instanceof AuditProviderEntry)
+      { 
+         AuditProviderEntry ameEntry = (AuditProviderEntry)value;
+         if(!auditProviderEntries.contains(ameEntry))
+            auditProviderEntries.add(ameEntry); 
+         containsAudit = true;
+      } 
+      else if( value instanceof IdentityTrustModuleEntry )
+      { 
+         IdentityTrustModuleEntry ameEntry = (IdentityTrustModuleEntry) value;
+         if(!identityTrustModuleEntries.contains(ameEntry))
+            identityTrustModuleEntries.add(ameEntry); 
+         containsIdentityTrust = true;
+      }
    } 
    
    /**
@@ -171,6 +196,18 @@
       { 
          info.setRoleMappingInfo(roleMappingInfo);
       }
+      if(containsAudit)
+      {
+         auditInfo = new AuditInfo(authName);
+         auditInfo.add(auditProviderEntries);
+         info.setAuditInfo(auditInfo);
+      }
+      if(containsIdentityTrust)
+      {
+         identityTrustInfo = new IdentityTrustInfo(authName);
+         identityTrustInfo.add(identityTrustModuleEntries);
+         info.setIdentityTrustInfo(identityTrustInfo);
+      }
       return info; 
    }
 

Modified: projects/security/security-jboss-sx/trunk/src/resources/schema/security-config_5_0.xsd
===================================================================
--- projects/security/security-jboss-sx/trunk/src/resources/schema/security-config_5_0.xsd	2007-08-15 20:08:58 UTC (rev 64610)
+++ projects/security/security-jboss-sx/trunk/src/resources/schema/security-config_5_0.xsd	2007-08-15 20:10:03 UTC (rev 64611)
@@ -4,7 +4,8 @@
             xmlns="urn:jboss:security-config:5.0" 
             xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb" 
             targetNamespace="urn:jboss:security-config:5.0" 
-            elementFormDefault="qualified">
+            elementFormDefault="qualified"
+            attributeFormDefault="unqualified">
    <xsd:annotation>
       <xsd:appinfo>
          <jbxb:schemaBindings>
@@ -114,18 +115,16 @@
          <xsd:element ref="jbsx:trust-module"/>
       </xsd:sequence>
    </xsd:complexType>
+    
    
-   
-   <xsd:attribute name="flag">
-      <xsd:simpleType>
-         <xsd:restriction base="xsd:string">
-            <xsd:enumeration value="required"/>
-            <xsd:enumeration value="requisite"/>
-            <xsd:enumeration value="sufficient"/>
-            <xsd:enumeration value="optional"/>
-         </xsd:restriction>
-      </xsd:simpleType>
-   </xsd:attribute>
+   <xsd:simpleType name="module-option-flag">
+      <xsd:restriction base="xsd:string">
+         <xsd:enumeration value="required"/>
+         <xsd:enumeration value="requisite"/>
+         <xsd:enumeration value="sufficient"/>
+         <xsd:enumeration value="optional"/>
+      </xsd:restriction>
+   </xsd:simpleType>
 
    <xsd:element name="login-module" type="jbsx:loginModuleInfo"/>
    <xsd:complexType name="loginModuleInfo">
@@ -138,7 +137,7 @@
          <xsd:element ref="jbsx:module-option" minOccurs="0" maxOccurs="unbounded"/>
       </xsd:sequence>
       <xsd:attribute name="code" type="xsd:string" use="required"/>
-      <xsd:attribute ref="jbsx:flag" use="required"/>
+      <xsd:attribute name="flag" type="jbsx:module-option-flag" use="required"/>
    </xsd:complexType>
    
    <xsd:element name="module-option">
@@ -195,7 +194,7 @@
             <xsd:element ref="jbsx:module-option" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          <xsd:attribute name="code" type="xsd:string" use="required"/>
-         <xsd:attribute ref="jbsx:flag" use="required"/>
+         <xsd:attribute name="flag" type="jbsx:module-option-flag" use="required"/>
       </xsd:complexType>
    </xsd:element>
    <xsd:element name="mapping-module">
@@ -235,7 +234,7 @@
             <xsd:element ref="jbsx:module-option" minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
          <xsd:attribute name="code" type="xsd:string" use="required"/>
-         <xsd:attribute ref="jbsx:flag" use="required"/>
+         <xsd:attribute name="flag" type="jbsx:module-option-flag" use="required"/>
       </xsd:complexType>
    </xsd:element>
 </xsd:schema>

Modified: projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/security/config/JBossXBSchemaBindingUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/security/config/JBossXBSchemaBindingUnitTestCase.java	2007-08-15 20:08:58 UTC (rev 64610)
+++ projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/security/config/JBossXBSchemaBindingUnitTestCase.java	2007-08-15 20:10:03 UTC (rev 64611)
@@ -21,12 +21,6 @@
   */
 package org.jboss.test.security.config;
 
-import java.util.List;
-
-import javax.security.auth.login.AppConfigurationEntry;
-
-import org.jboss.security.auth.login.BaseAuthenticationInfo;
-import org.jboss.security.config.ApplicationPolicy;
 import org.jboss.security.config.PolicyConfig;
 import org.jboss.xb.binding.Unmarshaller;
 import org.jboss.xb.binding.UnmarshallerFactory;
@@ -43,38 +37,23 @@
  */
 public class JBossXBSchemaBindingUnitTestCase extends SecurityConfigurationUnitTestCase
 { 
+   
+   public JBossXBSchemaBindingUnitTestCase(String name)
+   {
+      super(name); 
+   }
+
    protected void setUp() throws Exception
    {
+      super.setUp();
+      
+      // **** UNCOMMENT TO ENABLE TRACE ***
+      //this.enableTrace("org.jboss.xb.binding.sunday.unmarshalling.XsdBinder");
+      
       ClassLoader tcl = Thread.currentThread().getContextClassLoader();
       SchemaBinding schema = XsdBinder.bind(tcl.getResourceAsStream(schemaFile), null);      
       Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
       config = (PolicyConfig) unmarshaller.unmarshal(tcl.getResourceAsStream(xmlFile), schema);
       assertNotNull(config); 
    } 
-   
-   public void testValidateJAASConfiguration()
-   {
-      ApplicationPolicy jaasConfig = config.get("conf-jaas");
-      BaseAuthenticationInfo authInfo = jaasConfig.getAuthenticationInfo();
-      List entries = authInfo.getModuleEntries();
-      assertEquals("Number of entries = 2", 2, entries.size());
-      
-      
-      //Second Entry 
-      AppConfigurationEntry entry = (AppConfigurationEntry) entries.get(1);
-      assertTrue("Entry instanceof AppConfigurationEntry", 
-            entry instanceof AppConfigurationEntry); 
-      AppConfigurationEntry ace = (AppConfigurationEntry)entry; 
-      assertEquals("LM Name","org.jboss.test.TestLoginModule2" ,ace.getLoginModuleName());
-      assertEquals("Optional expected", AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL,
-            ace.getControlFlag());
-   }
-   
-   public void testValidateJASPIConfiguration()
-   { 
-   }
-   
-   public void testValidateCompleteConfiguration()
-   { 
-   }  
 }

Modified: projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/security/config/SecurityConfigurationUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/security/config/SecurityConfigurationUnitTestCase.java	2007-08-15 20:08:58 UTC (rev 64610)
+++ projects/security/security-jboss-sx/trunk/src/tests/org/jboss/test/security/config/SecurityConfigurationUnitTestCase.java	2007-08-15 20:10:03 UTC (rev 64611)
@@ -29,7 +29,7 @@
 import java.util.Map;
 
 import javax.security.auth.login.AppConfigurationEntry;
- 
+
 import org.jboss.security.audit.config.AuditProviderEntry;
 import org.jboss.security.auth.container.config.AuthModuleEntry;
 import org.jboss.security.auth.login.BaseAuthenticationInfo;
@@ -47,11 +47,10 @@
 import org.jboss.security.config.PolicyConfig;
 import org.jboss.security.identitytrust.config.IdentityTrustModuleEntry;
 import org.jboss.security.mapping.config.MappingModuleEntry;
-import org.jboss.xb.binding.Unmarshaller; 
+import org.jboss.test.AbstractJBossSXTest;
+import org.jboss.xb.binding.Unmarshaller;
 import org.jboss.xb.binding.UnmarshallerFactory;
 
-import junit.framework.TestCase;
-
 //$Id$
 
 /**
@@ -60,15 +59,21 @@
  *  @since  Jul 25, 2007 
  *  @version $Revision$
  */
-public class SecurityConfigurationUnitTestCase extends TestCase
-{
+public class SecurityConfigurationUnitTestCase extends AbstractJBossSXTest
+{  
    protected String schemaFile = "schema/security-config_5_0.xsd";
    protected String xmlFile = "config/securityConfig5.xml";
    
    protected PolicyConfig config = null;
    
+   public SecurityConfigurationUnitTestCase(String name)
+   {
+      super(name); 
+   }
+   
    protected void setUp() throws Exception
-   {
+   { 
+      super.setUp();
       ClassLoader tcl = Thread.currentThread().getContextClassLoader();
       
       LoginConfigObjectModelFactory lcomf = new SecurityConfigObjectModelFactory();

Modified: projects/security/security-jboss-sx/trunk/src/tests/resources/config/securityConfig5.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/src/tests/resources/config/securityConfig5.xml	2007-08-15 20:08:58 UTC (rev 64610)
+++ projects/security/security-jboss-sx/trunk/src/tests/resources/config/securityConfig5.xml	2007-08-15 20:10:03 UTC (rev 64611)
@@ -2,8 +2,9 @@
  
 <policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="urn:jboss:security-config:5.0"
-         xmlns="urn:jboss:security-config:5.0">
-    <application-policy name = "conf-jaas"> 
+         xmlns="urn:jboss:security-config:5.0"
+         xmlns:jbxb="urn:jboss:security-config:5.0">
+   <application-policy name = "conf-jaas"> 
        <authentication>
           <login-module code = "org.jboss.test.TestLoginModule"
              flag = "required"> 
@@ -39,7 +40,7 @@
       </auth-module>  
       <auth-module code="TestAuthModule2" login-module-stack-ref="lm-stack"/>  
     </authentication-jaspi> 
-   </application-policy> 
+   </application-policy>  
    
    <application-policy name="conf-complete"> 
      <authentication>
@@ -78,6 +79,5 @@
              <module-option name = "dummy">dr</module-option> 
           </trust-module> 
        </identity-trust>
-   </application-policy> 
- 
+   </application-policy>  
 </policy> 




More information about the jboss-cvs-commits mailing list