summaryrefslogtreecommitdiffstats
path: root/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java')
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java36
1 files changed, 17 insertions, 19 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java
index c318a3b514..510c0a277c 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.common.http.config;
import fj.data.Either;
@@ -27,6 +26,7 @@ import org.onap.sdc.security.SecurityUtil;
@EqualsAndHashCode
public class ClientCertificate {
+
private String keyStore;
private String keyStorePassword;
@@ -37,28 +37,17 @@ public class ClientCertificate {
setKeyStore(clientCertificate.getKeyStore());
setKeyStorePassword(clientCertificate.getKeyStorePassword(), false);
}
-
- public void setKeyStore(String keyStore) {
- validate(keyStore);
- this.keyStore = keyStore;
- }
-
- public void setKeyStorePassword(String keyStorePassword) {
- setKeyStorePassword(keyStorePassword, true);
- }
private void setKeyStorePassword(String keyStorePassword, boolean isEncoded) {
validate(keyStorePassword);
- if(isEncoded) {
+ if (isEncoded) {
Either<String, String> passkey = SecurityUtil.INSTANCE.decrypt(keyStorePassword);
if (passkey.isLeft()) {
this.keyStorePassword = passkey.left().value();
- }
- else {
+ } else {
throw new IllegalArgumentException(passkey.right().value());
}
- }
- else {
+ } else {
this.keyStorePassword = keyStorePassword;
}
}
@@ -67,10 +56,19 @@ public class ClientCertificate {
return keyStore;
}
+ public void setKeyStore(String keyStore) {
+ validate(keyStore);
+ this.keyStore = keyStore;
+ }
+
public String getKeyStorePassword() {
return keyStorePassword;
}
+ public void setKeyStorePassword(String keyStorePassword) {
+ setKeyStorePassword(keyStorePassword, true);
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@@ -79,9 +77,9 @@ public class ClientCertificate {
builder.append("]");
return builder.toString();
}
-
+
private void validate(String str) {
- if(StringUtils.isEmpty(str)) {
+ if (StringUtils.isEmpty(str)) {
throw new IllegalArgumentException("ClientCertificate keystore and/or kestorePassword cannot be empty");
}
}