<version>${yang-ext.version}</version>
</dependency>
<!-- bgppcep dependencies -->
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>concepts</artifactId>
- <version>${bgpcep.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>util</artifactId>
- <version>${bgpcep.version}</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.bgpcep</groupId>
<artifactId>framework</artifactId>
</dependency>
<!-- bgppcep dependencies -->
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>concepts</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>util</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.bgpcep</groupId>
<artifactId>framework</artifactId>
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(), // //
<version>${netconf.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>util</artifactId>
- <scope>test</scope>
- <version>0.3.0-SNAPSHOT</version>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-client</artifactId>
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(),
<artifactId>ietf-inet-types</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>util</artifactId>
- </dependency>
-
<dependency>
<groupId>org.opendaylight.bgpcep</groupId>
<artifactId>framework</artifactId>
<artifactId>netconf-api</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>util</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-client</artifactId>
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 {
--- /dev/null
+/*
+ * 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;
+ }
+
+}
<groupId>org.opendaylight.bgpcep</groupId>
<artifactId>framework</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>util</artifactId>
- </dependency>
<dependency>
<groupId>org.osgi</groupId>
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,
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;
return message;
}
+ private static int findByteSequence(final byte[] bytes, final byte[] sequence) {
+ if (bytes.length < sequence.length) {
+ throw new IllegalArgumentException("Sequence to be found is longer than the given byte array.");
+ }
+ if (bytes.length == sequence.length) {
+ if (Arrays.equals(bytes, sequence)) {
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+ int j = 0;
+ for (int i = 0; i < bytes.length; i++) {
+ if (bytes[i] == sequence[j]) {
+ j++;
+ if (j == sequence.length) {
+ return i - j + 1;
+ }
+ } else {
+ j = 0;
+ }
+ }
+ return -1;
+ }
+
private int getAdditionalHeaderEndIndex(byte[] bytes) {
for (byte[] possibleEnd : POSSIBLE_ENDS) {
- int idx = ByteArray.findByteSequence(bytes, possibleEnd);
+ int idx = findByteSequence(bytes, possibleEnd);
if (idx != -1) {
return idx;
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
-import org.opendaylight.protocol.util.ByteArray;
import java.nio.ByteBuffer;
// the length should be only numbers and therefore easily parsed with
// ASCII
this.length = Long.parseLong(Charsets.US_ASCII.decode(
- ByteBuffer.wrap(ByteArray.subByte(bytes, headerBegin.length, bytes.length - headerBegin.length - 1)))
- .toString());
+ ByteBuffer.wrap(bytes, headerBegin.length, bytes.length - headerBegin.length - 1)).toString());
Preconditions.checkState(this.length < Integer.MAX_VALUE && this.length > 0);
this.parsed = true;
return this;