Removed authentication methods 70/112370/2
authorBoslet, Cory <cory.boslet@att.com>
Wed, 9 Sep 2020 14:26:43 +0000 (10:26 -0400)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Wed, 9 Sep 2020 20:06:00 +0000 (16:06 -0400)
Keystone token authentication methods no longer
needed for ONAP use case

Issue-ID: SO-3226
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I17867f05fdc47070292c59f955188568ea5b9367

adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java

index fa5c57f..c7f4509 100644 (file)
@@ -90,22 +90,4 @@ public final class AuthenticationMethodFactory {
         return v3Auth;
     }
 
-    public final com.woorea.openstack.keystone.v3.model.Authentication getAuthenticationForV3(
-            CloudIdentity cloudIdentity) {
-        Identity identity = new Identity();
-        Password password = new Password();
-        User user = new User();
-        Domain userDomain = new Domain();
-        userDomain.setName(cloudIdentity.getUserDomainName());
-        user.setName(cloudIdentity.getMsoId());
-        user.setPassword(CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass()));
-        user.setDomain(userDomain);
-        password.setUser(user);
-        identity.setPassword(password);
-        identity.setMethods(Collections.singletonList("password"));
-        com.woorea.openstack.keystone.v3.model.Authentication v3Auth =
-                new com.woorea.openstack.keystone.v3.model.Authentication();
-        v3Auth.setIdentity(identity);
-        return v3Auth;
-    }
 }
index 50ebcc6..6800428 100644 (file)
@@ -97,7 +97,7 @@ public class MsoCommonUtils {
      * openstack-java-sdk classname of the OpenStackRequest<T> parameter).
      */
 
-    protected <T> T executeAndRecordOpenstackRequest(OpenStackRequest<T> request) {
+    public <T> T executeAndRecordOpenstackRequest(OpenStackRequest<T> request) {
         return executeAndRecordOpenstackRequest(request, true);
     }
 
@@ -174,7 +174,7 @@ public class MsoCommonUtils {
      * Convert an Openstack Exception on a Keystone call to an MsoException. This method supports both
      * OpenstackResponseException and OpenStackConnectException.
      */
-    protected MsoException keystoneErrorToMsoException(OpenStackBaseException e, String context) {
+    public MsoException keystoneErrorToMsoException(OpenStackBaseException e, String context) {
         MsoException me = null;
 
         if (e instanceof OpenStackResponseException) {
@@ -455,15 +455,16 @@ public class MsoCommonUtils {
      */
     protected KeystoneAuthHolder getKeystoneAuthHolder(String cloudSiteId, String tenantId, String serviceName)
             throws MsoException {
-        CloudSite cloudSite =
-                cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
-        String cloudId = cloudSite.getId();
-        String region = cloudSite.getRegionId();
-        CloudIdentity cloudIdentity = cloudSite.getIdentityService();
-        MsoTenantUtils tenantUtils =
-                tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
-        String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
+        CloudIdentity cloudIdentity = null;
         try {
+            CloudSite cloudSite =
+                    cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
+            String cloudId = cloudSite.getId();
+            String region = cloudSite.getRegionId();
+            cloudIdentity = cloudSite.getIdentityService();
+            MsoTenantUtils tenantUtils =
+                    tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
+            String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
             if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType())) {
                 Access access = getKeystone(tenantId, cloudIdentity, keystoneUrl);
                 try {
index 072ab5a..63bc235 100644 (file)
 package org.onap.so.openstack.utils;
 
 import java.util.Map;
-import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
 import org.onap.so.db.catalog.beans.CloudIdentity;
-import org.onap.so.db.catalog.beans.CloudSite;
 import org.onap.so.openstack.beans.MsoTenant;
 import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
 import org.onap.so.openstack.exceptions.MsoException;
-import org.onap.so.utils.CryptoUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
-import com.woorea.openstack.keystone.v3.model.Token;
-import com.woorea.openstack.base.client.OpenStackConnectException;
-import com.woorea.openstack.base.client.OpenStackResponseException;
-import com.woorea.openstack.keystone.v3.Keystone;
-import com.woorea.openstack.keystone.v3.api.TokensResource.Authenticate;
-import com.woorea.openstack.keystone.v3.model.Authentication;
-import com.woorea.openstack.keystone.v3.model.Authentication.Identity;
 
 @Component
 public class MsoKeystoneV3Utils extends MsoTenantUtils {
 
-    @Autowired
-    private AuthenticationMethodFactory authenticationMethodFactory;
-
     @Override
     public String createTenant(String tenantName, String cloudSiteId, Map<String, String> metadata, boolean backout)
             throws MsoException {
@@ -71,22 +57,4 @@ public class MsoKeystoneV3Utils extends MsoTenantUtils {
         return cloudIdentity.getIdentityUrl();
     }
 
-    public Token getKeystoneToken(CloudSite cloudSite) throws MsoException {
-        try {
-            CloudIdentity cloudIdentity = cloudSite.getIdentityService();
-
-            Keystone keystone = new Keystone(cloudIdentity.getIdentityUrl());
-
-            Authentication auth = authenticationMethodFactory.getAuthenticationForV3(cloudIdentity);
-
-            Authenticate authenticate = keystone.tokens().authenticate(auth);
-            return executeAndRecordOpenstackRequest(authenticate);
-
-        } catch (OpenStackResponseException e) {
-            throw keystoneErrorToMsoException(e, "TokenAuth");
-        } catch (OpenStackConnectException e) {
-            throw keystoneErrorToMsoException(e, "TokenAuth");
-        }
-    }
-
 }