mirror of https://github.com/apache/jclouds.git
Remove InputSuppliers.of(String)
Callers rarely want this functionality and should call ByteStreams.newInputStreamSupplier when they do.
This commit is contained in:
parent
d938349229
commit
be1da2501e
|
@ -50,14 +50,15 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.crypto.Crypto;
|
import org.jclouds.crypto.Crypto;
|
||||||
import org.jclouds.crypto.Pems;
|
import org.jclouds.crypto.Pems;
|
||||||
import org.jclouds.io.InputSuppliers;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
import com.google.common.hash.HashCode;
|
import com.google.common.hash.HashCode;
|
||||||
import com.google.common.hash.Hashing;
|
import com.google.common.hash.Hashing;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
import com.google.common.io.InputSupplier;
|
import com.google.common.io.InputSupplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,7 +82,8 @@ public class SshKeys {
|
||||||
*/
|
*/
|
||||||
public static RSAPublicKeySpec publicKeySpecFromOpenSSH(String idRsaPub) {
|
public static RSAPublicKeySpec publicKeySpecFromOpenSSH(String idRsaPub) {
|
||||||
try {
|
try {
|
||||||
return publicKeySpecFromOpenSSH(InputSuppliers.of(idRsaPub));
|
return publicKeySpecFromOpenSSH(ByteStreams.newInputStreamSupplier(
|
||||||
|
idRsaPub.getBytes(Charsets.UTF_8)));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw propagate(e);
|
throw propagate(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,14 +53,15 @@ import java.security.spec.RSAPrivateKeySpec;
|
||||||
import java.security.spec.X509EncodedKeySpec;
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.io.InputSuppliers;
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.io.ByteProcessor;
|
import com.google.common.io.ByteProcessor;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
import com.google.common.io.InputSupplier;
|
import com.google.common.io.InputSupplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -255,7 +256,8 @@ public class Pems {
|
||||||
*/
|
*/
|
||||||
public static KeySpec privateKeySpec(String pem) {
|
public static KeySpec privateKeySpec(String pem) {
|
||||||
try {
|
try {
|
||||||
return privateKeySpec(InputSuppliers.of(pem));
|
return privateKeySpec(ByteStreams.newInputStreamSupplier(
|
||||||
|
pem.getBytes(Charsets.UTF_8)));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw propagate(e);
|
throw propagate(e);
|
||||||
}
|
}
|
||||||
|
@ -314,7 +316,8 @@ public class Pems {
|
||||||
* @see Pems#publicKeySpec(InputSupplier)
|
* @see Pems#publicKeySpec(InputSupplier)
|
||||||
*/
|
*/
|
||||||
public static KeySpec publicKeySpec(String pem) throws IOException {
|
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)
|
* @see Pems#x509Certificate(InputSupplier, CertificateFactory)
|
||||||
*/
|
*/
|
||||||
public static X509Certificate x509Certificate(String pem) throws IOException, CertificateException {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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<? extends InputStream> of(String in) {
|
|
||||||
byte[] bytes = checkNotNull(in, "in").getBytes(Charsets.UTF_8);
|
|
||||||
return ByteStreams.newInputStreamSupplier(bytes);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue