Search in sources :

Example 21 with CloudIdentity

use of org.onap.so.db.catalog.beans.CloudIdentity in project so by onap.

the class R__CloudConfigMigration method migrateCloudIdentity.

private void migrateCloudIdentity(Collection<CloudIdentity> entities, Connection connection) throws SQLException {
    logger.debug("Starting migration for CloudConfig-->IdentityService");
    String insert = "INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `PROJECT_DOMAIN_NAME`, `USER_DOMAIN_NAME`) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?);";
    try (Statement stmt = connection.createStatement();
        PreparedStatement ps = connection.prepareStatement(insert)) {
        for (CloudIdentity cloudIdentity : entities) {
            try (ResultSet rows = stmt.executeQuery("Select count(1) from identity_services where id='" + cloudIdentity.getId() + "'")) {
                int count = 0;
                while (rows.next()) {
                    count = rows.getInt(1);
                }
                if (count == 0) {
                    ps.setString(1, cloudIdentity.getId());
                    ps.setString(2, cloudIdentity.getIdentityUrl());
                    ps.setString(3, cloudIdentity.getMsoId());
                    ps.setString(4, cloudIdentity.getMsoPass());
                    ps.setString(5, cloudIdentity.getAdminTenant());
                    ps.setString(6, cloudIdentity.getMemberRole());
                    ps.setBoolean(7, cloudIdentity.getTenantMetadata());
                    ps.setString(8, cloudIdentity.getIdentityServerType() != null ? cloudIdentity.getIdentityServerType().name() : null);
                    ps.setString(9, cloudIdentity.getIdentityAuthenticationType() != null ? cloudIdentity.getIdentityAuthenticationType().name() : null);
                    ps.setString(10, FLYWAY);
                    ps.setString(11, cloudIdentity.getProjectDomainName());
                    ps.setString(12, cloudIdentity.getUserDomainName());
                    ps.executeUpdate();
                }
            }
        }
    }
}
Also used : PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 22 with CloudIdentity

use of org.onap.so.db.catalog.beans.CloudIdentity in project so by onap.

the class DeleteAAIInventory method heatbridge.

public void heatbridge(CloudInformation cloudInformation) throws MsoCloudSiteNotFound, HeatBridgeException {
    logger.debug("Heatbridge delete executing");
    CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()).orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId()));
    if (cloudSite.getOrchestrator() != null && MULTICLOUD_MODE.equalsIgnoreCase(cloudSite.getOrchestrator())) {
        logger.debug("Skipping Heatbridge as CloudSite orchestrator is: " + MULTICLOUD_MODE);
        return;
    }
    CloudIdentity cloudIdentity = cloudSite.getIdentityService();
    HeatBridgeApi heatBridgeClient = createClient(getAaiClient(), cloudSite, cloudIdentity, cloudInformation);
    heatBridgeClient.authenticate();
    heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId());
}
Also used : MsoCloudSiteNotFound(org.onap.so.openstack.exceptions.MsoCloudSiteNotFound) CloudSite(org.onap.so.db.catalog.beans.CloudSite) CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) HeatBridgeApi(org.onap.so.heatbridge.HeatBridgeApi)

Example 23 with CloudIdentity

use of org.onap.so.db.catalog.beans.CloudIdentity in project so by onap.

the class AuthenticationMethodTest method testCoreUsernamePasswordAuthFromCloudIdentity.

@Test
public void testCoreUsernamePasswordAuthFromCloudIdentity() {
    CloudIdentity ci = new CloudIdentity();
    ci.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD);
    ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
    ci.setMsoId("someuser");
    Authentication auth = authenticationMethodFactory.getAuthenticationFor(ci);
    assertTrue(UsernamePassword.class.equals(auth.getClass()));
}
Also used : RackspaceAuthentication(org.onap.so.cloud.authentication.models.RackspaceAuthentication) Authentication(com.woorea.openstack.keystone.model.Authentication) CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) UsernamePassword(com.woorea.openstack.keystone.model.authentication.UsernamePassword) Test(org.junit.Test)

Example 24 with CloudIdentity

use of org.onap.so.db.catalog.beans.CloudIdentity in project so by onap.

the class AuthenticationMethodTest method testCoreUsernamePasswordAuth.

@Test
public void testCoreUsernamePasswordAuth() {
    CloudIdentity ci = new CloudIdentity();
    ci.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD);
    ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
    ci.setMsoId("someuser");
    Authentication auth = authenticationMethodFactory.getAuthenticationFor(ci);
    assertTrue(UsernamePassword.class.equals(auth.getClass()));
}
Also used : RackspaceAuthentication(org.onap.so.cloud.authentication.models.RackspaceAuthentication) Authentication(com.woorea.openstack.keystone.model.Authentication) CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) UsernamePassword(com.woorea.openstack.keystone.model.authentication.UsernamePassword) Test(org.junit.Test)

Example 25 with CloudIdentity

use of org.onap.so.db.catalog.beans.CloudIdentity in project so by onap.

the class AuthenticationMethodTest method testCustomRackspaceAuthFromCloudIdentity.

@Test
public void testCustomRackspaceAuthFromCloudIdentity() {
    CloudIdentity ci = new CloudIdentity();
    ci.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
    ci.setMsoPass("FD205490A48D48475607C36B9AD902BF");
    ci.setMsoId("test");
    Authentication auth = authenticationMethodFactory.getAuthenticationFor(ci);
    assertTrue(RackspaceAuthentication.class.equals(auth.getClass()));
}
Also used : RackspaceAuthentication(org.onap.so.cloud.authentication.models.RackspaceAuthentication) Authentication(com.woorea.openstack.keystone.model.Authentication) CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) RackspaceAuthentication(org.onap.so.cloud.authentication.models.RackspaceAuthentication) Test(org.junit.Test)

Aggregations

CloudIdentity (org.onap.so.db.catalog.beans.CloudIdentity)26 Test (org.junit.Test)13 CloudSite (org.onap.so.db.catalog.beans.CloudSite)12 Authentication (com.woorea.openstack.keystone.model.Authentication)8 RackspaceAuthentication (org.onap.so.cloud.authentication.models.RackspaceAuthentication)6 OpenStackConnectException (com.woorea.openstack.base.client.OpenStackConnectException)4 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)4 UsernamePassword (com.woorea.openstack.keystone.model.authentication.UsernamePassword)4 MsoAdapterException (org.onap.so.openstack.exceptions.MsoAdapterException)4 MsoCloudSiteNotFound (org.onap.so.openstack.exceptions.MsoCloudSiteNotFound)4 Keystone (com.woorea.openstack.keystone.Keystone)3 Access (com.woorea.openstack.keystone.model.Access)3 MsoException (org.onap.so.openstack.exceptions.MsoException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Identity (com.woorea.openstack.keystone.v3.model.Authentication.Identity)2 Password (com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password)2 User (com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password.User)2 Domain (com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password.User.Domain)2 Scope (com.woorea.openstack.keystone.v3.model.Authentication.Scope)2 Project (com.woorea.openstack.keystone.v3.model.Authentication.Scope.Project)2