public final class SigningUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
buildCannedPolicy(String resourceUrl,
Instant expirationDate)
Returns a "canned" policy for the given parameters.
|
static String |
buildCustomPolicy(String resourceUrl,
Instant activeDate,
Instant expirationDate,
String ipAddress)
Returns a custom policy for the given parameters.
|
static String |
buildCustomPolicyForSignedUrl(String resourceUrl,
Instant activeDate,
Instant expirationDate,
String limitToIpAddressCidr)
Generate a policy document that describes custom access permissions to
apply via a private distribution's signed URL.
|
static PrivateKey |
loadPrivateKey(Path keyFile)
Creates a private key from the file given, either in pem or der format.
|
static 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 String |
makeStringUrlSafe(String str)
Converts the given string to be safe for use in signed URLs for a private
distribution.
|
static byte[] |
signWithSha1Rsa(byte[] dataToSign,
PrivateKey privateKey)
Signs the data given with the private key given, using the SHA1withRSA
algorithm provided by bouncy castle.
|
public static String buildCannedPolicy(String resourceUrl, Instant expirationDate)
public static String buildCustomPolicy(String resourceUrl, Instant activeDate, Instant expirationDate, String ipAddress)
public static String makeBytesUrlSafe(byte[] bytes)
public static String makeStringUrlSafe(String str)
public static byte[] signWithSha1Rsa(byte[] dataToSign,
PrivateKey privateKey)
throws InvalidKeyException
InvalidKeyExceptionpublic static String buildCustomPolicyForSignedUrl(String resourceUrl, Instant activeDate, Instant expirationDate, String limitToIpAddressCidr)
resourceUrl - The HTTP/S resource path that restricts which distribution and
S3 objects will be accessible in a signed URL, i.e.,
"https://" + distributionName + "/" + objectKey (may
also include URL parameters). The '*' and '?' characters can
be used as a wildcards to allow multi-character or single-character
matches respectively:
activeDate - An optional UTC time and date when the signed URL will become
active. If null, the signed URL will be active as soon as it
is created.expirationDate - The UTC time and date when the signed URL will expire. REQUIRED.limitToIpAddressCidr - An optional range of client IP addresses that will be allowed
to access the distribution, specified as an IPv4 CIDR range
(IPv6 format is not supported). If null, the CIDR will be omitted
and any client will be permitted.public static PrivateKey loadPrivateKey(Path keyFile) throws Exception
ExceptionCopyright © 2023. All rights reserved.