Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/465#discussion_r23467013
--- Diff:
core/src/main/java/brooklyn/location/basic/LocationConfigUtils.java ---
@@ -20,39 +20,355 @@
import static brooklyn.util.JavaGroovyEquivalents.groovyTruth;
+import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.IOException;
+import java.security.KeyPair;
+import java.security.PublicKey;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import brooklyn.config.ConfigKey;
import brooklyn.entity.basic.ConfigKeys;
+import brooklyn.internal.BrooklynFeatureEnablement;
+import brooklyn.location.cloud.CloudLocationConfig;
import brooklyn.management.ManagementContext;
+import brooklyn.util.ResourceUtils;
import brooklyn.util.collections.MutableMap;
+import brooklyn.util.collections.MutableSet;
import brooklyn.util.config.ConfigBag;
+import brooklyn.util.crypto.AuthorizedKeysParser;
+import brooklyn.util.crypto.SecureKeys;
+import brooklyn.util.crypto.SecureKeys.PassphraseProblem;
+import brooklyn.util.exceptions.Exceptions;
import brooklyn.util.os.Os;
import brooklyn.util.text.StringFunctions;
import brooklyn.util.text.Strings;
-import com.google.common.base.Charsets;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
-import com.google.common.io.Files;
public class LocationConfigUtils {
private static final Logger log =
LoggerFactory.getLogger(LocationConfigUtils.class);
+
+ /** Creates an instance of {@link OsCredential} by inspecting {@link
LocationConfigKeys#PASSWORD};
+ * {@link LocationConfigKeys#PRIVATE_KEY_DATA} and {@link
LocationConfigKeys#PRIVATE_KEY_FILE};
+ * {@link LocationConfigKeys#PRIVATE_KEY_PASSPHRASE} if needed, and
+ * {@link LocationConfigKeys#PRIVATE_KEY_DATA} and {@link
LocationConfigKeys#PRIVATE_KEY_FILE}
+ * (defaulting to the private key file + ".pub").
+ **/
+ public static OsCredential getOsCredential(ConfigBag config) {
+ return OsCredential.newInstance(config);
+ }
+ /** Convenience class for holding private/public keys and passwords,
inferring from config keys.
+ * See {@link LocationConfigUtils#getOsCredential(ConfigBag)}. */
+ public static class OsCredential {
--- End diff --
yeah - probably worth refactoring. are you okay with me marking it `@Beta`
for now, and we can do that later?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---