Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 12129 invoked from network); 2 Jul 2007 18:31:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jul 2007 18:31:13 -0000 Received: (qmail 60467 invoked by uid 500); 2 Jul 2007 18:31:13 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 60426 invoked by uid 500); 2 Jul 2007 18:31:13 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 60406 invoked by uid 99); 2 Jul 2007 18:31:13 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2007 11:31:13 -0700 X-ASF-Spam-Status: No, hits=-97.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME,URI_NOVOWEL X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2007 11:31:03 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 4C3AC1A9825; Mon, 2 Jul 2007 11:30:43 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r552557 [4/6] - in /geronimo/sandbox/j2g/plugins: org.apache.geronimo.j2g.descriptors.app/ org.apache.geronimo.j2g.descriptors.cmp/ org.apache.geronimo.j2g.descriptors.ejb/ org.apache.geronimo.j2g.descriptors.web/ org.apache.geronimo.j2g.de... Date: Mon, 02 Jul 2007 18:30:40 -0000 To: scm@geronimo.apache.org From: pmcmahan@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070702183043.4C3AC1A9825@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/security/SecurityResourcesTool.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/security/SecurityResourcesTool.java?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/security/SecurityResourcesTool.java (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/src/org/apache/geronimo/j2g/resources/security/SecurityResourcesTool.java Mon Jul 2 11:30:34 2007 @@ -0,0 +1,575 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.j2g.resources.security; + +import java.io.File; +import java.io.IOException; +import java.util.Iterator; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.j2g.common.IFileMigration; +import org.apache.geronimo.j2g.common.IOutput; +import org.apache.geronimo.j2g.common.Tool; +import org.apache.geronimo.j2g.util.resources.Constants; +import org.apache.geronimo.j2g.util.resources.xml.XMLConversionHelper; +import org.dom4j.Attribute; +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.Namespace; +import org.dom4j.QName; + +/** + * Class which implement the Security Resource File Migration + */ +public class SecurityResourcesTool implements IFileMigration { + + // Initialization of the IOutput for SecurityResourcesTool class + IOutput out = Tool.getCurrent().getOutput(); + // Initialization of the logger for SecurityResourcesTool class + Log logger = LogFactory.getLog(SecurityResourcesTool.class); + + /** + * mgration method from data source jboss discripters to geronimo + * discriptors + * + * @param sourceFile :data source jboss discriptor file + * @return status of the migration + */ + public boolean migrate(File sourceFile) { + // read the login-config.xml file and then make the changes to the + // geronimo side + boolean migrated = false; + String fileName = sourceFile.getPath(); + String directoryName = fileName.substring(0, fileName.lastIndexOf(File.separator)); + String jbossSecirityFileName = sourceFile.getName(); + logger.debug("Directory Name ==> " + directoryName); + logger.debug("jboss security file Name ==> " + jbossSecirityFileName); + // Checking wether file is a valid login-config.xml file + if (jbossSecirityFileName.equals(Constants.JBOSS_VALID_SECURITY_XML_FILE)) { + out.info("Converting Jboss login-config.xml file in " + directoryName); + try { + Document jbossDocument = XMLConversionHelper.getJbossDocument(sourceFile); + Document geronimoDocument = migrationFromJboss2Geronimo(jbossDocument + .getRootElement()); + String geronimoSecurityFileName = directoryName + File.separator + + Constants.GERONIMO_SECURITY_PLAN_FILE; + // Check whether the file already exists if so back up + // that and save that or check the req + // This was done at upper level of the tool + XMLConversionHelper.saveGeronimoDocument(geronimoSecurityFileName, + geronimoDocument); + migrated = true; + out.info("The Security Resource File Migration Complete !!!\n"); + } catch (DocumentException e) { + out.error("Errors occurs while reading xml descriptor " + + sourceFile.getAbsolutePath() + + ". It is possible that the migrator cannot download an xml schema or xml file has a wrong syntax. Nested exception:" + + e.getMessage()); + } catch (IOException e) { + out.error("IO exception " + e.getMessage()); + } + } + + return migrated; + } + + /** + * Accepts the jboss side Elements that holdes the discripter infomation and + * return the geronimo discripter + * + * @param jbossRootElement + * @return geronimo plan + */ + private Document migrationFromJboss2Geronimo(Element jbossRootElement) { + Document geronimoDocument = XMLConversionHelper.createNewGeronimoDocument( + Constants.NAMESPACE_ENV, "module", Constants.SECURITY_RESOURCE_TOOL, "", ""); + Document geronimoNewDocument = createGBeanElement(jbossRootElement, geronimoDocument); + return geronimoNewDocument; + } + + /** + * Create the GBeanElement by refering the jboss side elamanets + * + * @param jbossRootElement + * @param geronimoDocument + * @return geronimo security plan which contains the GBean Element + */ + private Document createGBeanElement(Element jbossRootElement, Document geronimoDocument) { + Namespace rootNamespace = geronimoDocument.getRootElement().getNamespace(); + Element gbeanElement = DocumentHelper.createElement(new QName("gbean", rootNamespace)); + gbeanElement.add(DocumentHelper.createAttribute(gbeanElement, "name", "SecurityRealm")); + gbeanElement.add(DocumentHelper.createAttribute(gbeanElement, "class", + "org.apache.geronimo.security.realm.GenericSecurityRealm")); + Element attributeElement = DocumentHelper.createElement(new QName("attribute", + rootNamespace)); + attributeElement.add(DocumentHelper.createAttribute(gbeanElement, "name", "realmName")); + attributeElement.addText("SecurityRealm"); + gbeanElement.add(createReferenceElement("ServerInfo", "ServerInfo", rootNamespace)); + gbeanElement.add(createReferenceElement("LoginService", "JaasLoginService", rootNamespace)); + Element xml_referenceElement = DocumentHelper.createElement(new QName("xml-reference", + rootNamespace)); + xml_referenceElement.add(DocumentHelper.createAttribute(xml_referenceElement, "name", + "LoginModuleConfiguration")); + Element loginConfigElement = createLoginConfigElement(); + Element newLoginConfigElement = createLoginModulesByReferingJbossDocument( + loginConfigElement, jbossRootElement); + xml_referenceElement.add(newLoginConfigElement); + gbeanElement.add(xml_referenceElement); + geronimoDocument.getRootElement().add(gbeanElement); + return geronimoDocument; + } + + /** + * create the reference element + * + * @param name + * @param contain + * @param rootNamespace + * @return return the reference element + */ + private Element createReferenceElement(String name, String contain, Namespace rootNamespace) { + Element referenceElement = DocumentHelper.createElement(new QName("reference", + rootNamespace)); + referenceElement.add(DocumentHelper.createAttribute(referenceElement, "name", name)); + Element nameElement = DocumentHelper.createElement(new QName("name", rootNamespace)); + nameElement.addText(contain); + referenceElement.add(nameElement); + return referenceElement; + + } + + /** + * create the login config elament + * + * @return login config element + */ + private Element createLoginConfigElement() { + Namespace loginNamespace = new Namespace("log", Constants.NAMESPACE_GERONIMO_LOGGIN); + Element login_configElement = DocumentHelper.createElement(new QName("login-config", + loginNamespace)); + return login_configElement; + } + + /** + * create the login module by referencing the jboss document + * + * @param loginConfigElement + * @param jbossRootElement + * @return the login module + */ + private Element createLoginModulesByReferingJbossDocument(Element loginConfigElement, + Element jbossRootElement) { + String login_domain_name = null; + String control_flag = null; + String login_module_class = null; + Element login_moduleElement = null; + Iterator elementIterator = jbossRootElement.elementIterator(); + while (elementIterator.hasNext()) { + Element itElement = (Element) elementIterator.next(); + if (itElement.getName().equals("application-policy")) { + out.info("Starting Module Migration"); + if (validateSecurityPolicy(itElement)) { + login_domain_name = obtainLoginDomainName(itElement); + if (XMLConversionHelper.containSubElement(itElement, "authentication")) { + Element authenticationElement = XMLConversionHelper.obtainSubElement( + itElement, "authentication"); + if (XMLConversionHelper.containSubElement(authenticationElement, + "login-module")) { + login_moduleElement = XMLConversionHelper.obtainSubElement( + authenticationElement, "login-module"); + control_flag = obtainControlFlagFromLoginModuleElement(login_moduleElement); + login_module_class = obtainLoginModuleClassFromLoginModuleElement(login_moduleElement); + } + } + Element geronimo_login_moduleElement = createLoginModuleElementbyReferingJbossApplicationPolicyElement( + login_moduleElement, loginConfigElement, control_flag, + login_domain_name, login_module_class); + loginConfigElement.add(geronimo_login_moduleElement); + out.info("Finishing Module Migration"); + } else { + out.error("The security resource conversion tool does not support module functionality"); + out.info("Finishing Module Migration"); + } + } + } + return loginConfigElement; + } + + /** + * return the login module class from the login module element + * + * @param login_moduleElement + * @return String version of the login module class + */ + private String obtainLoginModuleClassFromLoginModuleElement(Element login_moduleElement) { + String login_module_class = null; + Iterator attribIterator = login_moduleElement.attributeIterator(); + while (attribIterator.hasNext()) { + Attribute itAttribute = (Attribute) attribIterator.next(); + if (itAttribute.getName().equals("code")) { + login_module_class = itAttribute.getText(); + if (login_module_class.equals(Constants.JBOSS_LOGIN_MODULE_IDELTITY)) { + return Constants.GERONIMO_LOGIN_MODULE_IDELTITY; + } else if (login_module_class.equals(Constants.JBOSS_LOGIN_MODULE_LDAP)) { + return Constants.GERONIMO_LOGIN_MODULE_LDAP; + } else if (login_module_class.equals(Constants.JBOSS_LOGIN_MODULE_DATABASE_SERVER)) { + return Constants.GERONIMO_LOGIN_MODULE_DATABASE_SERVER; + } else if (login_module_class.equals(Constants.JBOSS_LOGIN_MODULE_USERS_ROLES)) { + return Constants.GERONIMO_LOGIN_MODULE_USERS_ROLES; + } + } + } + return login_module_class; + } + + /** + * obtain the login domain name from the element + * + * @param application_policyElement + * @return String version of the login domain name + */ + private String obtainLoginDomainName(Element application_policyElement) { + String login_domain_name = null; + Iterator attribIterator = application_policyElement.attributeIterator(); + while (attribIterator.hasNext()) { + Attribute itAttribute = (Attribute) attribIterator.next(); + if (itAttribute.getName().equals("name")) { + login_domain_name = itAttribute.getText(); + } + } + return login_domain_name; + } + + /** + * creates the mudule elements by referencing the jboss side apllication + * policy elamentsS + * + * @param jbossLoginModuleElement + * @param geronimoLoginConfigElement + * @param control_flag + * @param login_domain_name + * @param login_module_class + * @return login module element + */ + private Element createLoginModuleElementbyReferingJbossApplicationPolicyElement( + Element jbossLoginModuleElement, Element geronimoLoginConfigElement, + String control_flag, String login_domain_name, String login_module_class) { + Element login_moduleElement = DocumentHelper.createElement(new QName("login-module", + geronimoLoginConfigElement.getNamespace())); + login_moduleElement.add(DocumentHelper.createAttribute(login_moduleElement, "control-flag", + control_flag.toUpperCase())); + // Adding this defaults + login_moduleElement.add(DocumentHelper.createAttribute(login_moduleElement, "server-side", + "true")); + login_moduleElement.add(DocumentHelper.createAttribute(login_moduleElement, + "wrap-principals", "false")); + login_moduleElement.add(XMLConversionHelper.createSibling("login-domain-name", + login_domain_name, geronimoLoginConfigElement.getNamespace())); + login_moduleElement.add(XMLConversionHelper.createSibling("login-module-class", + login_module_class, geronimoLoginConfigElement.getNamespace())); + if (XMLConversionHelper.containSubElement(jbossLoginModuleElement, "module-option")) { + login_moduleElement = addAppropriateOptionToAppropriateLoginModule( + jbossLoginModuleElement, login_moduleElement, login_module_class); + } + return login_moduleElement; + } + + /** + * adding the appropriate options for the appropriate login modules + * + * @param jbossLoginModuleElement + * @param geronimoLoginmoduleElement + * @param login_module_class + * @return returns the login module + */ + private Element addAppropriateOptionToAppropriateLoginModule(Element jbossLoginModuleElement, + Element geronimoLoginmoduleElement, String login_module_class) { + String option_value = null; + String option_attrib_name_value = null; + Element[] extraOptionsElement = new Element[4]; + int countIterations = 0; + Iterator elementIterator = jbossLoginModuleElement.elementIterator(); + while (elementIterator.hasNext()) { + Element itElement = (Element) elementIterator.next(); + if (itElement.getName().equals("module-option")) { + option_value = itElement.getText(); + Iterator attribIterator = itElement.attributeIterator(); + while (attribIterator.hasNext()) { + Attribute itAttribute = (Attribute) attribIterator.next(); + if (itAttribute.getName().equals("name")) { + option_attrib_name_value = itAttribute.getText(); + } + } + Element optionElement = null; + if (login_module_class.equals(Constants.GERONIMO_LOGIN_MODULE_DATABASE_SERVER)) { + if (option_attrib_name_value.equals("principalsQuery")) { + option_attrib_name_value = "userSelect"; + } + if (option_attrib_name_value.equals("rolesQuery")) { + option_attrib_name_value = "groupSelect"; + } + if (option_attrib_name_value.equals("dsJndiName")) { + option_attrib_name_value = "dataSourceName"; + // This is to be modified to the algorithm that + // cuts only the last tocken + option_value = option_value.substring(option_value.indexOf(File.separator) + 1, + option_value.length()); + } + if (!(option_attrib_name_value.equals("unauthenticatedIdentity"))) { + optionElement = XMLConversionHelper.createSiblingWithAttrib("option", + option_value, "name", option_attrib_name_value, + geronimoLoginmoduleElement.getNamespace()); + } + } + // No Need , because of no Geronimo side support + // else if + // (login_module_class.equals(Constants.GERONIMO_LOGIN_MODULE_IDELTITY)){ + // optionElement = + // XMLConversionHelper.createSiblingWithAttrib("option", + // option_value, "name", option_attrib_name_value, + // geronimoLoginmoduleElement.getNamespace()); + // } + else if (login_module_class.equals(Constants.GERONIMO_LOGIN_MODULE_LDAP)) { + + if (option_attrib_name_value.equals("java.naming.factory.initial")) { + option_attrib_name_value = "initialContextFactory"; + optionElement = XMLConversionHelper.createSiblingWithAttrib("option", + option_value, "name", option_attrib_name_value, + geronimoLoginmoduleElement.getNamespace()); + } + if (option_attrib_name_value.equals("java.naming.provider.url")) { + String connectionURLString = "ldap://localhost:"; + if (XMLConversionHelper.containSubElementWithAttribute( + jbossLoginModuleElement, "module-option", "name", + "java.naming.security.protocol")) { + Element securityProtocolElement = XMLConversionHelper + .obtainSubElementWithAttribute(jbossLoginModuleElement, + "module-option", "name", + "java.naming.security.protocol"); + String securityProtocolElementString = securityProtocolElement + .getText(); + if (securityProtocolElementString.equals("ssl")) { + connectionURLString += "636"; + } else { + connectionURLString += "389"; + } + } + option_attrib_name_value = "connectionURL"; + option_value = connectionURLString; + optionElement = XMLConversionHelper.createSiblingWithAttrib("option", + option_value, "name", option_attrib_name_value, + geronimoLoginmoduleElement.getNamespace()); + } + if (option_attrib_name_value.equals("java.naming.security.protocol")) { + option_attrib_name_value = "connectionProtocol"; + optionElement = XMLConversionHelper.createSiblingWithAttrib("option", + option_value, "name", option_attrib_name_value, + geronimoLoginmoduleElement.getNamespace()); + } + if (option_attrib_name_value.equals("java.naming.security.authentication")) { + option_attrib_name_value = "authentication"; + optionElement = XMLConversionHelper.createSiblingWithAttrib("option", + option_value, "name", option_attrib_name_value, + geronimoLoginmoduleElement.getNamespace()); + } + if (option_attrib_name_value.equals("roleAttributeID")) { + option_attrib_name_value = "roleName"; + option_value = "roles"; + optionElement = XMLConversionHelper.createSiblingWithAttrib("option", + option_value, "name", option_attrib_name_value, + geronimoLoginmoduleElement.getNamespace()); + } + if (option_attrib_name_value.equals("java.naming.security.protocol")) { + option_attrib_name_value = "connectionProtocol"; + optionElement = XMLConversionHelper.createSiblingWithAttrib("option", + option_value, "name", option_attrib_name_value, + geronimoLoginmoduleElement.getNamespace()); + } + if (option_attrib_name_value.equals("principalDNPrefix")) { + if (XMLConversionHelper.containSubElementWithAttribute( + jbossLoginModuleElement, "module-option", "name", + "principalDNSuffix")) { + Element principalDNSuffixElement = XMLConversionHelper + .obtainSubElementWithAttribute(jbossLoginModuleElement, + "module-option", "name", "principalDNSuffix"); + String principalDNSuffixElementString = principalDNSuffixElement + .getText(); + if (principalDNSuffixElementString != null) { + // option_value+=principalDNSuffixElementString.substring(0, + // principalDNSuffixElementString.indexOf(",")); + option_value += "{0}" + principalDNSuffixElementString; + } else { + option_value += "{0}"; + } + } + option_attrib_name_value = "userSearchMatching"; + optionElement = XMLConversionHelper.createSiblingWithAttrib("option", + option_value, "name", option_attrib_name_value, + geronimoLoginmoduleElement.getNamespace()); + } + if (option_attrib_name_value.equals("rolesCtxDN")) { + option_attrib_name_value = "roleSearchMatching"; + if (XMLConversionHelper.containSubElementWithAttribute( + jbossLoginModuleElement, "module-option", "name", "matchOnUserDN")) { + Element matchOnUserDNElement = XMLConversionHelper + .obtainSubElementWithAttribute(jbossLoginModuleElement, + "module-option", "name", "matchOnUserDN"); + String matchOnUserDNString = matchOnUserDNElement.getText(); + if (XMLConversionHelper.containSubElementWithAttribute( + jbossLoginModuleElement, "module-option", "name", + "matchOnUserDN")) { + Element uidAttributeIDElement = XMLConversionHelper + .obtainSubElementWithAttribute(jbossLoginModuleElement, + "module-option", "name", "uidAttributeID"); + String uidAttributeIDString = uidAttributeIDElement.getText(); + // String first_part_of_option_value = + // option_value.substring(0, + // option_value.indexOf(",")); + // String secoend_part_of_option_value = + // first_part_of_option_value.substring(0, + // option_value.indexOf(",")); + String first_part_of_option_value = "{0}"; + String secoend_part_of_option_value = "{1}"; + option_value = option_value + + "???(" + + uidAttributeIDString + + "=" + + (matchOnUserDNString.equals("true") ? first_part_of_option_value + : secoend_part_of_option_value) + ")"; + } + } + optionElement = XMLConversionHelper.createSiblingWithAttrib("option", + option_value, "name", option_attrib_name_value, + geronimoLoginmoduleElement.getNamespace()); + } + extraOptionsElement[0] = XMLConversionHelper.createSiblingWithAttrib("option", + "", "name", "userBase", geronimoLoginmoduleElement.getNamespace()); + extraOptionsElement[1] = XMLConversionHelper.createSiblingWithAttrib("option", + "", "name", "roleBase", geronimoLoginmoduleElement.getNamespace()); + extraOptionsElement[2] = XMLConversionHelper.createSiblingWithAttrib("option", + "true", "name", "userSearchSubtree", geronimoLoginmoduleElement + .getNamespace()); + extraOptionsElement[3] = XMLConversionHelper.createSiblingWithAttrib("option", + "true", "name", "roleSearchSubtree", geronimoLoginmoduleElement + .getNamespace()); + } else if (login_module_class.equals(Constants.GERONIMO_LOGIN_MODULE_USERS_ROLES)) { + if (option_attrib_name_value.equals("usersProperties")) { + option_attrib_name_value = "usersURI"; + option_value = Constants.USER_PROPERTIES_FILE_PATH; + out + .info("Sesurity Resources Tool Assumes user properties are in location =>" + + Constants.USER_PROPERTIES_FILE_PATH); + } + if (option_attrib_name_value.equals("rolesProperties")) { + option_attrib_name_value = "groupsURI"; + option_value = Constants.GROUP_PROPERTIES_FILE_PATH; + out + .info("Sesurity Resources Tool Assumes groups properties are in location =>" + + Constants.GROUP_PROPERTIES_FILE_PATH); + } + optionElement = XMLConversionHelper.createSiblingWithAttrib("option", + option_value, "name", option_attrib_name_value, + geronimoLoginmoduleElement.getNamespace()); + } + if (optionElement != null) + geronimoLoginmoduleElement.add(optionElement); + if (countIterations == 0) { + for (int i = 0; i < extraOptionsElement.length; i++) { + if (extraOptionsElement[i] != null) + geronimoLoginmoduleElement.add(extraOptionsElement[i]); + } + } + countIterations += 1; + } + } + return geronimoLoginmoduleElement; + } + + /** + * validate the wether the jeronimo side policy is a valid policy + * + * @param application_policyElement + * @return boolean status of the check + */ + private boolean validateSecurityPolicy(Element application_policyElement) { + String jbossLoginModule = null; + if (XMLConversionHelper.containSubElement(application_policyElement, "authentication")) { + Element authenticationElement = XMLConversionHelper.obtainSubElement( + application_policyElement, "authentication"); + if (XMLConversionHelper.containSubElement(authenticationElement, "login-module")) { + Element login_moduleElement = XMLConversionHelper.obtainSubElement( + authenticationElement, "login-module"); + Iterator attribIterator = login_moduleElement.attributeIterator(); + while (attribIterator.hasNext()) { + Attribute itAttribute = (Attribute) attribIterator.next(); + if (itAttribute.getName().equals("code")) { + jbossLoginModule = itAttribute.getText(); + boolean return_value = validateJbossLoginModule(jbossLoginModule); + return return_value; + } + } + } + } + return false; + } + + /** + * obtain the control flag from the login module element + * + * @param login_moduleElement + * @return String version of the control flag + */ + private String obtainControlFlagFromLoginModuleElement(Element login_moduleElement) { + String control_flag = null; + Iterator attribIterator = login_moduleElement.attributeIterator(); + while (attribIterator.hasNext()) { + Attribute itAttribute = (Attribute) attribIterator.next(); + if (itAttribute.getName().equals("flag")) { + control_flag = itAttribute.getText(); + return control_flag; + } + } + return null; + } + + /** + * validate the jboss security modules wethere these are acceptable for the + * geronimo side + * + * @param jbossLoginModule + * @return boolean status of the validation + */ + private boolean validateJbossLoginModule(String jbossLoginModule) { + boolean status = false; + logger.debug("Jboss login module class name => " + jbossLoginModule); + if (jbossLoginModule.equals(Constants.JBOSS_LOGIN_MODULE_DATABASE_SERVER)) { + status = true; + } else if (jbossLoginModule.equals(Constants.JBOSS_LOGIN_MODULE_LDAP)) { + status = true; + } else if (jbossLoginModule.equals(Constants.JBOSS_LOGIN_MODULE_USERS_ROLES)) { + status = true; + }else { + out.error("The security resource conversion tool does not support "+ + jbossLoginModule+" module functionality"); + } + return status; + } + +} Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/hsqldb-ds.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/hsqldb-ds.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/hsqldb-ds.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/hsqldb-ds.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,120 @@ + + + + + + + + + + + + DefaultDS + + + + + jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB + + + org.hsqldb.jdbcDriver + + + sa + + + + + + + + + + 5 + + + 20 + + + + + 0 + + + + + + + + + + + + + + HsqlDbRealm + + + + + + Hypersonic SQL + + + + jboss:service=Hypersonic,database=localDB + + + + + + + localDB + true + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/hsqldb-geronimo-plan.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/hsqldb-geronimo-plan.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/hsqldb-geronimo-plan.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/hsqldb-geronimo-plan.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,40 @@ + + + + + + DefaultDS + + + + hsqldb + hsqldb + jar + + + + + + + javax.sql.DataSource + + DefaultDS + sa + + org.hsqldb.jdbcDriver + jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB + + + + 20 + 5 + 5000 + 0 + + + + + + + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/mysql-ds.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/mysql-ds.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/mysql-ds.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/mysql-ds.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,33 @@ + + + + + + + + + + jdbc/TradeDB + jdbc:mysql://localhost:3306/tradedb + com.mysql.jdbc.Driver + root + password + org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter + + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/mysql-geronimo-plan.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/mysql-geronimo-plan.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/mysql-geronimo-plan.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/mysql-geronimo-plan.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,40 @@ + + + + + + TradeDB + + + + mysql + mysql-connector-java + jar + + + + + + + javax.sql.DataSource + + TradeDB + root + password + com.mysql.jdbc.Driver + jdbc:mysql://localhost:3306/tradedb + + + + 10 + 0 + 5000 + 30 + + + + + + + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/oracle-ds.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/oracle-ds.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/oracle-ds.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/oracle-ds.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,33 @@ + + + + + + + + + + jdbc/TradeDB + jdbc:oracle://localhost:3306/tradedb + oracle.jdbc.OracleDriver + root + password + org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter + + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/oracle-geronimo-plan.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/oracle-geronimo-plan.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/oracle-geronimo-plan.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/ds/oracle-geronimo-plan.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,40 @@ + + + + + + TradeDB + + + + oracle + oracle-jdbc + jar + + + + + + + javax.sql.DataSource + + TradeDB + root + password + oracle.jdbc.OracleDriver + jdbc:oracle://localhost:3306/tradedb + + + + 10 + 0 + 5000 + 30 + + + + + + + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/geronimo-jms-resource-plan.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/geronimo-jms-resource-plan.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/geronimo-jms-resource-plan.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/geronimo-jms-resource-plan.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,125 @@ + + + + + + console.jms + SampleResourceGroup + 1.0 + rar + + + + geronimo + activemq-broker + car + + + + + + + + My JMS Resources + + + tcp://localhost:61616 + + + geronimo + + + geronimo + + + 105 + JMS Configuration [DRAFT (1.1)] + DefaultWorkManager + + + + + + + javax.jms.ConnectionFactory + + + MyConnectionFactory + + javax.jms.QueueConnectionFactory + + + javax.jms.TopicConnectionFactory + + + + + + + 10 + 0 + + 5000 + + + 0 + + + + + + + + + + + + javax.jms.Topic + + + org.activemq.message.ActiveMQTopic + + + + MyTopic + + + MyTopic + + + + + + + javax.jms.Queue + + + org.activemq.message.ActiveMQQueue + + + + 106 + JMS Configuration [DRAFT (1.1)] + MyQueue + + + MyQueue + + + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jbossmq-destinations-service.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jbossmq-destinations-service.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jbossmq-destinations-service.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jbossmq-destinations-service.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + jboss.mq:service=DestinationManager + jboss.mq:service=SecurityManager + + + + + + + + + + + jboss.mq:service=DestinationManager + jboss.mq:service=SecurityManager + + + + + + + + + jboss.mq:service=DestinationManager + jboss.mq:service=SecurityManager + + + + + + + + + + + jboss.mq:service=DestinationManager + jboss.mq:service=SecurityManager + -1 + + + + + + + + + + jboss.mq:service=DestinationManager + + + jboss.mq:service=DestinationManager + + + jboss.mq:service=DestinationManager + + + jboss.mq:service=DestinationManager + + + jboss.mq:service=DestinationManager + + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jms-ds.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jms-ds.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jms-ds.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jms-ds.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + DefaultJMSProvider + + org.jboss.jms.jndi.JNDIProviderAdapter + + + java:/XAConnectionFactory + + java:/XAConnectionFactory + + java:/XAConnectionFactory + + + + + + jboss:service=XidFactory + StdJMSPool + + org.jboss.jms.asf.StdServerSessionPoolFactory + + + + + + JmsXA + + jms-ra.rar + org.jboss.resource.adapter.jms.JmsConnectionFactory + javax.jms.Topic + java:/DefaultJMSProvider + 11 + + JmsXARealm + + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jms-geronimo-plan.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jms-geronimo-plan.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jms-geronimo-plan.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/jms/jms-geronimo-plan.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,123 @@ + + + + + + j2g + jms + 1.0 + jar + + + + j2g + jms + 1.0 + jar + + + + + + DefaultJMSProvider + tcp://localhost:61616 + geronimo + geronimo + + DefaultWorkManager + + + + + javax.jms.ConnectionFactory + + MyConnectionFactory + javax.jms.QueueConnectionFactory + javax.jms.TopicConnectionFactory + + + + 11 + 0 + 5000 + 30 + + + + + + + + + javax.jms.Queue + org.activemq.message.ActiveMQTopic + + testTopic + MyQueue + + + + javax.jms.Queue + org.activemq.message.ActiveMQTopic + + securedTopic + MyQueue + + + + javax.jms.Queue + org.activemq.message.ActiveMQTopic + + testDurableTopic + MyQueue + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + testQueue + Mytopic + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + A + Mytopic + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + B + Mytopic + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + C + Mytopic + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + D + Mytopic + + + + javax.jms.Topic + org.activemq.message.ActiveMQTopic + + ex + Mytopic + + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/err/mail-service.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/err/mail-service.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/err/mail-service.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/err/mail-service.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,54 @@ + + + + + + + + + + + + java:/Mail + nobody + password + + + + + + + + + + + + + + + + + + + + + + + + + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/geronimo-mail-service.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/geronimo-mail-service.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/geronimo-mail-service.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/geronimo-mail-service.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,42 @@ + + + + + + j2g + Mail + 1.0 + car + + + + geronimo + javamail + + + + + +mail.store.protocol=pop3 +mail.transport.protocol=smtp +mail.user=nobody +mail.pop3.host=pop3.nosuchhost.nosuchdomain.com +mail.smtp.host=smtp.nosuchhost.nosuchdomain.com +mail.from=nobody@nosuchhost.nosuchdomain.com +mail.debug=false + + + \ No newline at end of file Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/mail-geronimo-plan.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/mail-geronimo-plan.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/mail-geronimo-plan.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/mail-geronimo-plan.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,30 @@ + + + + + + j2g + Mail + 1.0 + car + + + + geronimo + javamail + 1.1 + car + + + + + + + Added: geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/mail-service.xml URL: http://svn.apache.org/viewvc/geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/mail-service.xml?view=auto&rev=552557 ============================================================================== --- geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/mail-service.xml (added) +++ geronimo/sandbox/j2g/plugins/org.apache.geronimo.j2g.resources/test-apps/mail/mail-service.xml Mon Jul 2 11:30:34 2007 @@ -0,0 +1,56 @@ + + + + + + + + + + + + + java:/Mail + nobody + + + + + + + + + + + + + + + + + + + + + + + + + +