Bug 5377: Support configuring cipher suites to use for SSLEngine
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / connection / TlsConfigurationImpl.java
1 /*
2  * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowjava.protocol.api.connection;
10
11 import java.util.List;
12
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType;
15
16 /**
17  * Class is used only for testing purposes - passwords are hardcoded
18  * @author michal.polkorab
19  */
20 public class TlsConfigurationImpl implements TlsConfiguration {
21
22     private KeystoreType trustStoreType;
23     private String trustStore;
24     private KeystoreType keyStoreType;
25     private String keyStore;
26     private PathType keystorePathType;
27     private PathType truststorePathType;
28     private List<String> cipherSuites;
29
30     /**
31      * Default constructor
32      * @param trustStoreType JKS or PKCS12
33      * @param trustStore path to trustStore file
34      * @param trustStorePathType truststore path type (classpath or path)
35      * @param keyStoreType JKS or PKCS12
36      * @param keyStore path to keyStore file
37      * @param keyStorePathType keystore path type (classpath or path)
38      */
39     public TlsConfigurationImpl(KeystoreType trustStoreType, String trustStore,
40             PathType trustStorePathType, KeystoreType keyStoreType,
41             String keyStore, PathType keyStorePathType,
42             List<String> cipherSuites) {
43         this.trustStoreType = trustStoreType;
44         this.trustStore = trustStore;
45         this.truststorePathType = trustStorePathType;
46         this.keyStoreType = keyStoreType;
47         this.keyStore = keyStore;
48         this.keystorePathType = keyStorePathType;
49         this.cipherSuites = cipherSuites;
50     }
51
52     @Override
53     public KeystoreType getTlsTruststoreType() {
54         return trustStoreType;
55     }
56
57     @Override
58     public String getTlsTruststore() {
59         return trustStore;
60     }
61
62     @Override
63     public KeystoreType getTlsKeystoreType() {
64         return keyStoreType;
65     }
66
67     @Override
68     public String getTlsKeystore() {
69         return keyStore;
70     }
71
72     @Override
73     public PathType getTlsKeystorePathType() {
74         return keystorePathType;
75     }
76
77     @Override
78     public PathType getTlsTruststorePathType() {
79         return truststorePathType;
80     }
81
82     @Override
83     public String getKeystorePassword() {
84         return "opendaylight";
85     }
86
87     @Override
88     public String getCertificatePassword() {
89         return "opendaylight";
90     }
91
92     @Override
93     public String getTruststorePassword() {
94         return "opendaylight";
95     }
96
97     @Override
98     public List<String> getCipherSuites() {
99         return cipherSuites;
100     }
101 }