summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-09-16 14:16:42 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-16 14:16:42 +0000
commit5f2674b6597dcec70fb31434d23ba3b84a0d5970 (patch)
tree46afd59612f144667d322dd73f88d154b041b73d
parent758ff096dee1bb8d187f8cb06a460c26fc5c0118 (diff)
parent0bab151e204c0f5cef6f5c45b7f03594535b41c9 (diff)
Merge "Removed authentication methods"
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java18
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java21
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java32
3 files changed, 11 insertions, 60 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
index fa5c57f447..c7f4509237 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
@@ -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;
- }
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
index 50ebcc66ee..6800428a62 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
@@ -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 {
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java
index 072ab5a8d0..63bc235363 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java
@@ -21,29 +21,15 @@
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");
- }
- }
-
}