aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-04-18 16:57:11 -0400
committerRob Daugherty <rd472p@att.com>2018-04-18 17:07:26 -0400
commit9218d80e65bf3eaa01e7942730bac8c72dcb7862 (patch)
tree2c3d32d4b1bb532d75b8bf2c65afc827e9add69c /bpmn/MSOCommonBPMN/src
parentcb28756cf544a5dd6d35d6a134a471181c0abcc1 (diff)
AAIRestClient support for Basic Auth
Adding support for Basic Auth in the AAI Rest Clients because ONAP uses this (whereas ECOMP uses 2-way SSL). In general, each AAI client will allow the user to configure properties called "aai.auth" and "mso.msoKey". If these are set, then the client will add the Authorization header to every request. Change-Id: I7c81ec05d2ec4a7dca131f2e9e19d341ac89b09f Issue-ID: SO-576 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java22
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java9
2 files changed, 10 insertions, 21 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java
index 3e315a5f04..16fd351b43 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java
@@ -21,7 +21,6 @@
package org.openecomp.mso.client.adapter.vnf;
import java.net.URI;
-import java.security.GeneralSecurityException;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
@@ -29,8 +28,6 @@ import java.util.UUID;
import javax.ws.rs.client.ClientResponseFilter;
import javax.ws.rs.ext.ContextResolver;
-import org.apache.commons.codec.binary.Base64;
-import org.openecomp.mso.bpmn.common.util.CryptoUtils;
import org.openecomp.mso.client.ResponseExceptionMapperImpl;
import org.openecomp.mso.client.policy.JettisonStyleMapperProvider;
import org.openecomp.mso.client.policy.RestClient;
@@ -52,8 +49,7 @@ public class AdapterRestClient extends RestClient {
@Override
protected void initializeHeaderMap(Map<String, String> headerMap) {
- headerMap.put("Authorization",
- this.getBasicAuth(props.getAuth(), props.getKey()));
+ addBasicAuthHeader(props.getAuth(), props.getKey());
}
@Override
@@ -70,20 +66,4 @@ public class AdapterRestClient extends RestClient {
protected ContextResolver<ObjectMapper> getMapper() {
return new JettisonStyleMapperProvider();
}
-
- private String getBasicAuth(String encryptedAuth, String msoKey) {
- if ((encryptedAuth == null || encryptedAuth.isEmpty()) || (msoKey == null || msoKey.isEmpty())) {
- return null;
- }
- try {
- String auth = CryptoUtils.decrypt(encryptedAuth, msoKey);
- byte[] encoded = Base64.encodeBase64(auth.getBytes());
- String encodedString = new String(encoded);
- encodedString = "Basic " + encodedString;
- return encodedString;
- } catch (GeneralSecurityException e) {
- this.logger.warn(e.getMessage(), e);
- return null;
- }
- }
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java
index 27352dc11d..a1ef35a49d 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java
@@ -52,4 +52,13 @@ public class AAIPropertiesImpl implements AAIProperties {
return AAIVersion.LATEST;
}
+ @Override
+ public String getAuth() {
+ return props.get("aai.auth");
+ }
+
+ @Override
+ public String getKey() {
+ return props.get("mso.msoKey");
+ }
}