2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowjava.protocol.impl.core;
12 import java.io.FileInputStream;
13 import java.io.FileNotFoundException;
14 import java.io.InputStream;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * Class for storing keys
23 * @author michal.polkorab
25 public final class SslKeyStore {
27 private static final Logger LOGGER = LoggerFactory.getLogger(SslKeyStore.class);
30 * InputStream instance of key - key location is on classpath
31 * @param filename keystore location
32 * @param pathType keystore location type - "classpath" or "path"
34 * @return key as InputStream
36 public static InputStream asInputStream(String filename, PathType pathType) {
40 in = SslKeyStore.class.getResourceAsStream(filename);
42 throw new IllegalStateException("KeyStore file not found: "
47 LOGGER.debug("Current dir using System:"
48 + System.getProperty("user.dir"));
49 File keystorefile = new File(filename);
51 in = new FileInputStream(keystorefile);
52 } catch (FileNotFoundException e) {
53 throw new IllegalStateException("KeyStore file not found: "
58 throw new IllegalArgumentException("Unknown path type: " + pathType);