public class SignerUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SignerUtils.Protocol
Enumeration of protocols for presigned URLs
|
Modifier and Type | Field and Description |
---|---|
private static java.security.SecureRandom |
srand |
Constructor and Description |
---|
SignerUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
buildCannedPolicy(java.lang.String resourceUrlOrPath,
java.util.Date dateLessThan)
Returns a "canned" policy for the given parameters.
|
static java.lang.String |
buildCustomPolicy(java.lang.String resourcePath,
java.util.Date expiresOn,
java.util.Date activeFrom,
java.lang.String ipAddress)
Returns a custom policy for the given parameters.
|
static java.lang.String |
generateResourcePath(SignerUtils.Protocol protocol,
java.lang.String distributionDomain,
java.lang.String resourcePath)
Returns the resource path for the given distribution, object, and
protocol.
|
static java.security.PrivateKey |
loadPrivateKey(java.io.File privateKeyFile)
Creates a private key from the file given, either in RSA private key
(.pem) or pkcs8 (.der) format.
|
static java.security.PrivateKey |
loadPrivateKey(java.lang.String privateKeyFilePath) |
static java.lang.String |
makeBytesUrlSafe(byte[] bytes)
Converts the given data to be safe for use in signed URLs for a private
distribution by using specialized Base64 encoding.
|
static java.lang.String |
makeStringUrlSafe(java.lang.String str)
Converts the given string to be safe for use in signed URLs for a private
distribution.
|
static byte[] |
signWithSha1RSA(byte[] dataToSign,
java.security.PrivateKey privateKey)
Signs the data given with the private key given, using the SHA1withRSA
algorithm provided by bouncy castle.
|
public static java.lang.String buildCannedPolicy(java.lang.String resourceUrlOrPath, java.util.Date dateLessThan)
public static java.lang.String buildCustomPolicy(java.lang.String resourcePath, java.util.Date expiresOn, java.util.Date activeFrom, java.lang.String ipAddress)
public static java.lang.String makeBytesUrlSafe(byte[] bytes)
public static java.lang.String makeStringUrlSafe(java.lang.String str)
public static java.lang.String generateResourcePath(SignerUtils.Protocol protocol, java.lang.String distributionDomain, java.lang.String resourcePath)
public static byte[] signWithSha1RSA(byte[] dataToSign, java.security.PrivateKey privateKey) throws java.security.InvalidKeyException
java.security.InvalidKeyException
public static java.security.PrivateKey loadPrivateKey(java.io.File privateKeyFile) throws java.security.spec.InvalidKeySpecException, java.io.IOException
java.security.spec.InvalidKeySpecException
java.io.IOException
public static java.security.PrivateKey loadPrivateKey(java.lang.String privateKeyFilePath) throws java.security.spec.InvalidKeySpecException, java.io.IOException
java.security.spec.InvalidKeySpecException
java.io.IOException