本文整理汇总了Java中org.openstack4j.model.common.Identifier类的典型用法代码示例。如果您正苦于以下问题:Java Identifier类的具体用法?Java Identifier怎么用?Java Identifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Identifier类属于org.openstack4j.model.common包,在下文中一共展示了Identifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildClientFromV3AuthByName
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
/**
* Verify that a driver config that specifies version 3 authentication is
* created properly by the {@link OSClientFactory}.
*/
@Test
public void buildClientFromV3AuthByName() {
ApiAccessConfig config = loadConfig("config/openstack-pool-config-authv3-by-name.json");
OSClientFactory factory = new OSClientFactory(config, this.builderMock);
OSClient<?> client = factory.acquireAuthenticatedClient();
// should create a v3 client
verify(this.builderMock).v3Auth();
verifyNoMoreInteractions(this.builderMock);
// verify v3 builder calls
verify(this.v3BuilderMock).keyStoneUrl("http://nova.host.com:5000/v3");
verify(this.v3BuilderMock).credentials("userName", Domain.of(Identifier.byName("domainName")), "secret");
verify(this.v3BuilderMock).project("projectName", Domain.of(Identifier.byId("domainId")));
verify(this.v3BuilderMock).createAuthenticated();
verifyNoMoreInteractions(this.v3BuilderMock);
verifyNoMoreInteractions(this.v2BuilderMock);
}
示例2: createWithUserIdAndProjectName
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
/**
* When created from userId and projectName one also needs to specify a
* project domain (either via projectDomainId or projectDomainName).
*/
@Test
public void createWithUserIdAndProjectName() {
// with projectDomainName
AuthV3Credentials creds = new AuthV3Credentials("userId", null, null, null, "password", null, "projectName",
"projectDomainName", null);
creds.validate();
assertThat(creds.getProjectId(), is(nullValue()));
assertThat(creds.getProjectName(), is("projectName"));
assertThat(creds.getProjectDomain().getType(), is(Identifier.Type.NAME));
assertThat(creds.getProjectDomain().getId(), is("projectDomainName"));
// with projectDomainId
creds = new AuthV3Credentials("userId", null, null, null, "password", null, "projectName", null,
"projectDomainId");
creds.validate();
assertThat(creds.getProjectId(), is(nullValue()));
assertThat(creds.getProjectName(), is("projectName"));
assertThat(creds.getProjectDomain().getType(), is(Identifier.Type.ID));
assertThat(creds.getProjectDomain().getId(), is("projectDomainId"));
}
示例3: createWithUserNameAndProjectId
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
/**
* When created from userName and projectId one also needs to specify a user
* domain (either via userDomainId or userDomainName).
*/
@Test
public void createWithUserNameAndProjectId() {
// with userDomainName
AuthV3Credentials creds = new AuthV3Credentials(null, "userName", null, "userDomainName", "password",
"projectId", null, null, null);
creds.validate();
assertThat(creds.getUserId(), is(nullValue()));
assertThat(creds.getUserName(), is("userName"));
assertThat(creds.getUserDomain().getType(), is(Identifier.Type.NAME));
assertThat(creds.getUserDomain().getId(), is("userDomainName"));
// with userDomainId
creds = new AuthV3Credentials(null, "userName", "userDomainId", null, "password", "projectId", null, null,
null);
creds.validate();
assertThat(creds.getUserId(), is(nullValue()));
assertThat(creds.getUserName(), is("userName"));
assertThat(creds.getUserDomain().getType(), is(Identifier.Type.ID));
assertThat(creds.getUserDomain().getId(), is("userDomainId"));
}
示例4: authFromServiceConfiguration
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
private OSClient authFromServiceConfiguration() {
final String[] split = cloud.credential().user().split(":");
checkState(split.length == 3, String
.format("Illegal username, expected user to be of format domain:tenant:user, got %s",
cloud.credential().user()));
final String domainId = split[0];
final String tenantId = split[1];
final String userId = split[2];
//todo resolve identifier from credentials
Identifier domainIdentifier = Identifier.byId(domainId);
Identifier tenantIdentifier = Identifier.byId(tenantId);
checkState(cloud.endpoint().isPresent(), "Endpoint is required for Openstack4J Driver.");
return OSFactory.builderV3().endpoint(cloud.endpoint().get())
.credentials(userId, cloud.credential().password(), domainIdentifier)
.scopeToProject(tenantIdentifier).authenticate();
}
示例5: getOSClientV3
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
/**
* Function that authenticates to openstack using v3 APIs.
* @param endPoint
* @param userName
* @param password
* @param domain
* @param project
* @return OSClient object that can be used for other OpenStack operations.
*/
public static void getOSClientV3(String endPoint, String userName, String password,
String domain, String project) {
if(os == null || apiVersion == null ||apiVersion != 3 || ! os.getEndpoint().equals(endPoint)) {
Identifier domainIdentifier = Identifier.byName(domain);
Identifier projectIdentifier = Identifier.byName(project);
os = OSFactory.builderV3()
.scopeToProject(projectIdentifier, domainIdentifier)
.endpoint(endPoint)
.credentials(userName, password, domainIdentifier)
.authenticate();
apiVersion = 3;
}
}
示例6: getOSClientV2
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
/**
* Function that authenticates to openstack using v2 APIs.
* @param endPoint
* @param userName
* @param password
* @param domain
* @param project
* @return OSClient object that can be used for other Openstack operations.
*/
public static void getOSClientV2(String endPoint, String userName, String password,
String domain) {
if(os == null || apiVersion == null ||apiVersion != 2 || ! os.getEndpoint().equals(endPoint)) {
Identifier domainIdentifier = Identifier.byName(domain);
//Identifier projectIdentifier = Identifier.byName(project);
os = OSFactory.builderV3()
//.scopeToProject(projectIdentifier, domainIdentifier)
.endpoint(endPoint)
.credentials(userName, password, domainIdentifier)
.authenticate();
apiVersion = 2;
}
}
示例7: getAvailableSession
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
OSClient.OSClientV3 getAvailableSession(Endpoint endpoint) {
OSClient.OSClientV3 localOs;
Config config = Config.newConfig().withSSLContext(endpoint.getSslContext()).withHostnameVerifier((hostname, session) -> true);
if (connectionsMap.containsKey(endpoint)) {
localOs = OSFactory.clientFromToken(connectionsMap.get(endpoint), Facing.PUBLIC, config);
} else {
String endpointURL;
try {
endpointURL = prepareEndpointURL(endpoint);
} catch (URISyntaxException | MalformedURLException e) {
throw new RuntimeException(e.getMessage(), e);
}
// LOGGER
OSFactory.enableHttpLoggingFilter(log.isDebugEnabled() || log.isInfoEnabled());
Identifier domainIdentifier = Identifier.byId(endpoint.getDomainId());
IOSClientBuilder.V3 keystoneV3Builder = OSFactory.builderV3().perspective(Facing.PUBLIC)
.endpoint(endpointURL)
.credentials(endpoint.getUser(), endpoint.getPassword(), domainIdentifier)
.scopeToProject(Identifier.byName(endpoint.getProject()), domainIdentifier)
.withConfig(config);
localOs = keystoneV3Builder.authenticate();
connectionsMap.put(endpoint, localOs.getToken());
}
return localOs;
}
示例8: authenticateV3
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
public static OpenstackConnectionFactory authenticateV3(String authUrl, String userDomainName) {
Assert.notNull(username, "Username may not be empty, when initializing");
Assert.notNull(password, "Password may not be empty, when initializing");
log.info("Initializing Provider:" + PROVIDER);
osClient = OSFactory.builderV3().endpoint(authUrl).credentials(username, password, Identifier.byName(userDomainName))
.authenticate();
return instance;
}
示例9: authenticateAndGetObjectStorageService
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
private ObjectStorageService authenticateAndGetObjectStorageService() {
String OBJECT_STORAGE_AUTH_URL = "https://identity.open.softlayer.com/v3";
Identifier domainIdentifier = Identifier.byName(DOMAIN_ID);
System.out.println("Authenticating...");
OSClientV3 os = OSFactory.builderV3()
.endpoint(OBJECT_STORAGE_AUTH_URL)
.credentials(USERNAME,PASSWORD, domainIdentifier)
.scopeToProject(Identifier.byId(PROJECT_ID))
.authenticate();
System.out.println("Authenticated successfully!");
ObjectStorageService objectStorage = os.objectStorage();
return objectStorage;
}
开发者ID:ibm-bluemix-mobile-services,项目名称:bluemix-objectstorage-sample-liberty,代码行数:20,代码来源:SimpleServlet.java
示例10: buildOSClient
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
private static OSClient buildOSClient() {
String sslEnabled=configprop.getProperty("OS_ENABLE_SSL");
Boolean isSSLEnabled = new Boolean(sslEnabled);
String v3Authentication=configprop.getProperty("OS_ENABLE_V3_AUTHENTICATION");
Boolean v3AuthenticationEnabled = new Boolean(v3Authentication);
if(v3AuthenticationEnabled)
os = OSFactory.builderV3().useNonStrictSSLClient(isSSLEnabled).scopeToProject(Identifier.byId(configprop.getProperty("OS_TENANT_ID")), Identifier.byName(configprop.getProperty("OS_DOMAIN")))
.credentials(configprop.getProperty("OS_USERNAME"), configprop.getProperty("OS_PASSWORD"), Identifier.byName(configprop.getProperty("OS_DOMAIN"))).endpoint(configprop.getProperty("OS_AUTH_URL"))
.authenticate();
else
os = OSFactory.builderV2().endpoint(configprop.getProperty("OS_AUTH_URL")).credentials(configprop.getProperty("OS_USERNAME"), configprop.getProperty("OS_PASSWORD")).tenantId(configprop.getProperty("OS_TENANT_ID")).useNonStrictSSLClient(isSSLEnabled).authenticate();
return os;
}
示例11: createClient
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
private static OSClient createClient(PluginSettings pluginSettings) throws Exception {
if (OpenStackClientFactory.client == null){
LOG.debug("OpenStackClientFactory - get new token from OpenStack");
}else{
LOG.debug("OpenStackClientFactory - token expired or will expire (" +
OpenStackClientFactory.client.getToken().getExpires().toString() + "), get a new token from OpenStack");
}
if (pluginSettings.getOpenstackKeystoneVersion().equals("3")) {
LOG.debug("Openstack Authentication V3");
LOG.debug("Endpoint : " + pluginSettings.getOpenstackEndpoint());
LOG.debug("User : " + pluginSettings.getOpenstackUser());
LOG.debug("Domain : " + pluginSettings.getOpenstackDomain());
LOG.debug("Tenant : " + pluginSettings.getOpenstackTenant());
return OSFactory.builderV3()
.endpoint(pluginSettings.getOpenstackEndpoint())
.credentials(pluginSettings.getOpenstackUser(), pluginSettings.getOpenstackPassword(), Identifier.byName(pluginSettings.getOpenstackDomain()))
.scopeToProject(Identifier.byName(pluginSettings.getOpenstackTenant()),Identifier.byName(pluginSettings.getOpenstackDomain()))
.authenticate();
} else {
LOG.debug("Openstack Authentication V2");
LOG.debug("Endpoint : " + pluginSettings.getOpenstackEndpoint());
LOG.debug("User : " + pluginSettings.getOpenstackUser());
LOG.debug("Tenant : " + pluginSettings.getOpenstackTenant());
return OSFactory.builder()
.endpoint(pluginSettings.getOpenstackEndpoint())
.credentials(pluginSettings.getOpenstackUser(), pluginSettings.getOpenstackPassword())
.tenantName(pluginSettings.getOpenstackTenant())
.authenticate();
}
}
示例12: create
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
@Override
public V3 create(IBMObjectStorageServiceInfo serviceInfo,
ServiceConnectorConfig serviceConnectorConfig) {
final Identifier domainIdent = Identifier.byName(serviceInfo.getDomainName());
final Identifier projectIdent = Identifier.byName(serviceInfo.getProject());
return OSFactory.builderV3().endpoint(serviceInfo.getAuthUrl())
.credentials(serviceInfo.getUserId(), serviceInfo.getPassword())
.scopeToProject(projectIdent, domainIdent);
}
示例13: createApi
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
private OSClient.OSClientV3 createApi(Cloud cloud, String region) {
return operationUtils.fromProjectAndUserName(cloud, (projectName, userName) -> {
OSClient.OSClientV3 api = OSFactory.builderV3()
.withConfig(getConnectionSettings())
.endpoint(cloud.getEndpoint())
.credentials(userName, cloud.getCredential(), Identifier.byId("default"))
.scopeToProject(Identifier.byName(projectName), Identifier.byName("default"))
.authenticate();
return region != null ? api.useRegion(region) : api;
});
}
示例14: buildContext
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
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;
}
示例15: getUserDomain
import org.openstack4j.model.common.Identifier; //导入依赖的package包/类
/**
* Returns the user's owning domain (if one was given: it is required when
* specifying a user by name via {@link #userName}).
*
* @return
*/
public Domain getUserDomain() {
if (this.userDomainId != null) {
return Domain.of(Identifier.byId(this.userDomainId));
}
if (this.userDomainName != null) {
return Domain.of(Identifier.byName(this.userDomainName));
}
return null;
}