Package: SslManagerServiceOptions

SslManagerServiceOptions

nameinstructionbranchcomplexitylinemethod
SslManagerServiceOptions(Map)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
equals(Object)
M: 35 C: 0
0%
M: 12 C: 0
0%
M: 7 C: 0
0%
M: 13 C: 0
0%
M: 1 C: 0
0%
getConfigurationProperties()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getSslCiphers()
M: 12 C: 10
45%
M: 4 C: 2
33%
M: 3 C: 1
25%
M: 2 C: 2
50%
M: 0 C: 1
100%
getSslKeyStore()
M: 2 C: 20
91%
M: 3 C: 3
50%
M: 3 C: 1
25%
M: 1 C: 3
75%
M: 0 C: 1
100%
getSslKeystorePassword()
M: 2 C: 20
91%
M: 3 C: 3
50%
M: 3 C: 1
25%
M: 1 C: 3
75%
M: 0 C: 1
100%
getSslProtocol()
M: 2 C: 20
91%
M: 3 C: 3
50%
M: 3 C: 1
25%
M: 1 C: 3
75%
M: 0 C: 1
100%
hashCode()
M: 2 C: 15
88%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 3
100%
M: 0 C: 1
100%
isSslHostnameVerification()
M: 6 C: 16
73%
M: 3 C: 3
50%
M: 3 C: 1
25%
M: 1 C: 3
75%
M: 0 C: 1
100%
static {...}
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2018 Eurotech and/or its affiliates
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License v1.0
6: * which accompanies this distribution, and is available at
7: * http://www.eclipse.org/legal/epl-v10.html
8: *
9: * Contributors:
10: * Eurotech
11: *******************************************************************************/
12: package org.eclipse.kura.core.ssl;
13:
14: import java.util.Map;
15:
16: public class SslManagerServiceOptions {
17:
18: public static final String PROP_PROTOCOL = "ssl.default.protocol";
19: public static final String PROP_TRUST_STORE = "ssl.default.trustStore";
20: public static final String PROP_CIPHERS = "ssl.default.cipherSuites";
21: public static final String PROP_HN_VERIFY = "ssl.hostname.verification";
22: public static final String PROP_TRUST_PASSWORD = "ssl.keystore.password";
23:
24: public static final String PROP_DEFAULT_PROTOCOL = "TLSv1";
25: public static final Boolean PROP_DEFAULT_HN_VERIFY = true;
26: public static final String PROP_DEFAULT_TRUST_PASSWORD = "changeit";
27:
28: private final Map<String, Object> properties;
29:
30: public SslManagerServiceOptions(Map<String, Object> properties) {
31: this.properties = properties;
32: }
33:
34: public Map<String, Object> getConfigurationProperties() {
35: return this.properties;
36: }
37:
38: /**
39: * Returns the ssl.default.protocol.
40: *
41: * @return
42: */
43: public String getSslProtocol() {
44:• if (this.properties != null && this.properties.get(PROP_PROTOCOL) != null
45:• && this.properties.get(PROP_PROTOCOL) instanceof String) {
46: return (String) this.properties.get(PROP_PROTOCOL);
47: }
48: return PROP_DEFAULT_PROTOCOL;
49: }
50:
51: /**
52: * Returns the ssl.default.trustStore.
53: *
54: * @return
55: */
56: public String getSslKeyStore() {
57:• if (this.properties != null && this.properties.get(PROP_TRUST_STORE) != null
58:• && this.properties.get(PROP_TRUST_STORE) instanceof String) {
59: return (String) this.properties.get(PROP_TRUST_STORE);
60: }
61: return null;
62: }
63:
64: /**
65: * Returns the ssl.default.trustStore.
66: *
67: * @return
68: */
69: public String getSslCiphers() {
70:• if (this.properties != null && this.properties.get(PROP_CIPHERS) != null
71:• && this.properties.get(PROP_CIPHERS) instanceof String) {
72: return (String) this.properties.get(PROP_CIPHERS);
73: }
74: return null;
75: }
76:
77: /**
78: * Returns the ssl.keystore.password.
79: *
80: * @return
81: */
82: public String getSslKeystorePassword() {
83:• if (this.properties != null && this.properties.get(PROP_TRUST_PASSWORD) != null
84:• && this.properties.get(PROP_TRUST_PASSWORD) instanceof String) {
85: return (String) this.properties.get(PROP_TRUST_PASSWORD);
86: }
87: return PROP_DEFAULT_TRUST_PASSWORD;
88: }
89:
90: /**
91: * Returns the ssl.hostname.verification
92: *
93: * @return
94: */
95: public Boolean isSslHostnameVerification() {
96:• if (this.properties != null && this.properties.get(PROP_HN_VERIFY) != null
97:• && this.properties.get(PROP_HN_VERIFY) instanceof Boolean) {
98: return (Boolean) this.properties.get(PROP_HN_VERIFY);
99: }
100: return PROP_DEFAULT_HN_VERIFY;
101: }
102:
103: @Override
104: public int hashCode() {
105: final int prime = 31;
106: int result = 1;
107:• result = prime * result + (this.properties == null ? 0 : this.properties.hashCode());
108: return result;
109: }
110:
111: @Override
112: public boolean equals(Object obj) {
113:• if (this == obj) {
114: return true;
115: }
116:• if (obj == null) {
117: return false;
118: }
119:• if (!(obj instanceof SslManagerServiceOptions)) {
120: return false;
121: }
122: SslManagerServiceOptions other = (SslManagerServiceOptions) obj;
123:• if (this.properties == null) {
124:• if (other.properties != null) {
125: return false;
126: }
127:• } else if (!this.properties.equals(other.properties)) {
128: return false;
129: }
130: return true;
131: }
132: }