com.amazonaws.services.cloudfront.util

## Class SignerUtils

- java.lang.Object
- - com.amazonaws.services.cloudfront.util.SignerUtils

    public class SignerUtils
    extends Object

### Nested Class Summary

Nested Classes
`static class` `SignerUtils.Protocol` Enumeration of protocols for presigned URLs

### Constructor Summary

Constructors
Constructor and Description
`SignerUtils()`

### Method Summary

All Methods Static Methods Concrete Methods
`static String` `buildCannedPolicy(String resourceUrlOrPath, Date dateLessThan)` Returns a "canned" policy for the given parameters.
`static String` `buildCustomPolicy(String resourcePath, Date expiresOn, Date activeFrom, String ipAddress)` Returns a custom policy for the given parameters.
`static String` `generateResourcePath(SignerUtils.Protocol protocol, String distributionDomain, String resourcePath)` Returns the resource path for the given distribution, object, and protocol.
`static PrivateKey` `loadPrivateKey(File privateKeyFile)` Creates a private key from the file given, either in RSA private key (.pem) or pkcs8 (.der) format.
`static PrivateKey` `loadPrivateKey(String privateKeyFilePath)`
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SignerUtils

    public SignerUtils()

### Method Detail

#### buildCannedPolicy

    public static String buildCannedPolicy(String resourceUrlOrPath,
                                           Date dateLessThan)

Returns a "canned" policy for the given parameters. For more information, see Overview of Signed URLs.

#### buildCustomPolicy

    public static String buildCustomPolicy(String resourcePath,
                                           Date expiresOn,
                                           Date activeFrom,
                                           String ipAddress)

Returns a custom policy for the given parameters.

#### makeBytesUrlSafe

    public 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.

#### makeStringUrlSafe

    public static String makeStringUrlSafe(String str)

Converts the given string to be safe for use in signed URLs for a private distribution.

#### generateResourcePath

    public static String generateResourcePath(SignerUtils.Protocol protocol,
                                              String distributionDomain,
                                              String resourcePath)

Returns the resource path for the given distribution, object, and protocol.

#### signWithSha1RSA

    public static byte[] signWithSha1RSA(byte[] dataToSign,
                                         PrivateKey privateKey)
                                  throws InvalidKeyException

Signs the data given with the private key given, using the SHA1withRSA algorithm provided by bouncy castle.

Throws:
  `InvalidKeyException`

#### loadPrivateKey

    public static PrivateKey loadPrivateKey(File privateKeyFile)
                                     throws InvalidKeySpecException,
                                            IOException

Creates a private key from the file given, either in RSA private key (.pem) or pkcs8 (.der) format. Other formats will cause an exception to be thrown.

Throws:
  `InvalidKeySpecException`
  `IOException`

#### loadPrivateKey

    public static PrivateKey loadPrivateKey(String privateKeyFilePath)
                                     throws InvalidKeySpecException,
                                            IOException

Throws:
  `InvalidKeySpecException`
  `IOException`