diff --git a/compute/src/main/java/org/jclouds/ssh/SshKeys.java b/compute/src/main/java/org/jclouds/ssh/SshKeys.java index 2ce55f02a9..ef6aac1a40 100644 --- a/compute/src/main/java/org/jclouds/ssh/SshKeys.java +++ b/compute/src/main/java/org/jclouds/ssh/SshKeys.java @@ -50,14 +50,15 @@ import java.util.Map; import org.jclouds.crypto.Crypto; import org.jclouds.crypto.Pems; -import org.jclouds.io.InputSuppliers; import com.google.common.annotations.Beta; +import com.google.common.base.Charsets; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import com.google.common.hash.HashCode; import com.google.common.hash.Hashing; +import com.google.common.io.ByteStreams; import com.google.common.io.InputSupplier; /** @@ -81,7 +82,8 @@ public class SshKeys { */ public static RSAPublicKeySpec publicKeySpecFromOpenSSH(String idRsaPub) { try { - return publicKeySpecFromOpenSSH(InputSuppliers.of(idRsaPub)); + return publicKeySpecFromOpenSSH(ByteStreams.newInputStreamSupplier( + idRsaPub.getBytes(Charsets.UTF_8))); } catch (IOException e) { throw propagate(e); } diff --git a/core/src/main/java/org/jclouds/crypto/Pems.java b/core/src/main/java/org/jclouds/crypto/Pems.java index 6297d760de..0e778917c7 100644 --- a/core/src/main/java/org/jclouds/crypto/Pems.java +++ b/core/src/main/java/org/jclouds/crypto/Pems.java @@ -53,14 +53,15 @@ import java.security.spec.RSAPrivateKeySpec; import java.security.spec.X509EncodedKeySpec; import java.util.Map; -import org.jclouds.io.InputSuppliers; import org.jclouds.javax.annotation.Nullable; import com.google.common.annotations.Beta; +import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.io.ByteProcessor; +import com.google.common.io.ByteStreams; import com.google.common.io.InputSupplier; /** @@ -255,7 +256,8 @@ public class Pems { */ public static KeySpec privateKeySpec(String pem) { try { - return privateKeySpec(InputSuppliers.of(pem)); + return privateKeySpec(ByteStreams.newInputStreamSupplier( + pem.getBytes(Charsets.UTF_8))); } catch (IOException e) { throw propagate(e); } @@ -314,7 +316,8 @@ public class Pems { * @see Pems#publicKeySpec(InputSupplier) */ public static KeySpec publicKeySpec(String pem) throws IOException { - return publicKeySpec(InputSuppliers.of(pem)); + return publicKeySpec(ByteStreams.newInputStreamSupplier( + pem.getBytes(Charsets.UTF_8))); } /** @@ -364,7 +367,8 @@ public class Pems { * @see Pems#x509Certificate(InputSupplier, CertificateFactory) */ public static X509Certificate x509Certificate(String pem) throws IOException, CertificateException { - return x509Certificate(InputSuppliers.of(pem), null); + return x509Certificate(ByteStreams.newInputStreamSupplier( + pem.getBytes(Charsets.UTF_8)), null); } /** diff --git a/core/src/main/java/org/jclouds/io/InputSuppliers.java b/core/src/main/java/org/jclouds/io/InputSuppliers.java deleted file mode 100644 index 15c2ae3d9e..0000000000 --- a/core/src/main/java/org/jclouds/io/InputSuppliers.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.io; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.io.InputStream; - -import com.google.common.annotations.Beta; -import com.google.common.base.Charsets; -import com.google.common.io.ByteStreams; -import com.google.common.io.InputSupplier; - -/** - * functions related to or replacing those in {@link com.google.common.io.InputSupplier} - * - * @author Adrian Cole - */ -@Beta -public class InputSuppliers { - - public static InputSupplier of(String in) { - byte[] bytes = checkNotNull(in, "in").getBytes(Charsets.UTF_8); - return ByteStreams.newInputStreamSupplier(bytes); - } -}