From 1208cf638d47c7908604ab04eaf0e1dbaa67c9cb Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 16 Jan 2014 10:49:24 +0100 Subject: [PATCH] Remove dependecies on bgpcep concepts/util Change-Id: I2d1c1175ee06e77e0d6e3a31b98cd44843572bc6 Signed-off-by: Robert Varga --- opendaylight/commons/opendaylight/pom.xml | 10 ---- .../distribution/opendaylight/pom.xml | 8 --- .../test/sal/binding/it/TestHelper.java | 1 - .../md-sal/sal-netconf-connector/pom.xml | 6 -- .../it/ServiceProviderController.java | 1 - opendaylight/netconf/netconf-impl/pom.xml | 5 -- opendaylight/netconf/netconf-it/pom.xml | 5 -- .../netconf/it/NetconfITSecureTest.java | 1 - .../controller/netconf/it/SSLUtil.java | 60 +++++++++++++++++++ opendaylight/netconf/netconf-util/pom.xml | 5 -- .../util/messages/NetconfMessageFactory.java | 28 ++++++++- .../util/messages/NetconfMessageHeader.java | 4 +- 12 files changed, 87 insertions(+), 47 deletions(-) create mode 100644 opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/SSLUtil.java diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index 67da0228fe..d49437fbaf 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -694,16 +694,6 @@ ${yang-ext.version} - - org.opendaylight.bgpcep - concepts - ${bgpcep.version} - - - org.opendaylight.bgpcep - util - ${bgpcep.version} - org.opendaylight.bgpcep framework diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index a8dd607f44..22799281e2 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -1365,14 +1365,6 @@ - - org.opendaylight.bgpcep - concepts - - - org.opendaylight.bgpcep - util - org.opendaylight.bgpcep framework diff --git a/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java b/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java index 2e2d770872..82ad7cffe2 100644 --- a/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java +++ b/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java @@ -39,7 +39,6 @@ public class TestHelper { public static Option configMinumumBundles() { return new DefaultCompositeOption( mavenBundle("org.opendaylight.bgpcep", "framework").versionAsInProject(), // - mavenBundle("org.opendaylight.bgpcep", "util").versionAsInProject(), // mavenBundle("commons-codec", "commons-codec").versionAsInProject(), mavenBundle(CONTROLLER, "config-api").versionAsInProject(), // // diff --git a/opendaylight/md-sal/sal-netconf-connector/pom.xml b/opendaylight/md-sal/sal-netconf-connector/pom.xml index 67e2934a0e..770056f825 100644 --- a/opendaylight/md-sal/sal-netconf-connector/pom.xml +++ b/opendaylight/md-sal/sal-netconf-connector/pom.xml @@ -81,12 +81,6 @@ ${netconf.version} test - - org.opendaylight.bgpcep - util - test - 0.3.0-SNAPSHOT - ${project.groupId} netconf-client diff --git a/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java b/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java index b8ebedfdfb..a9637f8672 100644 --- a/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java +++ b/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java @@ -221,7 +221,6 @@ public class ServiceProviderController { mavenBundle(ODL, "config-persister-impl").versionAsInProject(), mavenBundle("org.opendaylight.bgpcep", "framework").versionAsInProject(), - mavenBundle("org.opendaylight.bgpcep", "util").versionAsInProject(), mavenBundle(YANG, "binding-generator-spi").versionAsInProject(), // mavenBundle(YANG, "binding-model-api").versionAsInProject(), // mavenBundle(YANG, "binding-generator-util").versionAsInProject(), diff --git a/opendaylight/netconf/netconf-impl/pom.xml b/opendaylight/netconf/netconf-impl/pom.xml index 27db4729ae..981a81d7b6 100644 --- a/opendaylight/netconf/netconf-impl/pom.xml +++ b/opendaylight/netconf/netconf-impl/pom.xml @@ -46,11 +46,6 @@ ietf-inet-types - - org.opendaylight.bgpcep - util - - org.opendaylight.bgpcep framework diff --git a/opendaylight/netconf/netconf-it/pom.xml b/opendaylight/netconf/netconf-it/pom.xml index 504c5220c6..5e8f29193a 100644 --- a/opendaylight/netconf/netconf-it/pom.xml +++ b/opendaylight/netconf/netconf-it/pom.xml @@ -40,11 +40,6 @@ netconf-api test - - org.opendaylight.bgpcep - util - test - ${project.groupId} netconf-client diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java index 91b543b4de..793a756d54 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java @@ -43,7 +43,6 @@ import org.opendaylight.controller.netconf.impl.NetconfServerSessionListenerFact import org.opendaylight.controller.netconf.impl.NetconfServerSessionNegotiatorFactory; import org.opendaylight.controller.netconf.impl.SessionIdProvider; import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl; -import org.opendaylight.protocol.util.SSLUtil; public class NetconfITSecureTest extends AbstractConfigTest { diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/SSLUtil.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/SSLUtil.java new file mode 100644 index 0000000000..07ca2f134d --- /dev/null +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/SSLUtil.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.netconf.it; + +import java.io.IOException; +import java.io.InputStream; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; + +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; + +import com.google.common.base.Preconditions; + +public final class SSLUtil { + + private SSLUtil() { + } + + public static SSLContext initializeSecureContext(final String pass, final InputStream ksKeysFile, final InputStream ksTrustFile, + final String algorithm) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, + UnrecoverableKeyException, KeyManagementException { + + Preconditions.checkNotNull(ksTrustFile, "ksTrustFile cannot be null"); + Preconditions.checkNotNull(ksKeysFile, "ksKeysFile cannot be null"); + + final char[] passphrase = pass.toCharArray(); + + // First initialize the key and trust material. + final KeyStore ksKeys = KeyStore.getInstance("JKS"); + ksKeys.load(ksKeysFile, passphrase); + final KeyStore ksTrust = KeyStore.getInstance("JKS"); + ksTrust.load(ksTrustFile, passphrase); + + // KeyManager's decide which key material to use. + final KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); + kmf.init(ksKeys, passphrase); + + // TrustManager's decide whether to allow connections. + final TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm); + tmf.init(ksTrust); + + final SSLContext sslContext = SSLContext.getInstance("TLS"); + + // Create/initialize the SSLContext with key material + sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); + return sslContext; + } + +} diff --git a/opendaylight/netconf/netconf-util/pom.xml b/opendaylight/netconf/netconf-util/pom.xml index 353dd1aae7..2f6da9e3c6 100644 --- a/opendaylight/netconf/netconf-util/pom.xml +++ b/opendaylight/netconf/netconf-util/pom.xml @@ -30,10 +30,6 @@ org.opendaylight.bgpcep framework - - org.opendaylight.bgpcep - util - org.osgi @@ -102,7 +98,6 @@ org.opendaylight.controller.netconf.api, org.opendaylight.controller.netconf.mapping.api, org.opendaylight.protocol.framework, - org.opendaylight.protocol.util, org.osgi.framework, org.slf4j, org.w3c.dom, diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageFactory.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageFactory.java index 9097da4d91..6f86cc37f9 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageFactory.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/messages/NetconfMessageFactory.java @@ -20,7 +20,6 @@ import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.opendaylight.protocol.framework.DeserializerException; import org.opendaylight.protocol.framework.DocumentedException; import org.opendaylight.protocol.framework.ProtocolMessageFactory; -import org.opendaylight.protocol.util.ByteArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Comment; @@ -77,9 +76,34 @@ public final class NetconfMessageFactory implements ProtocolMessageFactory 0); this.parsed = true; return this; -- 2.36.6