From: Giovanni Meo Date: Fri, 24 May 2013 09:34:09 +0000 (+0000) Subject: Merge "CodeGenerator update." X-Git-Tag: releasepom-0.1.0~423 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=9ff610f03e7fe11a5c9e40405cf24dd3e3af8a89;hp=5f40ba7c5e58cda34092ff0262b1a5fe5a84a615 Merge "CodeGenerator update." --- diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index f9cddd45f9..ddc24b3965 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -84,6 +84,8 @@ ../../northbound/subnets ../../northbound/switchmanager + + ../../northbound/integrationtest ../../logging/bridge diff --git a/opendaylight/northbound/integrationtest/pom.xml b/opendaylight/northbound/integrationtest/pom.xml index 67d6b37950..aa4469e452 100644 --- a/opendaylight/northbound/integrationtest/pom.xml +++ b/opendaylight/northbound/integrationtest/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 org.opendaylight.controller @@ -12,22 +13,618 @@ org.opendaylight.controller northbound.integrationtest 0.4.0-SNAPSHOT - + + + central2 + central2 + ${nexusproxy}/repositories/central2/ + + + + org.opendaylight.controller + sal + 0.5.0-SNAPSHOT + + + org.opendaylight.controller + sal.implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + forwarding.staticrouting + 0.4.0-SNAPSHOT + org.opendaylight.controller clustering.services 0.4.0-SNAPSHOT - + org.opendaylight.controller - sal + clustering.services-implementation 0.4.0-SNAPSHOT - - + + org.opendaylight.controller - sal.implementation + configuration + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + configuration.implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + routing.dijkstra_implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + arphandler + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + forwardingrulesmanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + forwardingrulesmanager.implementation 0.4.0-SNAPSHOT - + + + org.opendaylight.controller + hosttracker + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + hosttracker.implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + containermanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + containermanager.implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + switchmanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + switchmanager.implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + statisticsmanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + statisticsmanager.implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + topologymanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + usermanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + security + 0.4.0-SNAPSHOT + + + + org.opendaylight.controller.thirdparty + net.sf.jung2 + 2.0.1-SNAPSHOT + + + org.opendaylight.controller.thirdparty + com.sun.jersey.jersey-servlet + 1.17-SNAPSHOT + + + + org.opendaylight.controller + commons.northbound + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + topology.northbound + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + forwarding.staticrouting.northbound + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + statistics.northbound + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + flowprogrammer.northbound + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + hosttracker.northbound + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + subnets.northbound + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + switchmanager.northbound + 0.4.0-SNAPSHOT + + + + org.opendaylight.controller + logging.bridge + 0.4.0-SNAPSHOT + + + + org.opendaylight.controller + protocol_plugins.stub + 0.4.0-SNAPSHOT + + + + + org.codehaus.enunciate + enunciate-core-annotations + ${enunciate.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + log4j-over-slf4j + ${slf4j.version} + + + ch.qos.logback + logback-core + ${logback.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + org.codehaus.jackson + jackson-mapper-asl + ${jackson.version} + + + org.codehaus.jackson + jackson-core-asl + ${jackson.version} + + + org.codehaus.jackson + jackson-jaxrs + ${jackson.version} + + + org.codehaus.jettison + jettison + 1.3.3 + + + commons-io + commons-io + 2.3 + + + commons-fileupload + commons-fileupload + 1.2.2 + + + equinoxSDK381 + javax.servlet + 3.0.0.v201112011016 + + + equinoxSDK381 + javax.servlet.jsp + 2.2.0.v201112011158 + + + equinoxSDK381 + org.eclipse.equinox.ds + 1.4.0.v20120522-1841 + + + equinoxSDK381 + org.eclipse.equinox.util + 1.0.400.v20120522-2049 + + + equinoxSDK381 + org.eclipse.osgi.services + 3.3.100.v20120522-1822 + + + equinoxSDK381 + org.eclipse.osgi + 3.8.1.v20120830-144521 + + + equinoxSDK381 + org.apache.felix.gogo.command + 0.8.0.v201108120515 + + + equinoxSDK381 + org.apache.felix.gogo.runtime + 0.8.0.v201108120515 + + + equinoxSDK381 + org.apache.felix.gogo.shell + 0.8.0.v201110170705 + + + equinoxSDK381 + org.eclipse.equinox.cm + 1.0.400.v20120522-1841 + + + equinoxSDK381 + org.eclipse.equinox.console + 1.0.0.v20120522-1841 + + + equinoxSDK381 + org.eclipse.equinox.launcher + 1.3.0.v20120522-1813 + + + + geminiweb + org.eclipse.gemini.web.core + ${geminiweb.version} + + + geminiweb + org.eclipse.gemini.web.extender + ${geminiweb.version} + + + geminiweb + org.eclipse.gemini.web.tomcat + ${geminiweb.version} + + + geminiweb + org.eclipse.virgo.kernel.equinox.extensions + ${virgo.version} + + + geminiweb + org.eclipse.virgo.util.common + ${virgo.version} + + + geminiweb + org.eclipse.virgo.util.io + ${virgo.version} + + + geminiweb + org.eclipse.virgo.util.math + ${virgo.version} + + + geminiweb + org.eclipse.virgo.util.osgi + ${virgo.version} + + + geminiweb + org.eclipse.virgo.util.osgi.manifest + ${virgo.version} + + + geminiweb + org.eclipse.virgo.util.parser.manifest + ${virgo.version} + + + org.apache.felix + org.apache.felix.dependencymanager + 3.1.0 + + + org.apache.felix + org.apache.felix.dependencymanager.shell + 3.0.1 + + + com.google.code.gson + gson + 2.1 + compile + + + org.jboss.spec.javax.transaction + jboss-transaction-api_1.1_spec + 1.0.1.Final + + + org.apache.felix + org.apache.felix.fileinstall + 3.1.6 + + + org.apache.commons + commons-lang3 + 3.1 + + + virgomirror + org.eclipse.jdt.core.compiler.batch + 3.8.0.I20120518-2145 + + + eclipselink + javax.persistence + 2.0.4.v201112161009 + + + orbit + javax.activation + 1.1.0.v201211130549 + + + orbit + javax.annotation + 1.1.0.v201209060031 + + + orbit + javax.ejb + 3.1.1.v201204261316 + + + orbit + javax.el + 2.2.0.v201108011116 + + + orbit + javax.mail.glassfish + 1.4.1.v201108011116 + + + orbit + javax.xml.rpc + 1.1.0.v201005080400 + + + orbit + org.apache.catalina + 7.0.32.v201211201336 + + + orbit + org.apache.catalina.ha + 7.0.32.v201211201952 + + + orbit + org.apache.catalina.tribes + 7.0.32.v201211201952 + + + orbit + org.apache.coyote + 7.0.32.v201211201952 + + + orbit + org.apache.el + 7.0.32.v201211081135 + + + orbit + org.apache.jasper + 7.0.32.v201211201952 + + + orbit + org.apache.juli.extras + 7.0.32.v201211081135 + + + orbit + org.apache.tomcat.api + 7.0.32.v201211081135 + + + orbit + org.apache.tomcat.util + 7.0.32.v201211201952 + + + orbit + javax.servlet.jsp.jstl + 1.2.0.v201105211821 + + + orbit + javax.servlet.jsp.jstl.impl + 1.2.0.v201210211230 + + + + org.ops4j.pax.exam + pax-exam-container-native + ${exam.version} + test + + + org.ops4j.pax.exam + pax-exam-junit4 + ${exam.version} + test + + + org.ops4j.pax.exam + pax-exam-link-mvn + ${exam.version} + test + + + org.ops4j.pax.url + pax-url-aether + ${url.version} + test + + + org.springframework + org.springframework.asm + ${spring.version} + + + org.springframework + org.springframework.aop + ${spring.version} + + + org.springframework + org.springframework.context + ${spring.version} + + + org.springframework + org.springframework.context.support + ${spring.version} + + + org.springframework + org.springframework.core + ${spring.version} + + + org.springframework + org.springframework.beans + ${spring.version} + + + org.springframework + org.springframework.expression + ${spring.version} + + + org.springframework + org.springframework.web + ${spring.version} + + + org.aopalliance + com.springsource.org.aopalliance + 1.0.0 + + + org.springframework + org.springframework.web.servlet + ${spring.version} + + + + org.springframework.security + spring-security-config + ${spring-security.version} + + + org.springframework.security + spring-security-core + ${spring-security.version} + + + org.springframework.security + spring-security-web + ${spring-security.version} + + + org.springframework.security + spring-security-taglibs + ${spring-security.version} + + + org.springframework + org.springframework.transaction + ${spring-security.version} + + + + org.ow2.chameleon.management + chameleon-mbeans + 1.0.0 + + + + com.sun.jersey + jersey-core + ${jersey.version} + + + + com.sun.jersey + jersey-server + ${jersey.version} + + + com.sun.jersey + jersey-client + ${jersey.version} + + + com.sun.jersey + jersey-json + ${jersey.version} + + + diff --git a/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIntegrationTest.java b/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIntegrationTest.java new file mode 100644 index 0000000000..47dfa76b28 --- /dev/null +++ b/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIntegrationTest.java @@ -0,0 +1,425 @@ +package org.opendaylight.controller.northbound.integrationtest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.Bundle; +import javax.inject.Inject; +import org.junit.Assert; +import org.junit.Test; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.junit.PaxExam; +import org.osgi.framework.BundleContext; +import static org.junit.Assert.*; +import org.ops4j.pax.exam.junit.Configuration; +import static org.ops4j.pax.exam.CoreOptions.*; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.util.PathUtils; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; +import org.apache.commons.codec.binary.Base64; + +import org.codehaus.jettison.json.JSONObject; +import org.codehaus.jettison.json.JSONTokener; + +import org.opendaylight.controller.usermanager.IUserManager; + +@RunWith(PaxExam.class) +public class NorthboundIntegrationTest { + private Logger log = LoggerFactory + .getLogger(NorthboundIntegrationTest.class); + // get the OSGI bundle context + @Inject + private BundleContext bc; + private IUserManager users = null; + + private String stateToString(int state) { + switch (state) { + case Bundle.ACTIVE: + return "ACTIVE"; + case Bundle.INSTALLED: + return "INSTALLED"; + case Bundle.RESOLVED: + return "RESOLVED"; + case Bundle.UNINSTALLED: + return "UNINSTALLED"; + default: + return "Not CONVERTED"; + } + } + + @Before + public void areWeReady() { + assertNotNull(bc); + boolean debugit = false; + Bundle b[] = bc.getBundles(); + for (int i = 0; i < b.length; i++) { + int state = b[i].getState(); + if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) { + log.debug("Bundle:" + b[i].getSymbolicName() + " state:" + + stateToString(state)); + debugit = true; + } + } + if (debugit) { + log.debug("Do some debugging because some bundle is " + + "unresolved"); + } + // Assert if true, if false we are good to go! + assertFalse(debugit); + + ServiceReference r = bc.getServiceReference(IUserManager.class + .getName()); + if (r != null) { + this.users = (IUserManager) bc.getService(r); + } + // If UserManager is null, cannot login to run tests. + assertNotNull(this.users); + + } + + @Test + public void testStatistics() { + + System.out.println("Starting Statistics JAXB client."); + + String baseURL = "http://127.0.0.1:8080/controller/nb/v2/statistics/default/flowstats"; + try { + URL url = new URL(baseURL); + + this.users.getAuthorizationList(); + this.users.authenticate("admin", "admin"); + String authString = "admin:admin"; + byte[] authEncBytes = Base64.encodeBase64(authString.getBytes()); + String authStringEnc = new String(authEncBytes); + URLConnection connection = url.openConnection(); + connection.setRequestProperty("Authorization", "Basic " + + authStringEnc); + + connection.setRequestProperty("Content-Type", "application/json"); + connection.setRequestProperty("Accept", "application/json"); + + connection.connect(); + connection.getContentType(); + InputStream is = connection.getInputStream(); + // InputStream is = connection.getInputStream(); + BufferedReader rd = new BufferedReader(new InputStreamReader(is, + Charset.forName("UTF-8"))); + StringBuilder sb = new StringBuilder(); + int cp; + while ((cp = rd.read()) != -1) { + sb.append((char) cp); + } + is.close(); + JSONTokener jt = new JSONTokener(sb.toString()); + JSONObject json = new JSONObject(jt); + JSONObject flowStatistics = json.getJSONObject("flowStatistics"); + JSONObject node = flowStatistics.getJSONObject("node"); + // test that node was returned properly + Assert.assertTrue(node.getInt("@id") == 0xCAFE); + Assert.assertTrue(node.getString("@type").equals("STUB")); + + // test that flow statistics results are correct + JSONObject flowStat = flowStatistics.getJSONObject("flowStat"); + Assert.assertTrue(flowStat.getInt("tableId") == 1); + Assert.assertTrue(flowStat.getInt("durationSeconds") == 40); + Assert.assertTrue(flowStat.getInt("durationNanoseconds") == 400); + Assert.assertTrue(flowStat.getInt("packetCount") == 200); + Assert.assertTrue(flowStat.getInt("byteCount") == 100); + + // test that flow information is correct + JSONObject flow = flowStat.getJSONObject("flow"); + Assert.assertTrue(flow.getInt("priority") == 3500); + Assert.assertTrue(flow.getInt("idleTimeout") == 1000); + Assert.assertTrue(flow.getInt("hardTimeout") == 2000); + Assert.assertTrue(flow.getInt("id") == 12345); + + JSONObject match = (flow.getJSONObject("match") + .getJSONObject("matchField")); + Assert.assertTrue(match.getString("type").equals("NW_DST")); + Assert.assertTrue(match.getString("value").equals("1.1.1.1")); + + Assert.assertTrue(flow.getJSONObject("actions").getString("@type") + .equals("drop")); + + } catch (Exception e) { + // Got an unexpected exception + Assert.assertTrue(false); + + } + } + + // Configure the OSGi container + @Configuration + public Option[] config() { + return options( + // + systemProperty("logback.configurationFile").value( + "file:" + PathUtils.getBaseDir() + + "/src/test/resources/logback.xml"), + // To start OSGi console for inspection remotely + systemProperty("osgi.console").value("2401"), + systemProperty("org.eclipse.gemini.web.tomcat.config.path") + .value(PathUtils.getBaseDir() + + "/src/test/resources/tomcat-server.xml"), + + // setting default level. Jersey bundles will need to be started + // earlier. + systemProperty("osgi.bundles.defaultStartLevel").value("4"), + + // Set the systemPackages (used by clustering) + systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"), + mavenBundle("javax.servlet", "servlet-api", "2.5"), + + mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.2"), + mavenBundle("org.slf4j", "slf4j-api", "1.7.2"), + mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"), + mavenBundle("ch.qos.logback", "logback-core", "1.0.9"), + mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"), + mavenBundle("org.apache.commons", "commons-lang3", "3.1"), + mavenBundle("org.apache.felix", + "org.apache.felix.dependencymanager", "3.1.0"), + + // the plugin stub to get data for the tests + mavenBundle("org.opendaylight.controller", + "protocol_plugins.stub", "0.4.0-SNAPSHOT"), + + // List all the opendaylight modules + mavenBundle("org.opendaylight.controller", "security", + "0.4.0-SNAPSHOT").noStart(), + mavenBundle("org.opendaylight.controller", "sal", + "0.5.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "sal.implementation", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "statisticsmanager", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "statisticsmanager.implementation", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "containermanager", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "containermanager.implementation", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "forwardingrulesmanager", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "forwardingrulesmanager.implementation", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "arphandler", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "clustering.services", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "clustering.services-implementation", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "switchmanager", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "switchmanager.implementation", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "configuration", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "configuration.implementation", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "hosttracker", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "hosttracker.implementation", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "arphandler", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "routing.dijkstra_implementation", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "topologymanager", + "0.4.0-SNAPSHOT"), + + mavenBundle("org.opendaylight.controller", "usermanager", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "logging.bridge", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "clustering.test", + "0.4.0-SNAPSHOT"), + + mavenBundle("org.opendaylight.controller", + "forwarding.staticrouting", "0.4.0-SNAPSHOT"), + + // Northbound bundles + mavenBundle("org.opendaylight.controller", + "commons.northbound", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "forwarding.staticrouting.northbound", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "statistics.northbound", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "topology.northbound", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "hosttracker.northbound", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "switchmanager.northbound", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "flowprogrammer.northbound", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "subnets.northbound", "0.4.0-SNAPSHOT"), + + mavenBundle("org.codehaus.jackson", "jackson-mapper-asl", + "1.9.8"), + mavenBundle("org.codehaus.jackson", "jackson-core-asl", "1.9.8"), + mavenBundle("org.codehaus.jackson", "jackson-jaxrs", "1.9.8"), + mavenBundle("org.codehaus.jettison", "jettison", "1.3.3"), + + mavenBundle("commons-io", "commons-io", "2.3"), + + mavenBundle("commons-fileupload", "commons-fileupload", "1.2.2"), + + mavenBundle("equinoxSDK381", "javax.servlet", + "3.0.0.v201112011016"), + mavenBundle("equinoxSDK381", "javax.servlet.jsp", + "2.2.0.v201112011158"), + mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds", + "1.4.0.v20120522-1841"), + mavenBundle("orbit", "javax.xml.rpc", "1.1.0.v201005080400"), + mavenBundle("equinoxSDK381", "org.eclipse.equinox.util", + "1.0.400.v20120522-2049"), + mavenBundle("equinoxSDK381", "org.eclipse.osgi.services", + "3.3.100.v20120522-1822"), + mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command", + "0.8.0.v201108120515"), + mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime", + "0.8.0.v201108120515"), + mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell", + "0.8.0.v201110170705"), + mavenBundle("equinoxSDK381", "org.eclipse.equinox.cm", + "1.0.400.v20120522-1841"), + mavenBundle("equinoxSDK381", "org.eclipse.equinox.console", + "1.0.0.v20120522-1841"), + mavenBundle("equinoxSDK381", "org.eclipse.equinox.launcher", + "1.3.0.v20120522-1813"), + + mavenBundle("geminiweb", "org.eclipse.gemini.web.core", + "2.2.0.RELEASE"), + mavenBundle("geminiweb", "org.eclipse.gemini.web.extender", + "2.2.0.RELEASE"), + mavenBundle("geminiweb", "org.eclipse.gemini.web.tomcat", + "2.2.0.RELEASE"), + mavenBundle("geminiweb", + "org.eclipse.virgo.kernel.equinox.extensions", + "3.6.0.RELEASE").noStart(), + mavenBundle("geminiweb", "org.eclipse.virgo.util.common", + "3.6.0.RELEASE"), + mavenBundle("geminiweb", "org.eclipse.virgo.util.io", + "3.6.0.RELEASE"), + mavenBundle("geminiweb", "org.eclipse.virgo.util.math", + "3.6.0.RELEASE"), + mavenBundle("geminiweb", "org.eclipse.virgo.util.osgi", + "3.6.0.RELEASE"), + mavenBundle("geminiweb", + "org.eclipse.virgo.util.osgi.manifest", "3.6.0.RELEASE"), + mavenBundle("geminiweb", + "org.eclipse.virgo.util.parser.manifest", + "3.6.0.RELEASE"), + + mavenBundle("org.apache.felix", + "org.apache.felix.dependencymanager", "3.1.0"), + mavenBundle("org.apache.felix", + "org.apache.felix.dependencymanager.shell", "3.0.1"), + + mavenBundle("com.google.code.gson", "gson", "2.1"), + mavenBundle("org.jboss.spec.javax.transaction", + "jboss-transaction-api_1.1_spec", "1.0.1.Final"), + mavenBundle("org.apache.felix", "org.apache.felix.fileinstall", + "3.1.6"), + mavenBundle("org.apache.commons", "commons-lang3", "3.1"), + mavenBundle("commons-codec", "commons-codec"), + mavenBundle("virgomirror", + "org.eclipse.jdt.core.compiler.batch", + "3.8.0.I20120518-2145"), + mavenBundle("eclipselink", "javax.persistence", + "2.0.4.v201112161009"), + + mavenBundle("orbit", "javax.activation", "1.1.0.v201211130549"), + mavenBundle("orbit", "javax.annotation", "1.1.0.v201209060031"), + mavenBundle("orbit", "javax.ejb", "3.1.1.v201204261316"), + mavenBundle("orbit", "javax.el", "2.2.0.v201108011116"), + mavenBundle("orbit", "javax.mail.glassfish", + "1.4.1.v201108011116"), + mavenBundle("orbit", "javax.xml.rpc", "1.1.0.v201005080400"), + mavenBundle("orbit", "org.apache.catalina", + "7.0.32.v201211201336"), + // these are bundle fragments that can't be started on its own + mavenBundle("orbit", "org.apache.catalina.ha", + "7.0.32.v201211201952").noStart(), + mavenBundle("orbit", "org.apache.catalina.tribes", + "7.0.32.v201211201952").noStart(), + mavenBundle("orbit", "org.apache.coyote", + "7.0.32.v201211201952").noStart(), + mavenBundle("orbit", "org.apache.jasper", + "7.0.32.v201211201952").noStart(), + + mavenBundle("orbit", "org.apache.el", "7.0.32.v201211081135"), + mavenBundle("orbit", "org.apache.juli.extras", + "7.0.32.v201211081135"), + mavenBundle("orbit", "org.apache.tomcat.api", + "7.0.32.v201211081135"), + mavenBundle("orbit", "org.apache.tomcat.util", + "7.0.32.v201211201952").noStart(), + mavenBundle("orbit", "javax.servlet.jsp.jstl", + "1.2.0.v201105211821"), + mavenBundle("orbit", "javax.servlet.jsp.jstl.impl", + "1.2.0.v201210211230"), + + mavenBundle("org.ops4j.pax.exam", "pax-exam-container-native"), + mavenBundle("org.ops4j.pax.exam", "pax-exam-junit4"), + mavenBundle("org.ops4j.pax.exam", "pax-exam-link-mvn"), + mavenBundle("org.ops4j.pax.url", "pax-url-aether"), + + mavenBundle("org.springframework", "org.springframework.asm", + "3.1.3.RELEASE"), + mavenBundle("org.springframework", "org.springframework.aop", + "3.1.3.RELEASE"), + mavenBundle("org.springframework", + "org.springframework.context", "3.1.3.RELEASE"), + mavenBundle("org.springframework", + "org.springframework.context.support", "3.1.3.RELEASE"), + mavenBundle("org.springframework", "org.springframework.core", + "3.1.3.RELEASE"), + mavenBundle("org.springframework", "org.springframework.beans", + "3.1.3.RELEASE"), + mavenBundle("org.springframework", + "org.springframework.expression", "3.1.3.RELEASE"), + mavenBundle("org.springframework", "org.springframework.web", + "3.1.3.RELEASE"), + + mavenBundle("org.aopalliance", + "com.springsource.org.aopalliance", "1.0.0"), + mavenBundle("org.springframework", + "org.springframework.web.servlet", "3.1.3.RELEASE"), + mavenBundle("org.springframework.security", + "spring-security-config", "3.1.3.RELEASE"), + mavenBundle("org.springframework.security", + "spring-security-core", "3.1.3.RELEASE"), + mavenBundle("org.springframework.security", + "spring-security-web", "3.1.3.RELEASE"), + mavenBundle("org.springframework.security", + "spring-security-taglibs", "3.1.3.RELEASE"), + mavenBundle("org.springframework", + "org.springframework.transaction", "3.1.3.RELEASE"), + + mavenBundle("org.ow2.chameleon.management", "chameleon-mbeans", + "1.0.0"), + mavenBundle("org.opendaylight.controller.thirdparty", + "net.sf.jung2", "2.0.1-SNAPSHOT"), + mavenBundle("org.opendaylight.controller.thirdparty", + "com.sun.jersey.jersey-servlet", "1.17-SNAPSHOT"), + + // Jersey needs to be started before the northbound application + // bundles, using a lower start level + mavenBundle("com.sun.jersey", "jersey-client", "1.17"), + mavenBundle("com.sun.jersey", "jersey-server", "1.17") + .startLevel(2), + mavenBundle("com.sun.jersey", "jersey-core", "1.17") + .startLevel(2), + mavenBundle("com.sun.jersey", "jersey-json", "1.17") + .startLevel(2), junitBundles()); + } +} \ No newline at end of file diff --git a/opendaylight/northbound/integrationtest/src/test/resources/tomcat-server.xml b/opendaylight/northbound/integrationtest/src/test/resources/tomcat-server.xml new file mode 100644 index 0000000000..4be075451e --- /dev/null +++ b/opendaylight/northbound/integrationtest/src/test/resources/tomcat-server.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/ReadService.java b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/ReadService.java index 0224e3ade6..d331ff0602 100644 --- a/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/ReadService.java +++ b/opendaylight/protocol_plugins/stub/src/main/java/org/opendaylight/controller/protocol_plugins/stub/internal/ReadService.java @@ -94,7 +94,11 @@ public class ReadService implements IPluginInReadService { List actions = new ArrayList(); actions.add(action); flow.setActions(actions); - + flow.setPriority((short)3500); + flow.setIdleTimeout((short)1000); + flow.setHardTimeout((short)2000); + flow.setId(12345); + FlowOnNode fn1 = new FlowOnNode(flow); fn1.setByteCount(100); fn1.setDurationNanoseconds(400); diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/AdvertisedBandwidth.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/AdvertisedBandwidth.java index b07dc34806..37aa60deef 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/AdvertisedBandwidth.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/AdvertisedBandwidth.java @@ -11,9 +11,6 @@ package org.opendaylight.controller.sal.core; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * @file AdvertisedBandWidth.java * @@ -45,16 +42,6 @@ public class AdvertisedBandwidth extends Bandwidth { return new AdvertisedBandwidth(this.bandwidthValue); } - @Override - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); - } - - @Override - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - @Override public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/MacAddress.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/MacAddress.java index 2bfeb46248..b4d1045bac 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/MacAddress.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/MacAddress.java @@ -9,13 +9,13 @@ package org.opendaylight.controller.sal.core; +import java.util.Arrays; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; /** @@ -79,12 +79,27 @@ public class MacAddress extends Property { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + Arrays.hashCode(controllerMacAddress); + result = prime * result + Arrays.hashCode(nodeMacAddress); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + MacAddress other = (MacAddress) obj; + if (!Arrays.equals(controllerMacAddress, other.controllerMacAddress)) + return false; + if (!Arrays.equals(nodeMacAddress, other.nodeMacAddress)) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Name.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Name.java index 6ac89952b3..ddb663f590 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Name.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Name.java @@ -12,9 +12,6 @@ package org.opendaylight.controller.sal.core; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * The class represents the Name property of an element. */ @@ -48,12 +45,28 @@ public class Name extends Property { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + + ((nameValue == null) ? 0 : nameValue.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + Name other = (Name) obj; + if (nameValue == null) { + if (other.nameValue != null) + return false; + } else if (!nameValue.equals(other.nameValue)) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Node.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Node.java index 5c21294f46..ea9d93bdb6 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Node.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Node.java @@ -29,8 +29,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.opendaylight.controller.sal.utils.HexEncode; /** @@ -233,10 +231,10 @@ public class Node implements Serializable { } } - /** + /** * Private setter for nodeType to be called by JAXB not by anyone * else, Node is immutable - * + * * @param type of node to be set */ private void setType(String type) { @@ -269,10 +267,10 @@ public class Node implements Serializable { return this.nodeID.toString(); } } - - /** + + /** * private setter to be used by JAXB - * + * * @param nodeIDString String representation for NodeID */ private void setNodeIDString(String nodeIDString) { @@ -284,24 +282,34 @@ public class Node implements Serializable { @Override public int hashCode() { - return new HashCodeBuilder(163841, 56473) - .append(nodeType) - .append(nodeID) - .hashCode(); + final int prime = 31; + int result = 1; + result = prime * result + ((nodeID == null) ? 0 : nodeID.hashCode()); + result = prime * result + + ((nodeType == null) ? 0 : nodeType.hashCode()); + return result; } @Override public boolean equals(Object obj) { - if (obj == null) { return false; } - if (obj == this) { return true; } - if (obj.getClass() != getClass()) { + if (this == obj) + return true; + if (obj == null) return false; - } - Node rhs = (Node)obj; - return new EqualsBuilder() - .append(this.getType(), rhs.getType()) - .append(this.getID(), rhs.getID()) - .isEquals(); + if (getClass() != obj.getClass()) + return false; + Node other = (Node) obj; + if (nodeID == null) { + if (other.nodeID != null) + return false; + } else if (!nodeID.equals(other.nodeID)) + return false; + if (nodeType == null) { + if (other.nodeType != null) + return false; + } else if (!nodeType.equals(other.nodeType)) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java index 6245c9be8a..495af7970c 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java @@ -27,8 +27,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.tuple.ImmutablePair; /** @@ -53,14 +51,14 @@ public class NodeConnector implements Serializable { ConcurrentHashMap, String>> compatibleType = new ConcurrentHashMap, String>>(); /** - * Represents the OFPP_CONTROLLER reserved port to forward a - * packet to the controller, this is to send data packets - * to the controller from the data plane triggering + * Represents the OFPP_CONTROLLER reserved port to forward a + * packet to the controller, this is to send data packets + * to the controller from the data plane triggering * a packet_in event. */ public static String CONTROLLER = "CTRL"; /** - * Represents the OFPP_ALL reserved OF port + * Represents the OFPP_ALL reserved OF port * to forward to ALL the ports in the system , * should be used for flooding like mechanism to * be used cautiously to avoid excessive flooding. @@ -74,8 +72,8 @@ public class NodeConnector implements Serializable { */ public static String SWSTACK = "SW"; /** - * Describes OFPP_Normal reserved port destination that invokes - * the traditional native L2/L3 HW normal forwarding functionality + * Describes OFPP_Normal reserved port destination that invokes + * the traditional native L2/L3 HW normal forwarding functionality * if supported on the forwarding element. */ public static String HWPATH = "HW"; @@ -332,10 +330,10 @@ public class NodeConnector implements Serializable { } } - /** + /** * Private setter for nodeConnectorType to be called by JAXB not by anyone * else, NodeConnector is immutable - * + * * @param type of node to be set */ private void setType(String type) { @@ -366,9 +364,9 @@ public class NodeConnector implements Serializable { return this.nodeConnectorID.toString(); } - /** + /** * private setter to be used by JAXB - * + * * @param nodeConnectorIDString String representation for NodeConnectorID */ private void setNodeConnectorIDString(String IDStr) { @@ -390,26 +388,46 @@ public class NodeConnector implements Serializable { @Override public int hashCode() { - return new HashCodeBuilder(63389, 4951) - .append(nodeConnectorType) - .append(nodeConnectorID) - .append(nodeConnectorNode) - .hashCode(); + final int prime = 31; + int result = 1; + result = prime * result + + ((nodeConnectorID == null) ? 0 : nodeConnectorID.hashCode()); + result = prime + * result + + ((nodeConnectorNode == null) ? 0 : nodeConnectorNode + .hashCode()); + result = prime + * result + + ((nodeConnectorType == null) ? 0 : nodeConnectorType + .hashCode()); + return result; } @Override public boolean equals(Object obj) { - if (obj == null) { return false; } - if (obj == this) { return true; } - if (obj.getClass() != getClass()) { + if (this == obj) + return true; + if (obj == null) return false; - } - NodeConnector rhs = (NodeConnector)obj; - return new EqualsBuilder() - .append(this.getType(), rhs.getType()) - .append(this.getID(), rhs.getID()) - .append(this.getNode(), rhs.getNode()) - .isEquals(); + if (getClass() != obj.getClass()) + return false; + NodeConnector other = (NodeConnector) obj; + if (nodeConnectorID == null) { + if (other.nodeConnectorID != null) + return false; + } else if (!nodeConnectorID.equals(other.nodeConnectorID)) + return false; + if (nodeConnectorNode == null) { + if (other.nodeConnectorNode != null) + return false; + } else if (!nodeConnectorNode.equals(other.nodeConnectorNode)) + return false; + if (nodeConnectorType == null) { + if (other.nodeConnectorType != null) + return false; + } else if (!nodeConnectorType.equals(other.nodeConnectorType)) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Path.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Path.java index 5f2dc92aee..e21f6f1472 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Path.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Path.java @@ -19,13 +19,11 @@ package org.opendaylight.controller.sal.core; import java.io.Serializable; import java.util.LinkedList; import java.util.List; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.EqualsBuilder; -import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; /** * Describe a path as a sequence of Edge such that from @@ -129,12 +127,27 @@ public class Path implements Serializable { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((edges == null) ? 0 : edges.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Path other = (Path) obj; + if (edges == null) { + if (other.edges != null) + return false; + } else if (!edges.equals(other.edges)) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/PeerBandwidth.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/PeerBandwidth.java index 557e2b3dd2..de2877597f 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/PeerBandwidth.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/PeerBandwidth.java @@ -11,9 +11,6 @@ package org.opendaylight.controller.sal.core; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * @file PeerBandWidth.java * @@ -45,16 +42,7 @@ public class PeerBandwidth extends Bandwidth { return new PeerBandwidth(this.bandwidthValue); } - @Override - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); - } - @Override - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - @Override public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Property.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Property.java index 15d9976106..d50c81e8d7 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Property.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Property.java @@ -14,10 +14,6 @@ import java.io.Serializable; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.ReflectionToStringBuilder; - /** * @file Property.java * @@ -69,16 +65,31 @@ abstract public class Property implements Serializable { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Property other = (Property) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; } @Override public String toString() { - return "Property[" + ReflectionToStringBuilder.toString(this) + "]"; + return "Property [name=" + name + "]"; } } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/State.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/State.java index 4edc1f1d23..ba67e0d821 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/State.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/State.java @@ -12,9 +12,6 @@ package org.opendaylight.controller.sal.core; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * The class represents the State property of an Edge * @@ -54,12 +51,24 @@ public class State extends Property { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + stateValue; + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + State other = (State) obj; + if (stateValue != other.stateValue) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/SupportedBandwidth.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/SupportedBandwidth.java index 969813ca08..5cb7b33890 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/SupportedBandwidth.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/SupportedBandwidth.java @@ -11,9 +11,6 @@ package org.opendaylight.controller.sal.core; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * @file SupportedBandWidth.java * @@ -44,17 +41,7 @@ public class SupportedBandwidth extends Bandwidth { public SupportedBandwidth clone() { return new SupportedBandwidth(this.bandwidthValue); } - - @Override - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); - } - @Override - public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - @Override public String toString() { StringBuffer sb = new StringBuffer(); diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tables.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tables.java index 4370c4c598..22cff90bb5 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tables.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tables.java @@ -12,9 +12,6 @@ package org.opendaylight.controller.sal.core; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * @file Tables.java * @@ -58,12 +55,24 @@ public class Tables extends Property { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + tablesValue; + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + Tables other = (Tables) obj; + if (tablesValue != other.tablesValue) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tier.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tier.java index f45599f6c8..ed4d02b245 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tier.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/Tier.java @@ -12,9 +12,6 @@ package org.opendaylight.controller.sal.core; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * The class represents the Tier property of a node * @@ -50,12 +47,24 @@ public class Tier extends Property { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + tierValue; + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + Tier other = (Tier) obj; + if (tierValue != other.tierValue) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/TimeStamp.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/TimeStamp.java index 6b2467ee5d..a15b3fa9cd 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/TimeStamp.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/TimeStamp.java @@ -12,9 +12,6 @@ package org.opendaylight.controller.sal.core; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * @file TimeStamp.java * @@ -74,12 +71,31 @@ public class TimeStamp extends Property { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + (int) (timestamp ^ (timestamp >>> 32)); + result = prime * result + + ((timestampName == null) ? 0 : timestampName.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + TimeStamp other = (TimeStamp) obj; + if (timestamp != other.timestamp) + return false; + if (timestampName == null) { + if (other.timestampName != null) + return false; + } else if (!timestampName.equals(other.timestampName)) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java index ed6d0e5033..f56c13d345 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/flowprogrammer/Flow.java @@ -20,8 +20,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.opendaylight.controller.sal.action.Action; import org.opendaylight.controller.sal.action.ActionType; import org.opendaylight.controller.sal.action.SetDlType; @@ -181,12 +179,45 @@ public class Flow implements Cloneable, Serializable { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((actions == null) ? 0 : actions.hashCode()); + result = prime * result + hardTimeout; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + idleTimeout; + result = prime * result + ((match == null) ? 0 : match.hashCode()); + result = prime * result + priority; + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Flow other = (Flow) obj; + if (actions == null) { + if (other.actions != null) + return false; + } else if (!actions.equals(other.actions)) + return false; + if (hardTimeout != other.hardTimeout) + return false; + if (id != other.id) + return false; + if (idleTimeout != other.idleTimeout) + return false; + if (match == null) { + if (other.match != null) + return false; + } else if (!match.equals(other.match)) + return false; + if (priority != other.priority) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java index 71e0087090..2ead8cdbc4 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java @@ -26,8 +26,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.opendaylight.controller.sal.utils.EtherTypes; import org.opendaylight.controller.sal.utils.IPProtocols; import org.opendaylight.controller.sal.utils.NetUtils; @@ -337,12 +335,30 @@ public class Match implements Cloneable, Serializable { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((fields == null) ? 0 : fields.hashCode()); + result = prime * result + matches; + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Match other = (Match) obj; + if (fields == null) { + if (other.fields != null) + return false; + } else if (!fields.equals(other.fields)) + return false; + if (matches != other.matches) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/DataLinkAddress.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/DataLinkAddress.java index 433f64c215..0c14517b19 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/DataLinkAddress.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/DataLinkAddress.java @@ -14,8 +14,6 @@ import java.io.Serializable; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; /** @@ -71,12 +69,27 @@ abstract public class DataLinkAddress implements Serializable { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DataLinkAddress other = (DataLinkAddress) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/EthernetAddress.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/EthernetAddress.java index 63daf20763..2afaea8f42 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/EthernetAddress.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/address/EthernetAddress.java @@ -9,6 +9,8 @@ package org.opendaylight.controller.sal.packet.address; +import java.util.Arrays; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -16,8 +18,6 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.utils.HexEncode; @@ -95,12 +95,24 @@ public class EthernetAddress extends DataLinkAddress { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = super.hashCode(); + result = prime * result + Arrays.hashCode(macAddress); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + EthernetAddress other = (EthernetAddress) obj; + if (!Arrays.equals(macAddress, other.macAddress)) + return false; + return true; } @Override diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java index d8da9c301b..fff46eafaf 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/topology/TopoEdgeUpdate.java @@ -10,8 +10,6 @@ package org.opendaylight.controller.sal.topology; import java.util.Set; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.opendaylight.controller.sal.core.Edge; import org.opendaylight.controller.sal.core.Property; @@ -46,7 +44,12 @@ public class TopoEdgeUpdate { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((edge == null) ? 0 : edge.hashCode()); + result = prime * result + ((props == null) ? 0 : props.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; } @Override @@ -57,6 +60,25 @@ public class TopoEdgeUpdate { @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TopoEdgeUpdate other = (TopoEdgeUpdate) obj; + if (edge == null) { + if (other.edge != null) + return false; + } else if (!edge.equals(other.edge)) + return false; + if (props == null) { + if (other.props != null) + return false; + } else if (!props.equals(other.props)) + return false; + if (type != other.type) + return false; + return true; } } diff --git a/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostNodePair.java b/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostNodePair.java index 2437b98d4d..afbbec998d 100644 --- a/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostNodePair.java +++ b/opendaylight/samples/simpleforwarding/src/main/java/org/opendaylight/controller/samples/simpleforwarding/internal/HostNodePair.java @@ -11,10 +11,6 @@ package org.opendaylight.controller.samples.simpleforwarding.internal; import java.io.Serializable; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.ReflectionToStringBuilder; - import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector; import org.opendaylight.controller.sal.core.Node; @@ -53,16 +49,37 @@ public class HostNodePair implements Serializable { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((host == null) ? 0 : host.hashCode()); + result = prime * result + ((node == null) ? 0 : node.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + HostNodePair other = (HostNodePair) obj; + if (host == null) { + if (other.host != null) + return false; + } else if (!host.equals(other.host)) + return false; + if (node == null) { + if (other.node != null) + return false; + } else if (!node.equals(other.node)) + return false; + return true; } @Override public String toString() { - return "HostNodePair[" + ReflectionToStringBuilder.toString(this) + "]"; + return "HostNodePair [host=" + host + ", node=" + node + "]"; } } diff --git a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java index f701553811..80ed209819 100644 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java +++ b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java @@ -14,15 +14,11 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType; import org.opendaylight.controller.sal.utils.GUIField; - -import org.opendaylight.controller.switchmanager.SpanConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,12 +65,34 @@ public class SpanConfig implements Serializable { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode()); + result = prime * result + + ((spanPort == null) ? 0 : spanPort.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SpanConfig other = (SpanConfig) obj; + if (nodeId == null) { + if (other.nodeId != null) + return false; + } else if (!nodeId.equals(other.nodeId)) + return false; + if (spanPort == null) { + if (other.spanPort != null) + return false; + } else if (!spanPort.equals(other.spanPort)) + return false; + return true; } public static ArrayList getFieldsNames() { diff --git a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java index 551f0722db..e15303581f 100644 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java +++ b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java @@ -15,13 +15,8 @@ import java.net.UnknownHostException; import java.util.HashSet; import java.util.Set; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.opendaylight.controller.sal.core.NodeConnector; -import org.opendaylight.controller.switchmanager.Subnet; -import org.opendaylight.controller.switchmanager.SubnetConfig; - /** * The class describes subnet information including L3 address, vlan and set of * ports associated with the subnet. @@ -179,33 +174,43 @@ public class Subnet implements Serializable { return this; } - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ @Override public int hashCode() { - return new HashCodeBuilder().append(networkAddress).append( - subnetMaskLength).toHashCode(); + final int prime = 31; + int result = 1; + result = prime * result + + ((networkAddress == null) ? 0 : networkAddress.hashCode()); + result = prime * result + + ((nodeConnectors == null) ? 0 : nodeConnectors.hashCode()); + result = prime * result + subnetMaskLength; + result = prime * result + vlan; + return result; } - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ @Override public boolean equals(Object obj) { - if (this == obj) { + if (this == obj) return true; - } - if (obj == null) { + if (obj == null) return false; - } - if (obj.getClass() != getClass()) { + if (getClass() != obj.getClass()) return false; - } Subnet other = (Subnet) obj; - // Check only equality for the key fields - return new EqualsBuilder().append(networkAddress, other.networkAddress) - .append(subnetMaskLength, other.subnetMaskLength).isEquals(); + if (networkAddress == null) { + if (other.networkAddress != null) + return false; + } else if (!networkAddress.equals(other.networkAddress)) + return false; + if (nodeConnectors == null) { + if (other.nodeConnectors != null) + return false; + } else if (!nodeConnectors.equals(other.nodeConnectors)) + return false; + if (subnetMaskLength != other.subnetMaskLength) + return false; + if (vlan != other.vlan) + return false; + return true; } /* (non-Javadoc) diff --git a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Switch.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Switch.java index afca30c3a1..6ba78deade 100644 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Switch.java +++ b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Switch.java @@ -11,12 +11,11 @@ package org.opendaylight.controller.switchmanager; import java.io.Serializable; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; @@ -125,12 +124,44 @@ public class Switch implements Serializable { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(dataLayerAddress); + result = prime * result + ((node == null) ? 0 : node.hashCode()); + result = prime * result + + ((nodeConnectors == null) ? 0 : nodeConnectors.hashCode()); + result = prime * result + + ((spanPorts == null) ? 0 : spanPorts.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Switch other = (Switch) obj; + if (!Arrays.equals(dataLayerAddress, other.dataLayerAddress)) + return false; + if (node == null) { + if (other.node != null) + return false; + } else if (!node.equals(other.node)) + return false; + if (nodeConnectors == null) { + if (other.nodeConnectors != null) + return false; + } else if (!nodeConnectors.equals(other.nodeConnectors)) + return false; + if (spanPorts == null) { + if (other.spanPorts != null) + return false; + } else if (!spanPorts.equals(other.spanPorts)) + return false; + return true; } @Override diff --git a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java index ffb8ec042c..778310e07f 100644 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java +++ b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java @@ -11,9 +11,6 @@ package org.opendaylight.controller.switchmanager; import java.io.Serializable; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * The class describes a switch configuration including node identifier, node * name, tier number and proactive/reactive mode. @@ -59,11 +56,45 @@ public class SwitchConfig implements Serializable { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((mode == null) ? 0 : mode.hashCode()); + result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode()); + result = prime * result + ((tier == null) ? 0 : tier.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SwitchConfig other = (SwitchConfig) obj; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (mode == null) { + if (other.mode != null) + return false; + } else if (!mode.equals(other.mode)) + return false; + if (nodeId == null) { + if (other.nodeId != null) + return false; + } else if (!nodeId.equals(other.nodeId)) + return false; + if (tier == null) { + if (other.tier != null) + return false; + } else if (!tier.equals(other.tier)) + return false; + return true; } } diff --git a/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/AuthenticatedUser.java b/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/AuthenticatedUser.java index 6c6f07ca66..f66d47ea55 100644 --- a/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/AuthenticatedUser.java +++ b/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/AuthenticatedUser.java @@ -40,7 +40,10 @@ public class AuthenticatedUser implements Serializable { public void setRoleList(String[] roleArray) { userRoles = new ArrayList(roleArray.length); for (String role : roleArray) { - userRoles.add(role); + String target = role.trim(); + if (!target.isEmpty()) { + userRoles.add(target); + } } } diff --git a/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/AuthorizationConfig.java b/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/AuthorizationConfig.java index 2474eec6d9..038ccca2fc 100644 --- a/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/AuthorizationConfig.java +++ b/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/AuthorizationConfig.java @@ -8,6 +8,9 @@ package org.opendaylight.controller.usermanager.internal; +import java.util.ArrayList; +import java.util.List; + import org.opendaylight.controller.sal.utils.Status; /** @@ -22,22 +25,23 @@ public class AuthorizationConfig extends UserConfig { } // Constructor may be needed for autocontainer logic - public AuthorizationConfig(String user, String role) { + public AuthorizationConfig(String user, List roles) { super(); this.user = user; - this.role = role; + this.roles = (roles == null) ? new ArrayList() + : new ArrayList(roles); } @Override public Status validate() { - return (!isRoleValid().isSuccess() ? isRoleValid() : isUsernameValid()); - } - - public String getRolesData() { - return (role.replace(",", " ")); + Status status = validateUsername(); + if (status.isSuccess()) { + status = validateRoles(); + } + return status; } public String toString() { - return "AuthorizationConfig=[user: " + user + ", role: " + role + "]"; + return "AuthorizationConfig=[user: " + user + ", roles: " + roles + "]"; } } diff --git a/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/ServerConfig.java b/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/ServerConfig.java index 649fee8f7f..2ad98aba68 100644 --- a/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/ServerConfig.java +++ b/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/ServerConfig.java @@ -11,9 +11,6 @@ package org.opendaylight.controller.usermanager.internal; import java.io.Serializable; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - /** * Configuration Java Object which represents a Remote AAA server configuration * information for User Manager. @@ -49,12 +46,40 @@ public class ServerConfig implements Serializable { @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + ((ip == null) ? 0 : ip.hashCode()); + result = prime * result + + ((protocol == null) ? 0 : protocol.hashCode()); + result = prime * result + ((secret == null) ? 0 : secret.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ServerConfig other = (ServerConfig) obj; + if (ip == null) { + if (other.ip != null) + return false; + } else if (!ip.equals(other.ip)) + return false; + if (protocol == null) { + if (other.protocol != null) + return false; + } else if (!protocol.equals(other.protocol)) + return false; + if (secret == null) { + if (other.secret != null) + return false; + } else if (!secret.equals(other.secret)) + return false; + return true; } public boolean isValid() { diff --git a/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/UserConfig.java b/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/UserConfig.java index cedae6c918..176af3a3e4 100644 --- a/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/UserConfig.java +++ b/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/UserConfig.java @@ -9,11 +9,12 @@ package org.opendaylight.controller.usermanager.internal; import java.io.Serializable; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.opendaylight.controller.sal.authorization.AuthResultEnum; import org.opendaylight.controller.sal.utils.Status; import org.opendaylight.controller.sal.utils.StatusCode; @@ -31,7 +32,7 @@ public class UserConfig implements Serializable { * configurations */ protected String user; - protected String role; + protected List roles; private String password; private static final int USERNAME_MAXLENGTH = 32; private static final int PASSWORD_MINLENGTH = 5; @@ -42,12 +43,13 @@ public class UserConfig implements Serializable { public UserConfig() { } - public UserConfig(String user, String password, String role) { + public UserConfig(String user, String password, List roles) { this.user = user; this.password = password; - this.role = role; + this.roles = (roles == null) ? new ArrayList() + : new ArrayList(roles); } - + public String getUser() { return user; } @@ -56,38 +58,65 @@ public class UserConfig implements Serializable { return password; } - public String getRole() { - return role; + public List getRoles() { + return new ArrayList(roles); } @Override public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); + final int prime = 31; + int result = 1; + result = prime * result + + ((password == null) ? 0 : password.hashCode()); + result = prime * result + ((roles == null) ? 0 : roles.hashCode()); + result = prime * result + ((user == null) ? 0 : user.hashCode()); + return result; } @Override public boolean equals(Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + UserConfig other = (UserConfig) obj; + if (password == null) { + if (other.password != null) + return false; + } else if (!password.equals(other.password)) + return false; + if (roles == null) { + if (other.roles != null) + return false; + } else if (!roles.equals(other.roles)) + return false; + if (user == null) { + if (other.user != null) + return false; + } else if (!user.equals(other.user)) + return false; + return true; } @Override public String toString() { - return "UserConfig[user=" + user + ", password=" + password + "]"; + return "UserConfig[user=" + user + ", password=" + password + ", roles=" + roles +"]"; } public Status validate() { - Status validCheck = new Status(StatusCode.SUCCESS, null); - validCheck = isRoleValid(); - - if (validCheck.isSuccess()) - validCheck = isUsernameValid(); - if (validCheck.isSuccess()) - validCheck = isPasswordValid(); - + Status validCheck = validateRoles(); + if (validCheck.isSuccess()) { + validCheck = validateUsername(); + } + if (validCheck.isSuccess()) { + validCheck = validatePassword(); + } return validCheck; } - protected Status isUsernameValid() { + protected Status validateUsername() { if (user == null || user.isEmpty()) { return new Status(StatusCode.BADREQUEST, "Username cannot be empty"); } @@ -101,10 +130,10 @@ public class UserConfig implements Serializable { + "characters except ./#%;?\\"); } - return new Status(StatusCode.SUCCESS, null); + return new Status(StatusCode.SUCCESS); } - private Status isPasswordValid() { + private Status validatePassword() { if (password == null || password.isEmpty()) { return new Status(StatusCode.BADREQUEST, "Password cannot be empty"); } @@ -114,41 +143,66 @@ public class UserConfig implements Serializable { return new Status(StatusCode.BADREQUEST, "Password should have 5-256 characters"); } - return new Status(StatusCode.SUCCESS, null); + return new Status(StatusCode.SUCCESS); } - protected Status isRoleValid() { - if (role == null || role.isEmpty()) { - return new Status(StatusCode.BADREQUEST, - "Role name cannot be empty"); + protected Status validateRoles() { + if (roles == null || roles.isEmpty()) { + return new Status(StatusCode.BADREQUEST, "No role specified"); } - return new Status(StatusCode.SUCCESS, null); + return new Status(StatusCode.SUCCESS); } - public boolean update(String currentPassword, String newPassword, - String newRole) { + public Status update(String currentPassword, String newPassword, + List newRoles) { // To make any changes to a user configured profile, current password // must always be provided if (!this.password.equals(currentPassword)) { - return false; - } - if (newPassword != null) { - this.password = newPassword; + return new Status(StatusCode.BADREQUEST, + "Current password is incorrect"); } - if (newRole != null) { - this.role = newRole; + + // Create a new object with the proposed modifications + UserConfig proposed = new UserConfig(); + proposed.user = this.user; + proposed.password = (newPassword != null)? newPassword : this.password; + proposed.roles = (newRoles != null)? newRoles : this.roles; + + // Validate it + Status status = proposed.validate(); + if (!status.isSuccess()) { + return status; } - return true; + + // Accept the modifications + this.user = proposed.user; + this.password = proposed.password; + this.roles = new ArrayList(proposed.roles); + + return status; } public AuthResponse authenticate(String clearTextPass) { AuthResponse locResponse = new AuthResponse(); if (password.equals(clearTextPass)) { locResponse.setStatus(AuthResultEnum.AUTH_ACCEPT_LOC); - locResponse.addData(role.replace(",", " ")); + locResponse.addData(getRolesString()); } else { locResponse.setStatus(AuthResultEnum.AUTH_REJECT_LOC); } return locResponse; } + + protected String getRolesString() { + StringBuffer buffer = new StringBuffer(); + if (!roles.isEmpty()) { + Iterator iter = roles.iterator(); + buffer.append(iter.next()); + while (iter.hasNext()) { + buffer.append(" "); + buffer.append(iter.next()); + } + } + return buffer.toString(); + } } diff --git a/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/UserManagerImpl.java b/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/UserManagerImpl.java index 31c773da8a..69c9a1a2a6 100644 --- a/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/UserManagerImpl.java +++ b/opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/UserManagerImpl.java @@ -82,13 +82,8 @@ public class UserManagerImpl implements IUserManager, IObjectReader, private static final String authFileName = ROOT + "authorization.conf"; private ConcurrentMap localUserConfigList; private ConcurrentMap remoteServerConfigList; - private ConcurrentMap authorizationConfList; // local - // authorization - // info - // for - // remotely - // authenticated - // users + // local authorization info for remotely authenticated users + private ConcurrentMap authorizationConfList; private ConcurrentMap activeUsers; private ConcurrentMap authProviders; private ConcurrentMap localUserListSaveConfigEvent, @@ -243,8 +238,10 @@ public class UserManagerImpl implements IUserManager, IObjectReader, // If startup config is not there, it's old or it was deleted, // need to add Default Admin if (!localUserConfigList.containsKey(defaultAdmin)) { + List roles = new ArrayList(1); + roles.add(defaultAdminRole); localUserConfigList.put(defaultAdmin, new UserConfig(defaultAdmin, - defaultAdminPassword, defaultAdminRole)); + defaultAdminPassword, roles)); } } @@ -253,7 +250,6 @@ public class UserManagerImpl implements IUserManager, IObjectReader, IAAAProvider aaaClient; AuthResponse rcResponse = null; AuthenticatedUser result; - String[] adminRoles = null; boolean remotelyAuthenticated = false; boolean authorizationInfoIsPresent = false; boolean authorized = false; @@ -342,7 +338,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader, if (resource != null) { logger.info("Found Local Authorization Info for User: \"{}\"", userName); - attributes = resource.getRolesData(); + attributes = resource.getRolesString(); } authorizationInfoIsPresent = checkAuthorizationInfo(attributes); @@ -354,8 +350,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader, */ if (authorizationInfoIsPresent) { // Identifying the administrative role - adminRoles = attributes.split(" "); - result.setRoleList(adminRoles); + result.setRoleList(attributes.split(" ")); authorized = true; } else { logger.info("Not able to find Authorization Info for User: \"{}\"", @@ -504,6 +499,12 @@ public class UserManagerImpl implements IUserManager, IObjectReader, return new Status(StatusCode.NOTALLOWED, msg); } localUserConfigList.remove(AAAconf.getUser()); + /* + * A user account has been removed form local database, we assume + * admin does not want this user to stay connected, in case he has + * an open session. So we clean the active list as well. + */ + removeUserFromActiveList(AAAconf.getUser()); } else { if (AAAconf.getUser().equals(UserManagerImpl.defaultAdmin)) { String msg = "Invalid Request: Default Network Admin User " @@ -621,16 +622,17 @@ public class UserManagerImpl implements IUserManager, IObjectReader, if (targetConfigEntry == null) { return new Status(StatusCode.NOTFOUND, "User not found"); } - if (false == targetConfigEntry.update(curPassword, newPassword, null)) { - return new Status(StatusCode.BADREQUEST, - "Current password is incorrect"); + Status status = targetConfigEntry + .update(curPassword, newPassword, null); + if (!status.isSuccess()) { + return status; } - localUserConfigList.put(user, targetConfigEntry); // trigger cluster - // update + // Trigger cluster update + localUserConfigList.put(user, targetConfigEntry); logger.info("Password changed for User \"{}\"", user); - return new Status(StatusCode.SUCCESS, null); + return status; } @Override @@ -701,35 +703,44 @@ public class UserManagerImpl implements IUserManager, IObjectReader, String userName = ci.nextArgument(); String password = ci.nextArgument(); String role = ci.nextArgument(); + + List roles = new ArrayList(); + while (role != null) { + if (!role.trim().isEmpty()) { + roles.add(role); + } + role = ci.nextArgument(); + } if (userName == null || userName.trim().isEmpty() || password == null - || password.trim().isEmpty() || role == null - || role.trim().isEmpty()) { + || password.trim().isEmpty() || roles == null + || roles.isEmpty()) { ci.println("Invalid Arguments"); ci.println("umAddUser "); return; } - this.addLocalUser(new UserConfig(userName, password, role)); + ci.print(this.addLocalUser(new UserConfig(userName, password, roles))); } public void _umRemUser(CommandInterpreter ci) { String userName = ci.nextArgument(); - String password = ci.nextArgument(); - String role = ci.nextArgument(); - if (userName == null || userName.trim().isEmpty() || password == null - || password.trim().isEmpty() || role == null - || role.trim().isEmpty()) { + if (userName == null || userName.trim().isEmpty()) { ci.println("Invalid Arguments"); - ci.println("umRemUser "); + ci.println("umRemUser "); return; } - this.removeLocalUser(new UserConfig(userName, password, role)); + UserConfig target = localUserConfigList.get(userName); + if (target == null) { + ci.println("User not found"); + return; + } + ci.println(this.removeLocalUser(target)); } public void _umGetUsers(CommandInterpreter ci) { for (UserConfig conf : this.getLocalUserList()) { - ci.println(conf.getUser() + " " + conf.getRole()); + ci.println(conf.getUser() + " " + conf.getRoles()); } } @@ -862,39 +873,47 @@ public class UserManagerImpl implements IUserManager, IObjectReader, @Override public UserLevel getUserLevel(String username) { // Returns the controller well-know user level for the passed user - String roleName = null; + List rolesNames = null; // First check in active users then in local configured users if (activeUsers.containsKey(username)) { List roles = activeUsers.get(username).getUserRoles(); - roleName = (roles == null || roles.isEmpty())? null : roles.get(0); + rolesNames = (roles == null || roles.isEmpty()) ? null : roles; } else if (localUserConfigList.containsKey(username)) { UserConfig config = localUserConfigList.get(username); - roleName = (config == null)? null : config.getRole(); + rolesNames = (config == null) ? null : config.getRoles(); } - if (roleName == null) { + if (rolesNames == null) { return UserLevel.NOUSER; } - // For now only one role per user is allowed - if (roleName.equals(UserLevel.SYSTEMADMIN.toString())) { + // Check against the well known controller roles first + if (rolesNames.contains(UserLevel.SYSTEMADMIN.toString())) { return UserLevel.SYSTEMADMIN; } - if (roleName.equals(UserLevel.NETWORKADMIN.toString())) { + if (rolesNames.contains(UserLevel.NETWORKADMIN.toString())) { return UserLevel.NETWORKADMIN; } - if (roleName.equals(UserLevel.NETWORKOPERATOR.toString())) { + if (rolesNames.contains(UserLevel.NETWORKOPERATOR.toString())) { return UserLevel.NETWORKOPERATOR; } - if (this.containerAuthorizationClient != null - && this.containerAuthorizationClient - .isApplicationRole(roleName)) { - return UserLevel.CONTAINERUSER; + // Check if container user now + if (containerAuthorizationClient != null) { + for (String roleName : rolesNames) { + if (containerAuthorizationClient.isApplicationRole(roleName)) { + return UserLevel.CONTAINERUSER; + } + } } - for (IResourceAuthorization client : this.applicationAuthorizationClients) { - if (client.isApplicationRole(roleName)) { - return UserLevel.APPUSER; + // Finally check if application user + if (applicationAuthorizationClients != null) { + for (String roleName : rolesNames) { + for (IResourceAuthorization client : this.applicationAuthorizationClients) { + if (client.isApplicationRole(roleName)) { + return UserLevel.APPUSER; + } + } } } return UserLevel.NOUSER; diff --git a/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/AuthenticatedUserTest.java b/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/AuthenticatedUserTest.java index 4a379cdd2f..810500baa4 100644 --- a/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/AuthenticatedUserTest.java +++ b/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/AuthenticatedUserTest.java @@ -35,7 +35,6 @@ public class AuthenticatedUserTest { Assert.assertFalse(user.getAccessDate().isEmpty()); Assert.assertNull(user.getUserRoles()); - } @Test diff --git a/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/AuthorizationUserConfigTest.java b/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/AuthorizationUserConfigTest.java index d274da5248..7d28d23075 100644 --- a/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/AuthorizationUserConfigTest.java +++ b/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/AuthorizationUserConfigTest.java @@ -11,6 +11,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.util.ArrayList; +import java.util.List; + import org.junit.Test; import org.opendaylight.controller.sal.authorization.AuthResultEnum; import org.opendaylight.controller.sal.authorization.UserLevel; @@ -24,61 +27,75 @@ public class AuthorizationUserConfigTest { @Test public void AuthorizationConfigTest() { AuthorizationConfig authConfig; + List roles = new ArrayList(); // test isValid - authConfig = new AuthorizationConfig(null, - UserLevel.SYSTEMADMIN.toString()); + roles.add(UserLevel.SYSTEMADMIN.toString()); + authConfig = new AuthorizationConfig(null, roles); assertFalse(authConfig.validate().isSuccess()); - authConfig = new AuthorizationConfig("admin", ""); + authConfig = new AuthorizationConfig("admin", new ArrayList()); assertFalse(authConfig.validate().isSuccess()); - authConfig = new AuthorizationConfig("admin", - UserLevel.SYSTEMADMIN.toString()); + authConfig = new AuthorizationConfig("admin", roles); assertTrue(authConfig.validate().isSuccess()); } @Test public void UserConfigTest() { UserConfig userConfig; + List roles = new ArrayList(); - userConfig = new UserConfig(null, "cisco", - UserLevel.NETWORKOPERATOR.toString()); + roles.add(UserLevel.SYSTEMADMIN.toString()); + userConfig = new UserConfig(null, "cisco", roles); assertFalse(userConfig.validate().isSuccess()); - userConfig = new UserConfig("uname", "", "cisco"); + roles.clear(); + roles.add("cisco"); + userConfig = new UserConfig("uname", "", roles); assertFalse(userConfig.validate().isSuccess()); - userConfig = new UserConfig("uname", "ciscocisco", - UserLevel.NETWORKOPERATOR.toString()); + roles.clear(); + roles.add(UserLevel.NETWORKOPERATOR.toString()); + userConfig = new UserConfig("uname", "ciscocisco", roles); assertTrue(userConfig.validate().isSuccess()); - /* currentPassword mismatch */ - assertFalse(userConfig.update("Cisco", "cisco123", - UserLevel.NETWORKOPERATOR.toString())); - - assertTrue(userConfig.update("ciscocisco", null, - UserLevel.NETWORKOPERATOR.toString())); - /* New Password = null, No change in password */ + // currentPassword mismatch + assertFalse(userConfig.update("Cisco", "cisco123", roles).isSuccess()); + + // Role change only + roles.clear(); + roles.add(UserLevel.NETWORKADMIN.toString()); + assertTrue(userConfig.update("ciscocisco", null, roles).isSuccess()); + + // Role change and same new password + roles.clear(); + roles.add(UserLevel.NETWORKOPERATOR.toString()); + assertTrue(userConfig.update("ciscocisco", "ciscocisco", roles) + .isSuccess()); + + // New Password = null, No change in password assertTrue(userConfig.getPassword().equals("ciscocisco")); - /* Password changed successfully, no change in user role */ - assertTrue(userConfig.update("ciscocisco", "cisco123", - UserLevel.NETWORKOPERATOR.toString())); + // Password changed successfully, no change in user role + assertTrue(userConfig.update("ciscocisco", "cisco123", roles) + .isSuccess()); assertTrue(userConfig.getPassword().equals("cisco123")); - assertTrue(userConfig.getRole().equals( + assertTrue(userConfig.getRoles().get(0).equals( UserLevel.NETWORKOPERATOR.toString())); - /* Password not changed, role changed successfully */ - assertTrue(userConfig.update("cisco123", "cisco123", - UserLevel.SYSTEMADMIN.toString())); + // Password not changed, role changed successfully + roles.clear(); + roles.add(UserLevel.SYSTEMADMIN.toString()); + assertTrue(userConfig.update("cisco123", "cisco123", roles) + .isSuccess()); assertTrue(userConfig.getPassword().equals("cisco123")); - assertTrue(userConfig.getRole() + assertTrue(userConfig.getRoles().get(0) .equals(UserLevel.SYSTEMADMIN.toString())); - /* Password and role changed successfully */ - assertTrue(userConfig.update("cisco123", "ciscocisco", - UserLevel.SYSTEMADMIN.toString())); + // Password and role changed successfully + assertTrue(userConfig.update("cisco123", "ciscocisco", roles) + .isSuccess()); assertTrue(userConfig.getPassword().equals("ciscocisco")); - assertTrue(userConfig.getRole() + assertTrue(userConfig.getRoles().get(0) .equals(UserLevel.SYSTEMADMIN.toString())); String username = userConfig.getUser(); @@ -91,11 +108,11 @@ public class AuthorizationUserConfigTest { assertTrue(authresp.getStatus().equals(AuthResultEnum.AUTH_REJECT_LOC)); // test equals() - userConfig = new UserConfig("uname", "ciscocisco", - UserLevel.NETWORKOPERATOR.toString()); + roles.clear(); + roles.add(UserLevel.NETWORKOPERATOR.toString()); + userConfig = new UserConfig("uname", "ciscocisco", roles); assertEquals(userConfig, userConfig); - UserConfig userConfig2 = new UserConfig("uname", "ciscocisco", - UserLevel.NETWORKOPERATOR.toString()); + UserConfig userConfig2 = new UserConfig("uname", "ciscocisco", roles); assertEquals(userConfig, userConfig2); } } diff --git a/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/UserManagerImplTest.java b/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/UserManagerImplTest.java index ec7b136039..626011bd69 100644 --- a/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/UserManagerImplTest.java +++ b/opendaylight/usermanager/src/test/java/org/opendaylight/controller/usermanager/internal/UserManagerImplTest.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -13,7 +12,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import java.util.Date; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; import org.junit.Assert; @@ -31,218 +31,229 @@ import org.opendaylight.controller.usermanager.IUserManager; */ public class UserManagerImplTest { - private static UserManagerImpl um; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - - IUserManager userManager = (IUserManager) ServiceHelper - .getGlobalInstance(IUserManager.class, new Object()); - if (userManager instanceof UserManagerImpl) { - um = (UserManagerImpl) userManager; - } else { - um = new UserManagerImpl(); - um.setAuthProviders(new ConcurrentHashMap()); - - // mock up a remote server list with a dummy server - um.setRemoteServerConfigList(new ConcurrentHashMap() { - static final long serialVersionUID = 1L; - { - put("dummyServerConfig", new ServerConfig() { // Server config can't be empty - static final long serialVersionUID = 8645L; - - public String getAddress() { - return "1.1.1.1"; - } - - public String getSecret() { - return "secret"; - } - - public String getProtocol() { - return "IPv4"; - } - }); - } - }); - - // mock up a localUserConfigList with an admin user - um.setLocalUserConfigList(new ConcurrentHashMap() { - static final long serialVersionUID = 2L; - { - put("admin", new UserConfig("admin", "7029,7455,8165,7029,7881", - UserLevel.SYSTEMADMIN.toString())); - } - }); - // instantiate an empty activeUser collection - um.setActiveUsers(new ConcurrentHashMap()); - - } - - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#addAAAProvider(org.opendaylight.controller.usermanager.IAAAProvider)} - * . - */ - @Test - public void testAddAAAProvider() { - // instantiate an anonymous AAAProvider - IAAAProvider a3p = new IAAAProvider() { - - public AuthResponse authService(String userName, String password, - String server, String secretKey) { - return new AuthResponse(); - }; - - public String getName() { - return "dummyAAAProvider"; - } - }; - - um.addAAAProvider(a3p); - assertEquals(a3p, um.getAAAProvider("dummyAAAProvider")); - - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#removeAAAProvider(org.opendaylight.controller.usermanager.IAAAProvider)} - * and for for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#getAAAProvider(java.lang.String)} - * . - */ - @Test - public void testRemoveAAAProvider() { - um.removeAAAProvider(um.getAAAProvider("dummyAAAProvider")); - assertTrue(um.getAAAProviderNames().isEmpty()); - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#authenticate(java.lang.String, java.lang.String)} - * . - */ - @Test - public void testAuthenticateStringString() { - UserConfig uc = new UserConfig("administrator", "admin", - UserLevel.SYSTEMADMIN.toString()); - um.addLocalUser(uc); - AuthResultEnum authResult = um.authenticate("administrator", "admin"); - assertEquals(authResult, AuthResultEnum.AUTH_ACCEPT_LOC); - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#addRemoveLocalUser(org.opendaylight.controller.usermanager.internal.UserConfig, boolean)} - * . - */ - @Test - public void testAddRemoveLocalUser() { - UserConfig uc = new UserConfig("sysadmin", "7029,7455,8165,7029,7881", - UserLevel.SYSTEMADMIN.toString()); - um.addLocalUser(uc); - assertTrue(um.getLocalUserList().contains(uc)); - um.removeLocalUser(uc); - assertFalse(um.getLocalUserList().contains(uc)); - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#changeLocalUserPassword(java.lang.String, java.lang.String, java.lang.String)} - * . - */ - @Test - public void testChangeLocalUserPassword() { - // fail("Not yet implemented"); - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#userLogout(java.lang.String)} - * . - */ - @Test - public void testUserLogout() { - // fail("Not yet implemented"); - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#userTimedOut(java.lang.String)} - * . - */ - @Test - public void testUserTimedOut() { - // fail("Not yet implemented"); - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#authenticate(org.springframework.security.core.Authentication)} - * . - */ - @Test - public void testAuthenticateAuthentication() { - // fail("Not yet implemented"); - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#saveLocalUserList()} - * . - */ - @Test - public void testSaveLocalUserList() { - // fail("Not yet implemented"); - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#saveAAAServerList()} - * . - */ - @Test - public void testSaveAAAServerList() { - // fail("Not yet implemented"); - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#saveAuthorizationList()} - * . - */ - @Test - public void testSaveAuthorizationList() { - // fail("Not yet implemented"); - } - - /** - * Test method for - * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#readObject(java.io.ObjectInputStream)} - * . - */ - @Test - public void testReadObject() { - // fail("Not yet implemented"); - } - - @Test - public void testGetUserLevel() { - um.addLocalUser(new UserConfig("Jack", "password", - UserLevel.SYSTEMADMIN.toString())); - um.authenticate("Jack", "password"); - - um.addLocalUser(new UserConfig("John", "password", - UserLevel.NETWORKOPERATOR.toString())); - // Run the check on authenticated user - Assert.assertTrue(um.getUserLevel("Jack") == UserLevel.SYSTEMADMIN); - // Run the check on configured users - Assert.assertTrue(um.getUserLevel("John") == UserLevel.NETWORKOPERATOR); - Assert.assertTrue(um.getUserLevel("Andrew") == UserLevel.NOUSER); - } + private static UserManagerImpl um; + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception { + + IUserManager userManager = (IUserManager) ServiceHelper + .getGlobalInstance(IUserManager.class, new Object()); + if (userManager instanceof UserManagerImpl) { + um = (UserManagerImpl) userManager; + } else { + um = new UserManagerImpl(); + um.setAuthProviders(new ConcurrentHashMap()); + + // mock up a remote server list with a dummy server + um.setRemoteServerConfigList(new ConcurrentHashMap() { + static final long serialVersionUID = 1L; + { + put("dummyServerConfig", new ServerConfig() { + // Server config can't be empty + static final long serialVersionUID = 8645L; + + public String getAddress() { + return "1.1.1.1"; + } + + public String getSecret() { + return "secret"; + } + + public String getProtocol() { + return "IPv4"; + } + }); + } + }); + + // mock up a localUserConfigList with an admin user + um.setLocalUserConfigList(new ConcurrentHashMap() { + static final long serialVersionUID = 2L; + { + List roles = new ArrayList(1); + roles.add(UserLevel.SYSTEMADMIN.toString()); + put("admin", new UserConfig("admin", + "7029,7455,8165,7029,7881", roles)); + } + }); + // instantiate an empty activeUser collection + um.setActiveUsers(new ConcurrentHashMap()); + + } + + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#addAAAProvider(org.opendaylight.controller.usermanager.IAAAProvider)} + * . + */ + @Test + public void testAddAAAProvider() { + // instantiate an anonymous AAAProvider + IAAAProvider a3p = new IAAAProvider() { + + public AuthResponse authService(String userName, String password, + String server, String secretKey) { + return new AuthResponse(); + }; + + public String getName() { + return "dummyAAAProvider"; + } + }; + + um.addAAAProvider(a3p); + assertEquals(a3p, um.getAAAProvider("dummyAAAProvider")); + + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#removeAAAProvider(org.opendaylight.controller.usermanager.IAAAProvider)} + * and for for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#getAAAProvider(java.lang.String)} + * . + */ + @Test + public void testRemoveAAAProvider() { + um.removeAAAProvider(um.getAAAProvider("dummyAAAProvider")); + assertTrue(um.getAAAProviderNames().isEmpty()); + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#authenticate(java.lang.String, java.lang.String)} + * . + */ + @Test + public void testAuthenticateStringString() { + List roles = new ArrayList(1); + roles.add(UserLevel.SYSTEMADMIN.toString()); + UserConfig uc = new UserConfig("administrator", "admin", roles); + um.addLocalUser(uc); + AuthResultEnum authResult = um.authenticate("administrator", "admin"); + assertEquals(authResult, AuthResultEnum.AUTH_ACCEPT_LOC); + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#addRemoveLocalUser(org.opendaylight.controller.usermanager.internal.UserConfig, boolean)} + * . + */ + @Test + public void testAddRemoveLocalUser() { + List roles = new ArrayList(1); + roles.add(UserLevel.SYSTEMADMIN.toString()); + UserConfig uc = new UserConfig("sysadmin", "7029,7455,8165,7029,7881", + roles); + um.addLocalUser(uc); + assertTrue(um.getLocalUserList().contains(uc)); + um.removeLocalUser(uc); + assertFalse(um.getLocalUserList().contains(uc)); + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#changeLocalUserPassword(java.lang.String, java.lang.String, java.lang.String)} + * . + */ + @Test + public void testChangeLocalUserPassword() { + // fail("Not yet implemented"); + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#userLogout(java.lang.String)} + * . + */ + @Test + public void testUserLogout() { + // fail("Not yet implemented"); + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#userTimedOut(java.lang.String)} + * . + */ + @Test + public void testUserTimedOut() { + // fail("Not yet implemented"); + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#authenticate(org.springframework.security.core.Authentication)} + * . + */ + @Test + public void testAuthenticateAuthentication() { + // fail("Not yet implemented"); + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#saveLocalUserList()} + * . + */ + @Test + public void testSaveLocalUserList() { + // fail("Not yet implemented"); + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#saveAAAServerList()} + * . + */ + @Test + public void testSaveAAAServerList() { + // fail("Not yet implemented"); + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#saveAuthorizationList()} + * . + */ + @Test + public void testSaveAuthorizationList() { + // fail("Not yet implemented"); + } + + /** + * Test method for + * {@link org.opendaylight.controller.usermanager.internal.UserManagerImpl#readObject(java.io.ObjectInputStream)} + * . + */ + @Test + public void testReadObject() { + // fail("Not yet implemented"); + } + + @Test + public void testGetUserLevel() { + List roles = new ArrayList(2); + roles.add(UserLevel.SYSTEMADMIN.toString()); + roles.add("App1_supervisor"); + um.addLocalUser(new UserConfig("Jack", "password", roles)); + um.authenticate("Jack", "password"); + + roles.clear(); + roles.add("App2Admin"); + roles.add(UserLevel.NETWORKOPERATOR.toString()); + um.addLocalUser(new UserConfig("John", "password", roles)); + + // Run the check on authenticated user + Assert.assertTrue(um.getUserLevel("Jack") == UserLevel.SYSTEMADMIN); + // Run the check on configured users + Assert.assertTrue(um.getUserLevel("John") == UserLevel.NETWORKOPERATOR); + Assert.assertTrue(um.getUserLevel("Andrew") == UserLevel.NOUSER); + } } diff --git a/opendaylight/web/root/src/main/resources/js/open.js b/opendaylight/web/root/src/main/resources/js/open.js index dda63be90e..b82a85a74a 100644 --- a/opendaylight/web/root/src/main/resources/js/open.js +++ b/opendaylight/web/root/src/main/resources/js/open.js @@ -201,7 +201,7 @@ one.main.admin = { var tr = {}; var entry = []; entry.push(value['user']); - entry.push(value['role']); + entry.push(value['roles']); tr['entry'] = entry; tr['id'] = value['user']; body.push(tr); @@ -385,9 +385,11 @@ one.main.admin = { '#' + one.main.admin.id.modal.add.form.name).val(); user['password'] = $modal.find( '#' + one.main.admin.id.modal.add.form.password).val(); - user['role'] = $modal.find( + roles = new Array(); + roles[0] = $modal.find( '#' + one.main.admin.id.modal.add.form.role).find( 'option:selected').attr('value'); + user['roles'] = roles; // password check var verify = $('#'+one.main.admin.id.modal.add.form.verify).val();