You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2005/10/28 05:47:21 UTC
svn commit: r329071 - in /geronimo/trunk/modules/j2ee-schema/src:
java/org/apache/geronimo/schema/ test-data/geronimo/
test/org/apache/geronimo/schema/
Author: djencks
Date: Thu Oct 27 20:47:16 2005
New Revision: 329071
URL: http://svn.apache.org/viewcvs?rev=329071&view=rev
Log:
GERONIMO-890, GERONIMO-1114 Add backwards compatibility to new security schema, allow unnamespaced gbeans in j2ee plans
Added:
geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/ElementConverter.java
geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/GBeanElementConverter.java
geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/NamespaceElementConverter.java
geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SecurityElementConverter.java
geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/gbean-post.xml
geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/gbean-pre.xml
geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/security-post.xml
geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/security-pre.xml
Modified:
geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
geronimo/trunk/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
Added: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/ElementConverter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/ElementConverter.java?rev=329071&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/ElementConverter.java (added)
+++ geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/ElementConverter.java Thu Oct 27 20:47:16 2005
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.schema;
+
+import org.apache.xmlbeans.XmlCursor;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public interface ElementConverter {
+
+ void convertElement(XmlCursor start, XmlCursor work);
+}
Added: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/GBeanElementConverter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/GBeanElementConverter.java?rev=329071&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/GBeanElementConverter.java (added)
+++ geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/GBeanElementConverter.java Thu Oct 27 20:47:16 2005
@@ -0,0 +1,51 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.schema;
+
+import javax.xml.namespace.QName;
+
+import org.apache.xmlbeans.XmlCursor;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class GBeanElementConverter implements ElementConverter {
+
+ private static final String GERONIMO_SERVICE_NAMESPACE = "http://geronimo.apache.org/xml/ns/deployment-1.0";
+
+
+ public void convertElement(XmlCursor cursor, XmlCursor end) {
+ end.toCursor(cursor);
+ end.toEndToken();
+ while (cursor.hasNextToken() && cursor.isLeftOf(end)) {
+ if (cursor.isStart()) {
+ if (GERONIMO_SERVICE_NAMESPACE.equals(cursor.getName().getNamespaceURI())) {
+ //already has correct schema, exit
+ return;
+ }
+ String localPart = cursor.getName().getLocalPart();
+ if (localPart.equals("xml-attribute") || localPart.equals("xml-reference")) {
+ cursor.toEndToken();
+ } else {
+ cursor.setName(new QName(GERONIMO_SERVICE_NAMESPACE, localPart));
+ }
+ }
+ //this should not break because the xml-* elements are never top level.
+ cursor.toNextToken();
+ }
+ }
+}
Added: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/NamespaceElementConverter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/NamespaceElementConverter.java?rev=329071&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/NamespaceElementConverter.java (added)
+++ geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/NamespaceElementConverter.java Thu Oct 27 20:47:16 2005
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.schema;
+
+import javax.xml.namespace.QName;
+
+import org.apache.xmlbeans.XmlCursor;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class NamespaceElementConverter implements ElementConverter {
+
+ private final String namespace;
+
+ public NamespaceElementConverter(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public void convertElement(XmlCursor cursor, XmlCursor end) {
+ end.toCursor(cursor);
+ end.toEndToken();
+ while (cursor.hasNextToken() && cursor.isLeftOf(end)) {
+ if (cursor.isStart()) {
+ if (namespace.equals(cursor.getName().getNamespaceURI())) {
+ //already has correct schema, exit
+ return;
+ }
+ cursor.setName(new QName(namespace, cursor.getName().getLocalPart()));
+ }
+ cursor.toNextToken();
+ }
+ }
+}
Modified: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java?rev=329071&r1=329070&r2=329071&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java (original)
+++ geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java Thu Oct 27 20:47:16 2005
@@ -17,28 +17,23 @@
package org.apache.geronimo.schema;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Map;
import java.util.HashMap;
-import java.net.URL;
+import java.util.Map;
import javax.xml.namespace.QName;
+import org.apache.geronimo.xbeans.j2ee.ApplicationClientDocument;
import org.apache.geronimo.xbeans.j2ee.ApplicationDocument;
+import org.apache.geronimo.xbeans.j2ee.ConnectorDocument;
import org.apache.geronimo.xbeans.j2ee.EjbJarDocument;
import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
-import org.apache.geronimo.xbeans.j2ee.ApplicationClientDocument;
-import org.apache.geronimo.xbeans.j2ee.ConnectorDocument;
+import org.apache.xmlbeans.SchemaType;
import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlDocumentProperties;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlDocumentProperties;
-import org.w3c.dom.Element;
/**
* @version $Rev$ $Date$
@@ -58,24 +53,24 @@
static {
- GERONIMO_SCHEMA_CONVERSIONS.put("ejb-ref", GERONIMO_NAMING_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("ejb-local-ref", GERONIMO_NAMING_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("service-ref", GERONIMO_NAMING_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("resource-ref", GERONIMO_NAMING_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("resource-env-ref", GERONIMO_NAMING_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("cmp-connection-factory", GERONIMO_NAMING_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("workmanager", GERONIMO_NAMING_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("resource-adapter", GERONIMO_NAMING_NAMESPACE);
-
- GERONIMO_SCHEMA_CONVERSIONS.put("security", GERONIMO_SECURITY_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("default-principal", GERONIMO_SECURITY_NAMESPACE);
-
- GERONIMO_SCHEMA_CONVERSIONS.put("gbean", GERONIMO_SERVICE_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("import", GERONIMO_SERVICE_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("hidden-classes", GERONIMO_SERVICE_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("non-overridable-classes", GERONIMO_SERVICE_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("dependency", GERONIMO_SERVICE_NAMESPACE);
- GERONIMO_SCHEMA_CONVERSIONS.put("include", GERONIMO_SERVICE_NAMESPACE);
+ GERONIMO_SCHEMA_CONVERSIONS.put("ejb-ref", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));
+ GERONIMO_SCHEMA_CONVERSIONS.put("ejb-local-ref", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));
+ GERONIMO_SCHEMA_CONVERSIONS.put("service-ref", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));
+ GERONIMO_SCHEMA_CONVERSIONS.put("resource-ref", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));
+ GERONIMO_SCHEMA_CONVERSIONS.put("resource-env-ref", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));
+ GERONIMO_SCHEMA_CONVERSIONS.put("cmp-connection-factory", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));
+ GERONIMO_SCHEMA_CONVERSIONS.put("workmanager", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));
+ GERONIMO_SCHEMA_CONVERSIONS.put("resource-adapter", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));
+
+ GERONIMO_SCHEMA_CONVERSIONS.put("security", new SecurityElementConverter());
+ GERONIMO_SCHEMA_CONVERSIONS.put("default-principal", new NamespaceElementConverter(GERONIMO_SECURITY_NAMESPACE));
+
+ GERONIMO_SCHEMA_CONVERSIONS.put("gbean", new GBeanElementConverter());
+ GERONIMO_SCHEMA_CONVERSIONS.put("import", new NamespaceElementConverter(GERONIMO_SERVICE_NAMESPACE));
+ GERONIMO_SCHEMA_CONVERSIONS.put("hidden-classes", new NamespaceElementConverter(GERONIMO_SERVICE_NAMESPACE));
+ GERONIMO_SCHEMA_CONVERSIONS.put("non-overridable-classes", new NamespaceElementConverter(GERONIMO_SERVICE_NAMESPACE));
+ GERONIMO_SCHEMA_CONVERSIONS.put("dependency", new NamespaceElementConverter(GERONIMO_SERVICE_NAMESPACE));
+ GERONIMO_SCHEMA_CONVERSIONS.put("include", new NamespaceElementConverter(GERONIMO_SERVICE_NAMESPACE));
}
private SchemaConversionUtils() {
@@ -334,9 +329,9 @@
while (cursor.hasNextToken()) {
if (cursor.isStart()) {
String localName = cursor.getName().getLocalPart();
- String namespace = (String) GERONIMO_SCHEMA_CONVERSIONS.get(localName);
- if (namespace != null) {
- convertElementToSchema(cursor, end, namespace);
+ ElementConverter converter = (ElementConverter) GERONIMO_SCHEMA_CONVERSIONS.get(localName);
+ if (converter != null) {
+ converter.convertElement(cursor, end);
}
}
cursor.toNextToken();
@@ -435,24 +430,6 @@
cursor.insertAttributeWithValue(new QName("version"), version);
isFirstStart = false;
}
- } else {
- cursor.toNextToken();
- }
- }
- return true;
- }
-
- public static boolean convertElementToSchema(XmlCursor cursor, XmlCursor end, String namespace) {
- end.toCursor(cursor);
- end.toEndToken();
- while (cursor.hasNextToken() && cursor.isLeftOf(end)) {
- if (cursor.isStart()) {
- if (namespace.equals(cursor.getName().getNamespaceURI())) {
- //already has correct schema, exit
- return false;
- }
- cursor.setName(new QName(namespace, cursor.getName().getLocalPart()));
- cursor.toNextToken();
} else {
cursor.toNextToken();
}
Added: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SecurityElementConverter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SecurityElementConverter.java?rev=329071&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SecurityElementConverter.java (added)
+++ geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SecurityElementConverter.java Thu Oct 27 20:47:16 2005
@@ -0,0 +1,75 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.schema;
+
+import javax.xml.namespace.QName;
+
+import org.apache.xmlbeans.XmlCursor;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class SecurityElementConverter implements ElementConverter {
+
+ public static final String GERONIMO_SECURITY_NAMESPACE = "http://geronimo.apache.org/xml/ns/security-1.1";
+ private static final QName PRINCIPAL_QNAME = new QName(GERONIMO_SECURITY_NAMESPACE, "principal");
+ private static final QName REALM_NAME_QNAME = new QName("realm-name");
+
+ public void convertElement(XmlCursor cursor, XmlCursor end) {
+ cursor.push();
+ end.toCursor(cursor);
+ end.toEndToken();
+ while (cursor.hasNextToken() && cursor.isLeftOf(end)) {
+ if (cursor.isStart()) {
+ if (GERONIMO_SECURITY_NAMESPACE.equals(cursor.getName().getNamespaceURI())) {
+ break;
+ }
+ cursor.setName(new QName(GERONIMO_SECURITY_NAMESPACE, cursor.getName().getLocalPart()));
+
+ }
+ cursor.toNextToken();
+ }
+ cursor.pop();
+ while (cursor.hasNextToken() && cursor.isLeftOf(end)) {
+ if (cursor.isStart()) {
+ String localPart = cursor.getName().getLocalPart();
+ if (localPart.equals("realm")) {
+ XmlCursor source = cursor.newCursor();
+ cursor.push();
+ cursor.toEndToken();
+ cursor.toNextToken();
+ try {
+ if (source.toChild(PRINCIPAL_QNAME)) {
+ do {
+ source.copyXmlContents(cursor);
+ } while (source.toNextSibling(PRINCIPAL_QNAME));
+ }
+
+ } finally {
+ source.dispose();
+ }
+ cursor.pop();
+ cursor.removeXml();
+ } else if (localPart.equals("default-principal")) {
+ cursor.removeAttribute(REALM_NAME_QNAME);
+ }
+ }
+ cursor.toNextToken();
+ }
+
+ }
+}
Added: geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/gbean-post.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/gbean-post.xml?rev=329071&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/gbean-post.xml (added)
+++ geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/gbean-post.xml Thu Oct 27 20:47:16 2005
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<gbean name="client-properties-realm"
+ class="org.apache.geronimo.security.realm.GenericSecurityRealm" xmlns="http://geronimo.apache.org/xml/ns/deployment-1.0">
+ <attribute name="realmName">client-properties-realm</attribute>
+ <xml-reference name="LoginModuleConfiguration">
+ <lc:login-config xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig">
+ <lc:login-module control-flag="REQUIRED" server-side="true">
+ <lc:login-domain-name>client-properties-realm</lc:login-domain-name>
+ <lc:login-module-class>org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule</lc:login-module-class>
+ <lc:option name="usersURI">var/security/users.properties</lc:option>
+ <lc:option name="groupsURI">var/security/groups.properties</lc:option>
+ </lc:login-module>
+ <lc:login-module control-flag="REQUIRED" server-side="true">
+ <lc:login-domain-name>default</lc:login-domain-name>
+ <lc:login-module-class>org.apache.geronimo.security.jaas.NamedUPCredentialLoginModule</lc:login-module-class>
+ <lc:option name="org.apache.geronimo.jaas.NamedUPCredentialLoginModule.Name">default</lc:option>
+ </lc:login-module>
+ </lc:login-config>
+ </xml-reference>
+ <xml-attribute name="nssConfig">
+ <css:css xmlns:css="http://www.openejb.org/xml/ns/corba-css-config-2.0">
+ <css:compoundSecMechTypeList>
+ <css:compoundSecMech>
+ <css:SSL>
+ <css:supports>Integrity Confidentiality EstablishTrustInTarget EstablishTrustInClient</css:supports>
+ <css:requires></css:requires>
+ </css:SSL>
+ </css:compoundSecMech>
+ </css:compoundSecMechTypeList>
+ </css:css>
+ </xml-attribute>
+ <reference name="ServerInfo">
+ <module>org/apache/geronimo/ClientSystem</module>
+ <name>ServerInfo</name>
+ </reference>
+ <reference name="LoginService">
+ <name>JaasLoginService</name>
+ </reference>
+</gbean>
Added: geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/gbean-pre.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/gbean-pre.xml?rev=329071&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/gbean-pre.xml (added)
+++ geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/gbean-pre.xml Thu Oct 27 20:47:16 2005
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<gbean name="client-properties-realm"
+ class="org.apache.geronimo.security.realm.GenericSecurityRealm">
+ <attribute name="realmName">client-properties-realm</attribute>
+ <xml-reference name="LoginModuleConfiguration">
+ <lc:login-config xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig">
+ <lc:login-module control-flag="REQUIRED" server-side="true">
+ <lc:login-domain-name>client-properties-realm</lc:login-domain-name>
+ <lc:login-module-class>org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule</lc:login-module-class>
+ <lc:option name="usersURI">var/security/users.properties</lc:option>
+ <lc:option name="groupsURI">var/security/groups.properties</lc:option>
+ </lc:login-module>
+ <lc:login-module control-flag="REQUIRED" server-side="true">
+ <lc:login-domain-name>default</lc:login-domain-name>
+ <lc:login-module-class>org.apache.geronimo.security.jaas.NamedUPCredentialLoginModule</lc:login-module-class>
+ <lc:option name="org.apache.geronimo.jaas.NamedUPCredentialLoginModule.Name">default</lc:option>
+ </lc:login-module>
+ </lc:login-config>
+ </xml-reference>
+ <xml-attribute name="nssConfig">
+ <css:css xmlns:css="http://www.openejb.org/xml/ns/corba-css-config-2.0">
+ <css:compoundSecMechTypeList>
+ <css:compoundSecMech>
+ <css:SSL>
+ <css:supports>Integrity Confidentiality EstablishTrustInTarget EstablishTrustInClient</css:supports>
+ <css:requires></css:requires>
+ </css:SSL>
+ </css:compoundSecMech>
+ </css:compoundSecMechTypeList>
+ </css:css>
+ </xml-attribute>
+ <reference name="ServerInfo">
+ <module>org/apache/geronimo/ClientSystem</module>
+ <name>ServerInfo</name>
+ </reference>
+ <reference name="LoginService">
+ <name>JaasLoginService</name>
+ </reference>
+</gbean>
Added: geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/security-post.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/security-post.xml?rev=329071&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/security-post.xml (added)
+++ geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/security-post.xml Thu Oct 27 20:47:16 2005
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<security xmlns="http://geronimo.apache.org/xml/ns/security-1.1">
+ <default-principal>
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="supplier"/>
+ </default-principal>
+ <role-mappings>
+ <role role-name="administrator">
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="supplier"/>
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="buyer"/>
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="x"/>
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="y"/>
+ </role>
+ </role-mappings>
+</security>
Added: geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/security-pre.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/security-pre.xml?rev=329071&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/security-pre.xml (added)
+++ geronimo/trunk/modules/j2ee-schema/src/test-data/geronimo/security-pre.xml Thu Oct 27 20:47:16 2005
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<security>
+ <default-principal realm-name="petstore-realm">
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="supplier"/>
+ </default-principal>
+ <role-mappings>
+ <role role-name="administrator">
+ <realm realm-name="petstore-realm">
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="supplier"/>
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="buyer"/>
+ </realm>
+ <realm realm-name="foo-realm">
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="x"/>
+ <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal" name="y"/>
+ </realm>
+ </role>
+ </role-mappings>
+</security>
Modified: geronimo/trunk/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java?rev=329071&r1=329070&r2=329071&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java (original)
+++ geronimo/trunk/modules/j2ee-schema/src/test/org/apache/geronimo/schema/SchemaConversionUtilsTest.java Thu Oct 27 20:47:16 2005
@@ -390,6 +390,54 @@
// System.out.println(xmlObject.toString());
}
+ public void testSecurityElementConverter() throws Exception {
+ File srcXml = new File(basedir, "src/test-data/geronimo/security-pre.xml");
+ File expectedOutputXml = new File(basedir, "src/test-data/geronimo/security-post.xml");
+ XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+ ElementConverter elementConverter = new SecurityElementConverter();
+ XmlCursor cursor = xmlObject.newCursor();
+ XmlCursor end = cursor.newCursor();
+ try {
+ elementConverter.convertElement(cursor, end);
+ // System.out.println(xmlObject.toString());
+ XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+ List problems = new ArrayList();
+ boolean ok = compareXmlObjects(xmlObject, expected, problems);
+ assertTrue("Differences: " + problems, ok);
+ SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+ boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+ assertTrue("Differences: " + problems, ok2);
+ } finally {
+ cursor.dispose();
+ end.dispose();
+ }
+
+ }
+
+ public void testGBeanElementConverter() throws Exception {
+ File srcXml = new File(basedir, "src/test-data/geronimo/gbean-pre.xml");
+ File expectedOutputXml = new File(basedir, "src/test-data/geronimo/gbean-post.xml");
+ XmlObject xmlObject = XmlObject.Factory.parse(srcXml);
+ ElementConverter elementConverter = new GBeanElementConverter();
+ XmlCursor cursor = xmlObject.newCursor();
+ XmlCursor end = cursor.newCursor();
+ try {
+ elementConverter.convertElement(cursor, end);
+ // System.out.println(xmlObject.toString());
+ XmlObject expected = XmlObject.Factory.parse(expectedOutputXml);
+ List problems = new ArrayList();
+ boolean ok = compareXmlObjects(xmlObject, expected, problems);
+ assertTrue("Differences: " + problems, ok);
+ SchemaConversionUtils.convertToGeronimoSubSchemas(cursor);
+ boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
+ assertTrue("Differences: " + problems, ok2);
+ } finally {
+ cursor.dispose();
+ end.dispose();
+ }
+
+ }
+
private boolean compareXmlObjects(XmlObject xmlObject, XmlObject expectedObject, List problems) {
XmlCursor test = xmlObject.newCursor();
XmlCursor expected = expectedObject.newCursor();