/** if there is no credential (ignores public key) */ public boolean isEmpty() { return !hasKey() && !hasPassword(); } public boolean hasKey() {
/** whether to log warnings on problems */ public OsCredential warnOnErrors(boolean warnOnErrors) { this.warnOnErrors = warnOnErrors; return dirty(); } /** whether to throw on problems */
@Test public void testFromString() { PortRange r = PortRanges.fromString("80,8080,8000,8080-8099"); assertContents(r, 80, 8080, 8000, 8080, 8081, 8082, 8083, 8084, 8085, 8086, 8087, 8088, 8089, 8090, 8091, 8092, 8093, 8094, 8095, 8096, 8097, 8098, 8099); }
/** * @deprecated since 0.10.0; use {@link #getFilteredLocationProperties(String, String, Map, Map)} */ @Deprecated protected Map<String, Object> getFilteredLocationProperties(String provider, String namedLocation, Map<String, ?> globalProperties) { return new LocationPropertiesFromBrooklynProperties().getLocationProperties(getPrefix(), namedLocation, globalProperties); }
/** returns either the key or password or null; if both a key and a password this prefers the key unless otherwise set * via {@link #preferPassword()} */ public synchronized String getPreferredCredential() { infer(); if (isUsingPassword()) return password; if (hasKey()) return privateKeyData; return null; }
@Override public boolean isEnabled() { return LocationConfigUtils.isResolverPrefixEnabled(managementContext, getPrefix()); }
@Override public boolean isEnabled() { return LocationConfigUtils.isResolverPrefixEnabled(managementContext, getPrefix()); }
@Override public MachineDetails getMachineDetails() { HardwareDetails hardwareDetails = new BasicHardwareDetails(null, null); OsDetails osDetails = BasicOsDetails.Factory.ANONYMOUS_LINUX; return new BasicMachineDetails(hardwareDetails, osDetails); } }
public String getPublicKeyData() { infer(); return publicKeyData; } public String getPassword() {
@Override public boolean asBoolean() { return !isEmpty(); } @Override
@Override public LocationRegistry getLocationRegistry() { // NB: can deadlock if synched on whole LMC synchronized (locationRegistrySemaphore) { if (locationRegistry==null) locationRegistry = new BasicLocationRegistry(this); return locationRegistry; } }
/** * Returns those properties in the form "brooklyn.location.xyz", where "xyz" is any * key that does not contain dots. We do this special (sub-optimal!) filtering * because we want to exclude brooklyn.location.named.*, brooklyn.location.jclouds.*, etc. * We only want those properties that are to be generic for all locations. * * Strips off the prefix in the returned map. */ protected Map<String, Object> getGenericLocationSingleWordProperties(Map<String, ?> properties) { return getMatchingSingleWordProperties("brooklyn.location.", properties); }
@Override public void requestPersist() { super.requestPersist(); } }
@Override public synchronized int obtainPort(PortRange range) { for (int p: range) if (obtainSpecificPort(p)) return p; return -1; }
@Test public void testFromStringWithSpaces() { PortRange r = PortRanges.fromString(" 80 , 8080 , 8000 , 8080 - 8099 "); assertContents(r, 80, 8080, 8000, 8080, 8081, 8082, 8083, 8084, 8085, 8086, 8087, 8088, 8089, 8090, 8091, 8092, 8093, 8094, 8095, 8096, 8097, 8098, 8099); }
/** if true (the default) this will look at default locations set on keys */ public OsCredential useDefaultKeys(boolean tryDefaultKeys) { this.tryDefaultKeys = tryDefaultKeys; return dirty(); } /** whether to log warnings on problems */
public String getPrivateKeyData() { infer(); return privateKeyData; } public String getPublicKeyData() {
/** whether to throw on problems */ public OsCredential throwOnErrors(boolean throwOnErrors) { this.throwOnErrors = throwOnErrors; return dirty(); }