本文整理了Java中org.jclouds.openstack.keystone.v2_0.domain.Token.builder()
方法的一些代码示例,展示了Token.builder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Token.builder()
方法的具体详情如下:
包路径:org.jclouds.openstack.keystone.v2_0.domain.Token
类名称:Token
方法名:builder
暂无
代码示例来源:origin: apache/jclouds
@Override public Access apply(HttpResponse from) {
releasePayload(from);
URI storageUrl = null;
String authToken = null;
for (Map.Entry<String, String> entry : from.getHeaders().entries()) {
String header = entry.getKey();
if (header.equalsIgnoreCase(STORAGE_URL)) {
storageUrl = getURI(entry.getValue());
} else if (header.equalsIgnoreCase(AUTH_TOKEN)) {
authToken = entry.getValue();
}
}
if (storageUrl == null || authToken == null) {
throw new AuthorizationException("Invalid headers in TempAuth response " + from);
}
// For portability with keystone, based on common knowledge that these tokens tend to expire in 24 hours
// http://docs.openstack.org/api/openstack-object-storage/1.0/content/authentication-object-dev-guide.html
Date expires = new Date(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(24));
return Access.builder()
.user(User.builder().id(username).name(username).build())
.token(Token.builder().id(authToken).expires(expires).build())
.service(Service.builder().name("Object Storage").type(OBJECT_STORE)
.endpoint(Endpoint.builder().publicURL(storageUrl).id(apiVersion).region(storageUrl.getHost()).build())
.build()).build();
}
代码示例来源:origin: org.apache.jclouds.api/openstack-swift
@Override public Access apply(HttpResponse from) {
releasePayload(from);
URI storageUrl = null;
String authToken = null;
for (Map.Entry<String, String> entry : from.getHeaders().entries()) {
String header = entry.getKey();
if (header.equalsIgnoreCase(STORAGE_URL)) {
storageUrl = getURI(entry.getValue());
} else if (header.equalsIgnoreCase(AUTH_TOKEN)) {
authToken = entry.getValue();
}
}
if (storageUrl == null || authToken == null) {
throw new AuthorizationException("Invalid headers in TempAuth response " + from);
}
// For portability with keystone, based on common knowledge that these tokens tend to expire in 24 hours
// http://docs.openstack.org/api/openstack-object-storage/1.0/content/authentication-object-dev-guide.html
Date expires = new Date(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(24));
return Access.builder()
.user(User.builder().id(username).name(username).build())
.token(Token.builder().id(authToken).expires(expires).build())
.service(Service.builder().name("Object Storage").type(OBJECT_STORE)
.endpoint(Endpoint.builder().publicURL(storageUrl).id(apiVersion).region(storageUrl.getHost()).build())
.build()).build();
}
代码示例来源:origin: Nextdoor/bender
@Override public Access apply(HttpResponse from) {
releasePayload(from);
URI storageUrl = null;
String authToken = null;
for (Map.Entry<String, String> entry : from.getHeaders().entries()) {
String header = entry.getKey();
if (header.equalsIgnoreCase(STORAGE_URL)) {
storageUrl = getURI(entry.getValue());
} else if (header.equalsIgnoreCase(AUTH_TOKEN)) {
authToken = entry.getValue();
}
}
if (storageUrl == null || authToken == null) {
throw new AuthorizationException("Invalid headers in TempAuth response " + from);
}
// For portability with keystone, based on common knowledge that these tokens tend to expire in 24 hours
// http://docs.openstack.org/api/openstack-object-storage/1.0/content/authentication-object-dev-guide.html
Date expires = new Date(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(24));
return Access.builder()
.user(User.builder().id(username).name(username).build())
.token(Token.builder().id(authToken).expires(expires).build())
.service(Service.builder().name("Object Storage").type(OBJECT_STORE)
.endpoint(Endpoint.builder().publicURL(storageUrl).id(apiVersion).region(storageUrl.getHost()).build())
.build()).build();
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testGetToken() {
TokenApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/sometokenorother").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
.getTokenApi().get();
Token token = api.get("sometokenorother");
assertNotNull(token);
assertEquals(token,
Token.builder().id("167eccdc790946969ced473732e8109b").expires(dateService.iso8601SecondsDateParse("2012-04-28T12:42:50Z"))
.tenant(Tenant.builder().id("4cea93f5464b4f1c921fb3e0461d72b5").name("demo").build()).build());
}
代码示例来源:origin: apache/jclouds
public void testGetToken() {
TokenApi api = requestsSendResponses(
keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
authenticatedGET().endpoint(endpoint + "/v2.0/tokens/sometokenorother").build(),
HttpResponse.builder().statusCode(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build())
.getTokenApi().get();
Token token = api.get("sometokenorother");
assertNotNull(token);
assertEquals(token,
Token.builder().id("167eccdc790946969ced473732e8109b").expires(dateService.iso8601SecondsDateParse("2012-04-28T12:42:50Z"))
.tenant(Tenant.builder().id("4cea93f5464b4f1c921fb3e0461d72b5").name("demo").enabled(true).build()).build());
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-locations-jclouds
/**
* Injects into the guts of jclouds' openstack-keystone a token that was requested, which
* should last for only 5 seconds. By sleeping for 10 seconds in the test, it should mean
* the token subsequently used by jclouds will expire by the time the second half of the
* test executes.
*/
private void injectShortLivedTokenForSwiftAuth() throws Exception {
URL endpointUrl = new URL(endpoint);
Credentials creds = new Credentials(identity, credential);
Set<Service> services = getServices(creds);
HttpToolResponse tokenHttpResponse1 = requestTokenWithExplicitLifetime(endpointUrl,
identity, credential, Duration.FIVE_SECONDS);
Access access = Access.builder()
.user(User.builder()
.id(identity)
.name(identity)
.build())
.token(Token.builder()
.id(tokenHttpResponse1.getHeaderLists().get(AuthHeaders.AUTH_TOKEN).get(0))
.expires(new Date(System.currentTimeMillis() + 5000))
.build())
.services(services)
.build();
getAuthCache(context).put(creds, access);
}
代码示例来源:origin: jclouds/legacy-jclouds
@Override
@SelectJson("access")
@Consumes(MediaType.APPLICATION_JSON)
public Access expected() {
return Access.builder()
.token(Token.builder()
.expires(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-12-02T01:44:54Z"))
.id("5afc3adea6654e758b4a9cf01bafe507").build())
.user(User.builder()
.id("bf45fd7586c2410c980c651b918aa850")
.name("nova")
// .username("nova") TODO: add optional username field!
.build()).build();
}
代码示例来源:origin: apache/jclouds
@Override
@SelectJson("access")
@Consumes(MediaType.APPLICATION_JSON)
public Access expected() {
return Access.builder()
.token(Token.builder()
.expires(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-12-02T01:44:54Z"))
.id("5afc3adea6654e758b4a9cf01bafe507").build())
.user(User.builder()
.id("bf45fd7586c2410c980c651b918aa850")
.name("nova")
// .username("nova") TODO: add optional username field!
.build()).build();
}
代码示例来源:origin: jclouds/legacy-jclouds
public Access expected() {
return Access.builder()
.token(Token.builder()
.expires(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-08-01T13:08:52Z"))
.id("946b8ad1ede4422f87ab21dcba27896d")
代码示例来源:origin: jclouds/legacy-jclouds
public Access expected() {
return Access.builder()
.token(Token.builder()
.expires(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-09-29T19:53:45Z"))
.id("b267e2e240624b108b1ed5bba6e5882e")
代码示例来源:origin: apache/jclouds
public Access expected() {
return Access.builder()
.token(Token.builder()
.expires(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-08-01T13:08:52Z"))
.id("946b8ad1ede4422f87ab21dcba27896d")
代码示例来源:origin: apache/jclouds
public Access expected() {
return Access.builder()
.token(Token.builder()
.expires(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-09-29T19:53:45Z"))
.id("b267e2e240624b108b1ed5bba6e5882e")
代码示例来源:origin: jclouds/legacy-jclouds
public Access expected() {
return Access.builder()
.token(Token.builder()
.expires(new SimpleDateFormatDateService().iso8601DateParse("2012-06-06T20:56:47.000-05:00"))
.id("Auth_4f173437e4b013bee56d1007")
代码示例来源:origin: jclouds/legacy-jclouds
public Access expected() {
return Access.builder()
.token(Token.builder()
.expires(new SimpleDateFormatDateService().iso8601DateParse("2012-01-18T21:35:59.050Z"))
.id("Auth_4f173437e4b013bee56d1007")
代码示例来源:origin: apache/jclouds
public Access expected() {
return Access.builder()
.token(Token.builder()
.expires(new SimpleDateFormatDateService().iso8601DateParse("2012-06-06T20:56:47.000-05:00"))
.id("AADMTnolqiuwewdqwdqsdf2324f4234fndquipwou12e08_qw23f2e32f2qw4rf2432fddi_ar23d2q32p_DJOIASdd32d2323d23dqoiwjdaosiqowdijOAQIDJWqowid0aisjd_ajoisdjaoisdj1209ejdalo___qwdqwd---sdpoaqwdsaasdisdjw023d23q23edasd435gtf3g3w4egf4g4323efasdsdvsdvsasdvjmhfg43OINAOISndqaiosjkdq0w")
代码示例来源:origin: apache/jclouds
public Access expected() {
return Access.builder()
.token(Token.builder()
.expires(new SimpleDateFormatDateService().iso8601DateParse("2012-06-06T20:56:47.000-05:00"))
.id("Auth_4f173437e4b013bee56d1007")
代码示例来源:origin: apache/jclouds
public Access expected() {
return Access.builder()
.token(Token.builder()
.expires(new SimpleDateFormatDateService().iso8601DateParse("2012-01-18T21:35:59.050Z"))
.id("Auth_4f173437e4b013bee56d1007")
内容来源于网络,如有侵权,请联系作者删除!