Integrate OpenFlowJava into OpenFlowPlugin build
[openflowplugin.git] / samples / simple-client / src / main / java / org / opendaylight / openflowjava / protocol / impl / clients / ClientSslTrustStore.java
diff --git a/samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java b/samples/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/ClientSslTrustStore.java
new file mode 100644 (file)
index 0000000..5f7929f
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. 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.openflowjava.protocol.impl.clients;
+
+import java.io.InputStream;
+
+/**
+ * Class for storing keys
+ *
+ * @author michal.polkorab
+ */
+public final class ClientSslTrustStore {
+
+    private static final String KEY_STORE_FILENAME = "/selfSignedController";
+
+    private ClientSslTrustStore() {
+        throw new UnsupportedOperationException("Utility class shouldn't be instantiated");
+    }
+
+    /**
+     * InputStream instance of key
+     *
+     * @return key as InputStream
+     */
+    public static InputStream asInputStream() {
+        InputStream in = ClientSslTrustStore.class.getResourceAsStream(KEY_STORE_FILENAME);
+        if (in == null) {
+            throw new IllegalStateException("KeyStore file not found: " + KEY_STORE_FILENAME);
+        }
+        return in;
+    }
+
+    /**
+     * @return certificate password as char[]
+     */
+    public static char[] getCertificatePassword() {
+        return "opendaylight".toCharArray();
+    }
+
+    /**
+     * @return KeyStore password as char[]
+     */
+    public static char[] getKeyStorePassword() {
+        return "opendaylight".toCharArray();
+    }
+}
\ No newline at end of file