@Override public boolean apply(ComputeMetadata computeMetadata) { String region = null; String zone = null; Location location = computeMetadata.getLocation(); while (location != null) { switch (location.getScope()) { case ZONE: zone = location.getId(); break; case REGION: region = location.getId(); break; } location = location.getParent(); } if (regions != null && region != null && !regions.contains(region)) return false; if (zones != null && zone != null && !zones.contains(zone)) return false; return true; } };
public LoginCredentials build() { if (identity == null && password == null && privateKey == null && !authenticateSudo) return null; return new LoginCredentials(identity, password, privateKey, authenticateSudo); } }
public Builder credential(String credential) { if (isPrivateKeyCredential(credential)) return noPassword().privateKey(credential); else if (credential != null) return password(credential).noPrivateKey(); return this; }
public static Builder builder(Credentials creds) { if (creds == null) return builder(); if (creds instanceof LoginCredentials) return LoginCredentials.class.cast(creds).toBuilder(); else return builder().identity(creds.identity).credential(creds.credential); }
if (locationString != null) { for (Location loc : blobStore.listAssignableLocations()) { if (loc.getId().equalsIgnoreCase(locationString)) { location = loc; break;
@SuppressWarnings("unchecked") public T build() { return (T) new Credentials(identity, credential); } }
public MutableResourceMetadataImpl(ResourceMetadata<T> from) { this.type = from.getType(); this.id = from.getProviderId(); this.name = from.getName(); this.location = from.getLocation(); this.uri = from.getUri(); this.userMetadata = from.getUserMetadata(); }
public void testLoginConsistentAcrossMultipleInjectorsAndLooksNiceWithSudo() throws IOException { Map<String, InputStream> map = getMap(createInjector()); LoginCredentials creds = LoginCredentials.builder().user("user").password("pass").authenticateSudo(true).build(); put(map, getStore(createInjector()), "test", creds); checkConsistent(map, getStore(createInjector()), "test", creds, "{\"user\":\"user\",\"password\":\"pass\",\"authenticateSudo\":true}"); checkConsistent(map, getStore(createInjector()), "test", creds, "{\"user\":\"user\",\"password\":\"pass\",\"authenticateSudo\":true}"); remove(map, getStore(createInjector()), "test"); }
public Builder credential(String credential) { if (isPrivateKeyCredential(credential)) return noPassword().privateKey(credential); else if (credential != null) return password(credential).noPrivateKey(); return this; }
@SuppressWarnings("unchecked") public T build() { return (T) new Credentials(identity, credential); } }
public MutableResourceMetadataImpl(ResourceMetadata<T> from) { this.type = from.getType(); this.id = from.getProviderId(); this.name = from.getName(); this.location = from.getLocation(); this.uri = from.getUri(); this.userMetadata = from.getUserMetadata(); }
public void testLoginConsistentAcrossMultipleInjectorsAndLooksNice() throws IOException { Map<String, InputStream> map = getMap(createInjector()); LoginCredentials creds = LoginCredentials.builder().user("user").password("pass").build(); put(map, getStore(createInjector()), "test", creds); checkConsistent(map, getStore(createInjector()), "test", creds, "{\"user\":\"user\",\"password\":\"pass\"}"); checkConsistent(map, getStore(createInjector()), "test", creds, "{\"user\":\"user\",\"password\":\"pass\"}"); remove(map, getStore(createInjector()), "test"); }
@SuppressWarnings("unchecked") public T build() { return (T) new Credentials(identity, credential); } }
public MutableResourceMetadataImpl(ResourceMetadata<T> from) { this.type = from.getType(); this.id = from.getProviderId(); this.name = from.getName(); this.location = from.getLocation(); this.uri = from.getUri(); this.userMetadata = from.getUserMetadata(); }