Search in sources :

Example 1 with Authentication

use of com.woorea.openstack.keystone.v3.model.Authentication in project ovirt-engine by oVirt.

the class KeystoneV3TokenProviderTest method verifyAuthentication.

private void verifyAuthentication(boolean hasProject) {
    verify(tokenProvider).requestToken(authenticationCaptor.capture());
    Authentication authentication = authenticationCaptor.getValue();
    assertThat(authentication, notNullValue());
    Authentication.Identity.Password.User user = authentication.getIdentity().getPassword().getUser();
    assertThat(user, notNullValue());
    assertThat(user.getPassword(), is(PASSWORD));
    assertThat(user.getName(), is(USERNAME));
    Authentication.Identity.Password.User.Domain domain = user.getDomain();
    assertThat(domain, notNullValue());
    assertThat(domain.getName(), is(USER_DOMAIN_NAME));
    if (hasProject) {
        Authentication.Scope.Project project = authentication.getScope().getProject();
        assertThat(project, notNullValue());
        assertThat(project.getName(), is(PROJECT_NAME));
        Authentication.Scope.Project.Domain projectDomain = project.getDomain();
        assertThat(projectDomain, notNullValue());
        assertThat(projectDomain.getName(), is(PROJECT_DOMAIN_NAME));
    } else {
        assertNull(authentication.getScope());
    }
}
Also used : Authentication(com.woorea.openstack.keystone.v3.model.Authentication)

Example 2 with Authentication

use of com.woorea.openstack.keystone.v3.model.Authentication in project ovirt-engine by oVirt.

the class KeystoneV3TokenProvider method createToken.

private String createToken() {
    OpenStackProviderProperties providerProperties = provider.getAdditionalProperties();
    Authentication auth = new Authentication();
    auth.setIdentity(Authentication.Identity.password(providerProperties.getUserDomainName(), provider.getUsername(), provider.getPassword()));
    if (StringUtils.isNotEmpty(providerProperties.getProjectName())) {
        auth.setScope(Authentication.Scope.project(providerProperties.getProjectDomainName(), providerProperties.getProjectName()));
    }
    return getTokenId(requestToken(auth));
}
Also used : OpenStackProviderProperties(org.ovirt.engine.core.common.businessentities.OpenStackProviderProperties) Authentication(com.woorea.openstack.keystone.v3.model.Authentication)

Example 3 with Authentication

use of com.woorea.openstack.keystone.v3.model.Authentication in project so by onap.

the class KeystoneV3Authentication method getToken.

public KeystoneAuthHolder getToken(CloudSite cloudSite, String tenantId, String type) throws MsoException {
    String cloudId = cloudSite.getId();
    String region = cloudSite.getRegionId();
    CloudIdentity cloudIdentity = cloudSite.getIdentityService();
    MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
    String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
    Keystone keystoneTenantClient = new Keystone(keystoneUrl);
    Authentication v3Credentials = authenticationMethodFactory.getAuthenticationForV3(cloudIdentity, tenantId);
    OpenStackRequest<Token> v3Request = keystoneTenantClient.tokens().authenticate(v3Credentials);
    return makeRequest(v3Request, type, region);
}
Also used : Keystone(com.woorea.openstack.keystone.v3.Keystone) Authentication(com.woorea.openstack.keystone.v3.model.Authentication) CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) MsoTenantUtils(org.onap.so.openstack.utils.MsoTenantUtils) Token(com.woorea.openstack.keystone.v3.model.Token)

Aggregations

Authentication (com.woorea.openstack.keystone.v3.model.Authentication)3 Keystone (com.woorea.openstack.keystone.v3.Keystone)1 Token (com.woorea.openstack.keystone.v3.model.Token)1 CloudIdentity (org.onap.so.db.catalog.beans.CloudIdentity)1 MsoTenantUtils (org.onap.so.openstack.utils.MsoTenantUtils)1 OpenStackProviderProperties (org.ovirt.engine.core.common.businessentities.OpenStackProviderProperties)1