org.openstack4j.model.common.Identifier Java Examples

The following examples show how to use org.openstack4j.model.common.Identifier. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwiftStorageService.java    From front50 with Apache License 2.0 6 votes vote down vote up
public SwiftStorageService(
    String containerName,
    String identityEndpoint,
    String username,
    String password,
    String projectName,
    String domainName) {
  OSClient.OSClientV3 os =
      OSFactory.builderV3()
          .endpoint(identityEndpoint)
          .credentials(username, password, Identifier.byName(domainName))
          .scopeToProject(Identifier.byName(projectName), Identifier.byName(domainName))
          .authenticate();
  this.token = os.getToken();
  this.swift = os.objectStorage();
  this.containerName = containerName;
}
 
Example #2
Source File: OpenStackClient.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
private Token createToken(KeystoneCredentialView osCredential) {
    if (osCredential == null) {
        throw new CredentialVerificationException("Empty credential");
    }
    if (osCredential.getScope() == null) {
        throw new CredentialVerificationException("Null scope not supported");
    }
    switch (osCredential.getScope()) {
        case CB_KEYSTONE_V3_DOMAIN_SCOPE:
            return OSFactory.builderV3().withConfig(config).endpoint(osCredential.getEndpoint())
                    .credentials(osCredential.getUserName(), osCredential.getPassword(), Identifier.byName(osCredential.getUserDomain()))
                    .scopeToDomain(Identifier.byName(osCredential.getDomainName()))
                    .authenticate()
                    .getToken();
        case CB_KEYSTONE_V3_PROJECT_SCOPE:
            return OSFactory.builderV3().withConfig(config).endpoint(osCredential.getEndpoint())
                    .credentials(osCredential.getUserName(), osCredential.getPassword(), Identifier.byName(osCredential.getUserDomain()))
                    .scopeToProject(Identifier.byName(osCredential.getProjectName()), Identifier.byName(osCredential.getProjectDomain()))
                    .authenticate()
                    .getToken();
        default:
            throw new CredentialVerificationException("Scope not supported: " + osCredential.getScope());
    }
}
 
Example #3
Source File: NovaV3Context.java    From karamel with Apache License 2.0 5 votes vote down vote up
public static IOSClientBuilder.V3 buildContext(NovaCredentials credentials) {
  Properties properties = new Properties();
  String[] parts = credentials.getAccountName().split(":");

  logger.info(String.format("Creds : %s", String.join(", ", parts)));
  logger.info(String.format("Creds : endpoint %s", credentials.getEndpoint()));
  logger.info(String.format("Creds : pass %s", credentials.getAccountPass()));

  IOSClientBuilder.V3 builder = OSFactory.builderV3()
              .endpoint(credentials.getEndpoint())
              .credentials(parts[2], credentials.getAccountPass(), Identifier.byName(parts[0]))
              .scopeToProject(Identifier.byName(parts[1]), Identifier.byName(parts[0]));
 
  return builder;
}