本文整理汇总了Java中com.woorea.openstack.keystone.api.TokensResource类的典型用法代码示例。如果您正苦于以下问题:Java TokensResource类的具体用法?Java TokensResource怎么用?Java TokensResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TokensResource类属于com.woorea.openstack.keystone.api包,在下文中一共展示了TokensResource类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAccessWithTenantId
import com.woorea.openstack.keystone.api.TokensResource; //导入依赖的package包/类
private Access getAccessWithTenantId(){
if(PREFERENCES_INITIALIZED == false){
loadPreferences();
PREFERENCES_INITIALIZED = true;
}
Keystone keystone = new Keystone(KEYSTONE_AUTH_URL, new JerseyConnector());
TokensResource tokens = keystone.tokens();
UsernamePassword credentials = new UsernamePassword(KEYSTONE_USERNAME, KEYSTONE_PASSWORD);
Access access = tokens.authenticate(credentials).withTenantName(TENANT_NAME).execute();
keystone.token(access.getToken().getId());
Tenants tenants = keystone.tenants().list().execute();
List<Tenant> tenantsList = tenants.getList();
if (tenants.getList().size() > 0) {
for (Iterator<Tenant> iterator = tenantsList.iterator(); iterator.hasNext();) {
Tenant tenant = (Tenant) iterator.next();
if (tenant.getName().compareTo(TENANT_NAME) == 0) {
TENANT_ID = tenant.getId();
break;
}
}
} else {
throw new RuntimeException("No tenants found!");
}
TokenAuthentication tokenAuth = new TokenAuthentication(access.getToken().getId());
access = tokens.authenticate(tokenAuth).withTenantId(TENANT_ID).execute();
return access;
}
示例2: Keystone
import com.woorea.openstack.keystone.api.TokensResource; //导入依赖的package包/类
public Keystone(String endpoint, OpenStackClientConnector connector) {
super(endpoint, connector);
TOKENS = new TokensResource(this);
TENANTS = new TenantsResource(this);
USERS = new UsersResource(this);
ROLES = new RolesResource(this);
SERVICES = new ServicesResource(this);
ENDPOINTS = new EndpointsResource(this);
}
示例3: tokens
import com.woorea.openstack.keystone.api.TokensResource; //导入依赖的package包/类
public TokensResource tokens() {
return TOKENS;
}