myAccess = new Access(); myAccess.registerErrorHandler(xyz); myAccess.authenticate(.....);
@Override public String toString() { return string().toString(); }
@ManagedBean(name="accessBacking") @SessionScoped public class AccessBacking { private String username; private String password; public boolean checkViewAccess() { Access access = new Access(); if(access.authenticate(username, password)) { // user is logged in } } }
@Override public String get() { return supplier.get().getToken().getId(); } };
@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(); }
public String get() { return supplier.get().getToken().getId(); } };
@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(); }
public String get() { return supplier.get().getToken().getId(); } };
@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(); }
public Access build() { return new Access(token, user, serviceCatalog.build()); }
@Override public String toString() { return string().toString(); }
@Override public String get() { return supplier.get().getToken().getId(); } };
/** * 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); }
public Access build() { return new Access(token, user, serviceCatalog.build()); }
@Override public String toString() { return string().toString(); }
public Optional<Tenant> apply(Access in){ return in.getToken().getTenant(); } }