public class CloudFrontService extends java.lang.Object implements JetS3tRequestAuthorizer
This class uses properties obtained through Jets3tProperties
. For more information on
these properties please refer to
JetS3t Configuration
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_BUCKET_SUFFIX |
static java.lang.String |
ENDPOINT |
protected org.apache.http.client.HttpClient |
httpClient |
protected int |
internalErrorRetryMax |
protected Jets3tProperties |
jets3tProperties |
static java.lang.String |
ORIGIN_ACCESS_IDENTITY_PREFIX |
static java.lang.String |
ORIGIN_ACCESS_IDENTITY_URI_PATH |
protected long |
timeOffset
The approximate difference in the current time between your computer and
Amazon's servers, measured in milliseconds.
|
static java.lang.String |
VERSION |
static java.lang.String |
XML_NAMESPACE |
Constructor and Description |
---|
CloudFrontService(ProviderCredentials credentials)
Constructs the service with default properties.
|
CloudFrontService(ProviderCredentials credentials,
java.lang.String invokingApplicationDescription,
org.apache.http.client.CredentialsProvider credentialsProvider,
Jets3tProperties jets3tProperties)
Constructs the service and initialises its properties.
|
Modifier and Type | Method and Description |
---|---|
void |
authorizeHttpRequest(org.apache.http.client.methods.HttpUriRequest httpMethod,
org.apache.http.protocol.HttpContext context,
java.lang.String ignoredForceRequestSignatureVersion)
Sign the given HTTP method object using the AWS credentials provided
by
getAWSCredentials() . |
protected com.jamesmurty.utils.XMLBuilder |
buildCacheBehaviors(CacheBehavior[] cbs) |
protected com.jamesmurty.utils.XMLBuilder |
buildCacheBehaviorsElement(boolean isDefault,
CacheBehavior[] cbs) |
protected com.jamesmurty.utils.XMLBuilder |
buildDefaultCacheBehavior(CacheBehavior cb) |
protected java.lang.String |
buildDistributionConfigXmlDocument(DistributionConfig config)
Generate a DistributionConfig or StreamingDistributionConfig XML document.
|
protected com.jamesmurty.utils.XMLBuilder |
buildOrigin(Origin origin)
Generate XML representing an S3 or non-S3 (custom) origin.
|
static java.lang.String |
buildPolicyForSignedUrl(java.lang.String resourcePath,
java.util.Date epochDateLessThan,
java.lang.String limitToIpAddressCIDR,
java.util.Date epochDateGreaterThan)
Generate a policy document that describes custom access permissions to apply
via a private distribution's signed URL.
|
protected com.jamesmurty.utils.XMLBuilder |
buildTrustedSigners(java.lang.String[] trustedSignerAwsAccountNumbers) |
Distribution |
createDistribution(DistributionConfig config)
Create a public or private CloudFront distribution for an S3 bucket based
on a pre-configured
DistributionConfig . |
Distribution |
createDistribution(Origin origin)
Create a minimally-configured CloudFront distribution for an S3 bucket that will
be publicly available once created.
|
Distribution |
createDistribution(Origin origin,
java.lang.String callerReference,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus)
Create a public CloudFront distribution for an S3 bucket.
|
Distribution |
createDistribution(Origin origin,
java.lang.String callerReference,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus,
boolean trustedSignerSelf,
java.lang.String[] trustedSignerAwsAccountNumbers,
java.lang.String[] requiredProtocols,
java.lang.String defaultRootObject)
Create a public or private CloudFront distribution for an S3 bucket.
|
Distribution |
createDistribution(Origin origin,
java.lang.String callerReference,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus,
boolean trustedSignerSelf,
java.lang.String[] trustedSignerAwsAccountNumbers,
java.lang.String[] requiredProtocols,
java.lang.String defaultRootObject,
java.lang.Long minTTL)
Deprecated.
as of 2012-05-05 API version, use
createDistribution(DistributionConfig) . |
protected Distribution |
createDistributionImpl(DistributionConfig config)
Create a streaming or non-streaming distribution.
|
OriginAccessIdentity |
createOriginAccessIdentity(java.lang.String callerReference,
java.lang.String comment)
Create a new Origin Access Identity
|
StreamingDistribution |
createStreamingDistribution(Origin origin,
java.lang.String callerReference,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus)
Deprecated.
as of 2012-05-05 API version, use
createDistribution(DistributionConfig) . |
StreamingDistribution |
createStreamingDistribution(Origin origin,
java.lang.String callerReference,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus,
boolean trustedSignerSelf,
java.lang.String[] trustedSignerAwsAccountNumbers)
Deprecated.
as of 2012-05-05 API version, use
createDistribution(DistributionConfig) . |
void |
deleteDistribution(java.lang.String id)
Delete a disabled distribution.
|
protected void |
deleteDistributionImpl(boolean isStreaming,
java.lang.String distributionId)
Delete a streaming or non-streaming distribution.
|
void |
deleteOriginAccessIdentity(java.lang.String id)
Delete an Origin Access Identity.
|
void |
deleteStreamingDistribution(java.lang.String id)
Delete a disabled streaming distribution.
|
void |
disableDistributionForDeletion(java.lang.String id)
Convenience method to disable a distribution that you intend to delete.
|
void |
disableStreamingDistributionForDeletion(java.lang.String id)
Convenience method to disable a streaming distribution that you intend to delete.
|
ProviderCredentials |
getAWSCredentials() |
protected java.util.Date |
getCurrentTimeWithOffset()
Returns the current date and time, adjusted according to the time
offset between your computer and an AWS server (as set by the
RestUtils.calculateTimeAdjustmentOffset(HttpResponse) method). |
DistributionConfig |
getDistributionConfig(java.lang.String distributionId)
Lookup configuration information for a standard distribution.
|
protected DistributionConfig |
getDistributionConfigImpl(boolean isStreaming,
java.lang.String distributionId) |
Distribution |
getDistributionInfo(java.lang.String id)
Lookup information for a standard distribution.
|
protected Distribution |
getDistributionInfoImpl(boolean isStreaming,
java.lang.String distributionId) |
Invalidation |
getInvalidation(java.lang.String distributionId,
java.lang.String invalidationId) |
OriginAccessIdentity |
getOriginAccessIdentity(java.lang.String id)
Obtain the complete properties of an Origin Access Identity.
|
OriginAccessIdentityConfig |
getOriginAccessIdentityConfig(java.lang.String id)
Obtain the configuration properties of an Origin Access Identity.
|
java.util.List<OriginAccessIdentity> |
getOriginAccessIdentityList()
List the Origin Access Identities in a CloudFront account.
|
StreamingDistributionConfig |
getStreamingDistributionConfig(java.lang.String id)
Lookup configuration information for a streaming distribution.
|
StreamingDistribution |
getStreamingDistributionInfo(java.lang.String distributionId)
Lookup information for a streaming distribution.
|
protected org.apache.http.client.HttpClient |
initHttpConnection() |
protected void |
initializeDefaults() |
protected void |
initializeProxy() |
Invalidation |
invalidateObjects(java.lang.String distributionId,
S3Object[] objects,
java.lang.String callerReference)
Remove distribution objects from a CloudFront edge server cache to force
a refresh of the object data from the S3 origin.
|
Invalidation |
invalidateObjects(java.lang.String distributionId,
java.lang.String[] objectKeys,
java.lang.String callerReference)
Remove distribution objects from a CloudFront edge server cache to force
a refresh of the object data from the S3 origin.
|
Distribution[] |
listDistributions()
List all your standard CloudFront distributions.
|
Distribution[] |
listDistributions(int pagingSize)
List all your standard CloudFront distributions, with a given maximum
number of Distribution items in each "page" of results.
|
Distribution[] |
listDistributions(java.lang.String bucketName)
List the distributions whose origin is the given S3 bucket name.
|
java.util.List<Distribution> |
listDistributionsByBucketName(boolean isStreaming,
java.lang.String bucketName)
List streaming or non-stream distributions whose origin is the given S3 bucket name.
|
protected java.util.List<Distribution> |
listDistributionsImpl(boolean isStreaming,
int pagingSize)
List streaming or non-streaming Distributions in a CloudFront account.
|
java.util.List<InvalidationSummary> |
listInvalidations(java.lang.String distributionId)
List all past invalidation summaries, ordered from most recent to oldest.
|
InvalidationList |
listInvalidations(java.lang.String distributionId,
java.lang.String nextMarker,
int pagingSize)
List a single page of up to pagingSize past invalidation summaries, ordered from
most recent to oldest.
|
StreamingDistribution[] |
listStreamingDistributions()
List all your streaming CloudFront distributions.
|
StreamingDistribution[] |
listStreamingDistributions(int pagingSize)
List all your streaming CloudFront distributions, with a given maximum
number of Distribution items in each "page" of results.
|
StreamingDistribution[] |
listStreamingDistributions(java.lang.String bucketName)
List the streaming distributions whose origin is the given S3 bucket name.
|
protected static java.lang.String |
makeBytesUrlSafe(byte[] bytes)
Convert the given data to be safe for use in signed URLs for a private distribution by
using specialized Base64 encoding.
|
protected static java.lang.String |
makeStringUrlSafe(java.lang.String str)
Convert the given string to be safe for use in signed URLs for a private distribution.
|
protected org.apache.http.HttpResponse |
performRestRequest(org.apache.http.client.methods.HttpRequestBase httpMethod,
int expectedResponseCode)
Performs an HTTP/S request by invoking the provided HttpMethod object.
|
static java.lang.String |
sanitizeS3BucketName(java.lang.String proposedBucketName)
Sanitizes a proposed bucket name to ensure it is fully-specified rather than
merely the bucket's short name.
|
static java.lang.String |
signUrl(java.lang.String resourceUrlOrPath,
java.lang.String keyPairId,
byte[] derPrivateKey,
java.lang.String policy)
Generate a signed URL that allows access to distribution and S3 objects by
applying access restrictions specified in a custom policy document.
|
static java.lang.String |
signUrlCanned(java.lang.String resourceUrlOrPath,
java.lang.String keyPairId,
byte[] derPrivateKey,
java.util.Date epochDateLessThan)
Generate a signed URL that allows access to a specific distribution and
S3 object by applying a access restrictions from a "canned" (simplified)
policy document.
|
DistributionConfig |
updateDistributionConfig(java.lang.String id,
DistributionConfig config)
Update the configuration of an existing distribution to change its properties
or public/private status.
|
DistributionConfig |
updateDistributionConfig(java.lang.String id,
Origin origin,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus)
Update the configuration of an existing distribution to change its properties.
|
DistributionConfig |
updateDistributionConfig(java.lang.String id,
Origin origin,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus,
boolean trustedSignerSelf,
java.lang.String[] trustedSignerAwsAccountNumbers,
java.lang.String[] requiredProtocols,
java.lang.String defaultRootObject)
Update the configuration of an existing distribution to change its properties
or public/private status.
|
DistributionConfig |
updateDistributionConfig(java.lang.String id,
Origin origin,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus,
boolean trustedSignerSelf,
java.lang.String[] trustedSignerAwsAccountNumbers,
java.lang.String[] requiredProtocols,
java.lang.String defaultRootObject,
java.lang.Long minTTL)
Deprecated.
as of 2012-05-05 API version, use
updateDistributionConfig(String, DistributionConfig) . |
protected DistributionConfig |
updateDistributionConfigImpl(java.lang.String id,
DistributionConfig config)
Update a streaming or non-streaming distribution.
|
OriginAccessIdentityConfig |
updateOriginAccessIdentityConfig(java.lang.String id,
java.lang.String comment)
Update the properties of an Origin Access Identity.
|
StreamingDistributionConfig |
updateStreamingDistributionConfig(java.lang.String id,
Origin origin,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus)
Deprecated.
as of 2012-05-05 API version, use
updateDistributionConfig(String, DistributionConfig) . |
StreamingDistributionConfig |
updateStreamingDistributionConfig(java.lang.String id,
Origin origin,
java.lang.String[] cnames,
java.lang.String comment,
boolean enabled,
LoggingStatus loggingStatus,
boolean trustedSignerSelf,
java.lang.String[] trustedSignerAwsAccountNumbers)
Deprecated.
as of 2012-05-05 API version, use
updateDistributionConfig(String, DistributionConfig) . |
public static final java.lang.String ENDPOINT
public static final java.lang.String VERSION
public static final java.lang.String XML_NAMESPACE
public static final java.lang.String DEFAULT_BUCKET_SUFFIX
public static final java.lang.String ORIGIN_ACCESS_IDENTITY_URI_PATH
public static final java.lang.String ORIGIN_ACCESS_IDENTITY_PREFIX
protected org.apache.http.client.HttpClient httpClient
protected Jets3tProperties jets3tProperties
protected int internalErrorRetryMax
protected long timeOffset
This value is 0 by default. Use the getCurrentTimeWithOffset()
to obtain the current time with this offset factor included, and the
RestUtils.calculateTimeAdjustmentOffset(HttpResponse)
method to
calculate an offset value for your computer based on a response from an
AWS server.
public CloudFrontService(ProviderCredentials credentials, java.lang.String invokingApplicationDescription, org.apache.http.client.CredentialsProvider credentialsProvider, Jets3tProperties jets3tProperties)
credentials
- the Storage Provider user credentials to use when communicating with CloudFrontinvokingApplicationDescription
- a short description of the application using the service, suitable for inclusion in a
user agent string for REST/HTTP requests. Ideally this would include the application's
version number, for example: Cockpit/0.7.3
or My App Name/1.0
.
May be null.credentialsProvider
- an implementation of the HttpClient CredentialsProvider interface, to provide a means for
prompting for credentials when necessary. May be null.jets3tProperties
- JetS3t properties that will be applied within this service. May be null.public CloudFrontService(ProviderCredentials credentials)
credentials
- the Storage Provider user credentials to use when communicating with CloudFrontprotected void initializeDefaults()
protected org.apache.http.client.HttpClient initHttpConnection()
protected void initializeProxy()
public ProviderCredentials getAWSCredentials()
protected java.util.Date getCurrentTimeWithOffset()
RestUtils.calculateTimeAdjustmentOffset(HttpResponse)
method).public void authorizeHttpRequest(org.apache.http.client.methods.HttpUriRequest httpMethod, org.apache.http.protocol.HttpContext context, java.lang.String ignoredForceRequestSignatureVersion) throws ServiceException
getAWSCredentials()
.authorizeHttpRequest
in interface JetS3tRequestAuthorizer
httpMethod
- the request objectcontext
- ignoredForceRequestSignatureVersion
- ignored parameter relevant only for AWS4-HMAC-SHA256 request signing.ServiceException
protected org.apache.http.HttpResponse performRestRequest(org.apache.http.client.methods.HttpRequestBase httpMethod, int expectedResponseCode) throws CloudFrontServiceException
httpMethod
- the object containing a request target and all other information necessary to
perform the requestexpectedResponseCode
- the HTTP response code that indicates a successful request. If the response code received
does not match this value an error must have occurred, so an exception is thrown.CloudFrontServiceException
- all exceptions are wrapped in a CloudFrontServiceException. Depending on the kind of error that
occurred, this exception may contain additional error information available from an XML
error response document.protected java.util.List<Distribution> listDistributionsImpl(boolean isStreaming, int pagingSize) throws CloudFrontServiceException
isStreaming
- Only return streaming distributionspagingSize
- the maximum number of distributions the CloudFront service will
return in each response message.Distribution
s.CloudFrontServiceException
- exceptionpublic Distribution[] listDistributions(int pagingSize) throws CloudFrontServiceException
pagingSize
- the maximum number of distributions the CloudFront service will
return in each response message.CloudFrontServiceException
- exceptionpublic StreamingDistribution[] listStreamingDistributions(int pagingSize) throws CloudFrontServiceException
pagingSize
- the maximum number of distributions the CloudFront service will
return in each response message.CloudFrontServiceException
- exceptionpublic Distribution[] listDistributions() throws CloudFrontServiceException
CloudFrontServiceException
- exceptionpublic StreamingDistribution[] listStreamingDistributions() throws CloudFrontServiceException
CloudFrontServiceException
- exceptionpublic java.util.List<Distribution> listDistributionsByBucketName(boolean isStreaming, java.lang.String bucketName) throws CloudFrontServiceException
isStreaming
- List streaming distributionsbucketName
- the name of the S3 bucket whose distributions will be returned.CloudFrontServiceException
- exceptionpublic Distribution[] listDistributions(java.lang.String bucketName) throws CloudFrontServiceException
bucketName
- the name of the S3 bucket whose distributions will be returned.CloudFrontServiceException
- exceptionpublic StreamingDistribution[] listStreamingDistributions(java.lang.String bucketName) throws CloudFrontServiceException
bucketName
- the name of the S3 bucket whose distributions will be returned.CloudFrontServiceException
- exceptionprotected com.jamesmurty.utils.XMLBuilder buildOrigin(Origin origin) throws javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException, javax.xml.parsers.FactoryConfigurationError
origin
- S3 or non-S3 (custom) origin.javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.FactoryConfigurationError
protected com.jamesmurty.utils.XMLBuilder buildTrustedSigners(java.lang.String[] trustedSignerAwsAccountNumbers) throws javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.ParserConfigurationException
protected com.jamesmurty.utils.XMLBuilder buildDefaultCacheBehavior(CacheBehavior cb) throws javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException, javax.xml.parsers.FactoryConfigurationError
javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.FactoryConfigurationError
protected com.jamesmurty.utils.XMLBuilder buildCacheBehaviors(CacheBehavior[] cbs) throws javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException, javax.xml.parsers.FactoryConfigurationError
javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.FactoryConfigurationError
protected com.jamesmurty.utils.XMLBuilder buildCacheBehaviorsElement(boolean isDefault, CacheBehavior[] cbs) throws javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException, javax.xml.parsers.FactoryConfigurationError
javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.FactoryConfigurationError
protected java.lang.String buildDistributionConfigXmlDocument(DistributionConfig config) throws javax.xml.transform.TransformerException, javax.xml.parsers.ParserConfigurationException, javax.xml.parsers.FactoryConfigurationError
javax.xml.transform.TransformerException
javax.xml.parsers.ParserConfigurationException
javax.xml.parsers.FactoryConfigurationError
protected Distribution createDistributionImpl(DistributionConfig config) throws CloudFrontServiceException
config
- Configuration documentCloudFrontServiceException
- exceptionpublic Distribution createDistribution(Origin origin, java.lang.String callerReference, java.lang.String[] cnames, java.lang.String comment, boolean enabled, LoggingStatus loggingStatus, boolean trustedSignerSelf, java.lang.String[] trustedSignerAwsAccountNumbers, java.lang.String[] requiredProtocols, java.lang.String defaultRootObject) throws CloudFrontServiceException
origin
- the origin to associate with the distribution, either an Amazon S3 bucket or
a custom HTTP/S-accessible location.callerReference
- A user-set unique reference value that ensures the request can't be replayed
(max UTF-8 encoding size 128 bytes). This parameter may be null, in which
case your computer's local epoch time in milliseconds will be used.cnames
- A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be a null or empty array.comment
- An optional comment to describe the distribution in your own terms
(max 128 characters). May be null.enabled
- Should the distribution should be enabled and publicly accessible upon creation?loggingStatus
- Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.trustedSignerSelf
- If true the owner of the distribution (you) will be be allowed to generate
signed URLs for a private distribution. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.trustedSignerAwsAccountNumbers
- Account Number identifiers for AWS account holders other than the
distribution's owner who will be allowed to generate signed URLs for a private
distribution. If null or empty, no additional AWS account holders may generate
signed URLs. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.requiredProtocols
- List of protocols that must be used by clients to retrieve content from the
distribution. If this value is null or is an empty array, all protocols will be
supported.defaultRootObject
- The name of an object that will be served when someone visits the root of a
distribution.CloudFrontServiceException
- exception@Deprecated public Distribution createDistribution(Origin origin, java.lang.String callerReference, java.lang.String[] cnames, java.lang.String comment, boolean enabled, LoggingStatus loggingStatus, boolean trustedSignerSelf, java.lang.String[] trustedSignerAwsAccountNumbers, java.lang.String[] requiredProtocols, java.lang.String defaultRootObject, java.lang.Long minTTL) throws CloudFrontServiceException
createDistribution(DistributionConfig)
.origin
- the origin to associate with the distribution, either an Amazon S3 bucket or
a custom HTTP/S-accessible location.callerReference
- A user-set unique reference value that ensures the request can't be replayed
(max UTF-8 encoding size 128 bytes). This parameter may be null, in which
case your computer's local epoch time in milliseconds will be used.cnames
- A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be a null or empty array.comment
- An optional comment to describe the distribution in your own terms
(max 128 characters). May be null.enabled
- Should the distribution should be enabled and publicly accessible upon creation?loggingStatus
- Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.trustedSignerSelf
- If true the owner of the distribution (you) will be be allowed to generate
signed URLs for a private distribution. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.trustedSignerAwsAccountNumbers
- Account Number identifiers for AWS account holders other than the
distribution's owner who will be allowed to generate signed URLs for a private
distribution. If null or empty, no additional AWS account holders may generate
signed URLs. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.requiredProtocols
- List of protocols that must be used by clients to retrieve content from the
distribution. If this value is null or is an empty array, all protocols will be
supported.defaultRootObject
- The name of an object that will be served when someone visits the root of a
distribution.minTTL
- The time to live (TTL) to apply to objects served by this distribution.CloudFrontServiceException
public Distribution createDistribution(Origin origin) throws CloudFrontServiceException
origin
- the origin to associate with the distribution, either an Amazon S3 bucket or
a custom HTTP/S-accessible location.CloudFrontServiceException
public Distribution createDistribution(Origin origin, java.lang.String callerReference, java.lang.String[] cnames, java.lang.String comment, boolean enabled, LoggingStatus loggingStatus) throws CloudFrontServiceException
origin
- the origin to associate with the distribution, either an Amazon S3 bucket or
a custom HTTP/S-accessible location.callerReference
- A user-set unique reference value that ensures the request can't be replayed
(max UTF-8 encoding size 128 bytes). This parameter may be null, in which
case your computer's local epoch time in milliseconds will be used.cnames
- A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be a null or empty array.comment
- An optional comment to describe the distribution in your own terms
(max 128 characters). May be null.enabled
- Should the distribution should be enabled and publicly accessible upon creation?loggingStatus
- Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.CloudFrontServiceException
public Distribution createDistribution(DistributionConfig config) throws CloudFrontServiceException
DistributionConfig
.config
- Configuration settings to apply to the distribution.CloudFrontServiceException
@Deprecated public StreamingDistribution createStreamingDistribution(Origin origin, java.lang.String callerReference, java.lang.String[] cnames, java.lang.String comment, boolean enabled, LoggingStatus loggingStatus, boolean trustedSignerSelf, java.lang.String[] trustedSignerAwsAccountNumbers) throws CloudFrontServiceException
createDistribution(DistributionConfig)
.origin
- the origin to associate with the distribution, either an Amazon S3 bucket or
a custom HTTP/S-accessible location.callerReference
- A user-set unique reference value that ensures the request can't be replayed
(max UTF-8 encoding size 128 bytes). This parameter may be null, in which
case your computer's local epoch time in milliseconds will be used.cnames
- A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be a null or empty array.comment
- An optional comment to describe the distribution in your own terms
(max 128 characters). May be null.enabled
- Should the distribution should be enabled and publicly accessible upon creation?loggingStatus
- Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.trustedSignerSelf
- If true the owner of the distribution (you) will be be allowed to generate
signed URLs for a private distribution. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.trustedSignerAwsAccountNumbers
- Account Number identifiers for AWS account holders other than the
distribution's owner who will be allowed to generate signed URLs for a private
distribution. If null or empty, no additional AWS account holders may generate
signed URLs. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.CloudFrontServiceException
@Deprecated public StreamingDistribution createStreamingDistribution(Origin origin, java.lang.String callerReference, java.lang.String[] cnames, java.lang.String comment, boolean enabled, LoggingStatus loggingStatus) throws CloudFrontServiceException
createDistribution(DistributionConfig)
.origin
- the origin to associate with the distribution, either an Amazon S3 bucket or
a custom HTTP/S-accessible location.callerReference
- A user-set unique reference value that ensures the request can't be replayed
(max UTF-8 encoding size 128 bytes). This parameter may be null, in which
case your computer's local epoch time in milliseconds will be used.cnames
- A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be a null or empty array.comment
- An optional comment to describe the distribution in your own terms
(max 128 characters). May be null.enabled
- Should the distribution should be enabled and publicly accessible upon creation?loggingStatus
- Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.CloudFrontServiceException
protected Distribution getDistributionInfoImpl(boolean isStreaming, java.lang.String distributionId) throws CloudFrontServiceException
isStreaming
- Only return streaming distributionsdistributionId
- The distribution's unique identifier.CloudFrontServiceException
public Distribution getDistributionInfo(java.lang.String id) throws CloudFrontServiceException
id
- the distribution's unique identifier.CloudFrontServiceException
public StreamingDistribution getStreamingDistributionInfo(java.lang.String distributionId) throws CloudFrontServiceException
distributionId
- the distribution's unique identifier.CloudFrontServiceException
protected DistributionConfig getDistributionConfigImpl(boolean isStreaming, java.lang.String distributionId) throws CloudFrontServiceException
isStreaming
- Only return streaming distributionsdistributionId
- The distribution's unique identifier.CloudFrontServiceException
public DistributionConfig getDistributionConfig(java.lang.String distributionId) throws CloudFrontServiceException
getDistributionInfo(String)
method.distributionId
- the distribution's unique identifier.CloudFrontServiceException
public StreamingDistributionConfig getStreamingDistributionConfig(java.lang.String id) throws CloudFrontServiceException
getDistributionInfo(String)
method.id
- the distribution's unique identifier.CloudFrontServiceException
protected DistributionConfig updateDistributionConfigImpl(java.lang.String id, DistributionConfig config) throws CloudFrontServiceException
config
- Configuration properties to apply to the distribution.CloudFrontServiceException
@Deprecated public DistributionConfig updateDistributionConfig(java.lang.String id, Origin origin, java.lang.String[] cnames, java.lang.String comment, boolean enabled, LoggingStatus loggingStatus, boolean trustedSignerSelf, java.lang.String[] trustedSignerAwsAccountNumbers, java.lang.String[] requiredProtocols, java.lang.String defaultRootObject, java.lang.Long minTTL) throws CloudFrontServiceException
updateDistributionConfig(String, DistributionConfig)
.
This method performs all the steps necessary to update the configuration. It
first performs lookup on the distribution using
getDistributionConfig(String)
to find its origin and caller reference
values, then uses this information to apply your configuration changes.
id
- the distribution's unique identifier.origin
- the origin to associate with the distribution, either an Amazon S3 bucket or
a custom HTTP/S-accessible location.cnames
- A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be null, in which case the original CNAME aliases are retained.comment
- An optional comment to describe the distribution in your own terms
(max 128 characters). May be null, in which case the original comment is retained.enabled
- Should the distribution should be enabled and publicly accessible after the
configuration update?loggingStatus
- Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.trustedSignerSelf
- If true the owner of the distribution (you) will be be allowed to generate
signed URLs for a private distribution. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.trustedSignerAwsAccountNumbers
- Account Number identifiers for AWS account holders other than the
distribution's owner who will be allowed to generate signed URLs for a private
distribution. If null or empty, no additional AWS account holders may generate
signed URLs. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.requiredProtocols
- List of protocols that must be used by clients to retrieve content from the
distribution. If this value is null or is an empty array all protocols will be
permitted.defaultRootObject
- The name of an object that will be served when someone visits the root of a
distribution.minTTL
- The time to live (TTL) to apply to objects served by this distribution.CloudFrontServiceException
public DistributionConfig updateDistributionConfig(java.lang.String id, Origin origin, java.lang.String[] cnames, java.lang.String comment, boolean enabled, LoggingStatus loggingStatus, boolean trustedSignerSelf, java.lang.String[] trustedSignerAwsAccountNumbers, java.lang.String[] requiredProtocols, java.lang.String defaultRootObject) throws CloudFrontServiceException
This method performs all the steps necessary to update the configuration. It
first performs lookup on the distribution using
getDistributionConfig(String)
to find its origin and caller reference
values, then uses this information to apply your configuration changes.
id
- the distribution's unique identifier.origin
- the origin to associate with the distribution, either an Amazon S3 bucket or
a custom HTTP/S-accessible location.cnames
- A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be null, in which case the original CNAME aliases are retained.comment
- An optional comment to describe the distribution in your own terms
(max 128 characters). May be null, in which case the original comment is retained.enabled
- Should the distribution should be enabled and publicly accessible after the
configuration update?loggingStatus
- Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.trustedSignerSelf
- If true the owner of the distribution (you) will be be allowed to generate
signed URLs for a private distribution. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.trustedSignerAwsAccountNumbers
- Account Number identifiers for AWS account holders other than the
distribution's owner who will be allowed to generate signed URLs for a private
distribution. If null or empty, no additional AWS account holders may generate
signed URLs. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.requiredProtocols
- List of protocols that must be used by clients to retrieve content from the
distribution. If this value is null or is an empty array all protocols will be
permitted.defaultRootObject
- The name of an object that will be served when someone visits the root of a
distribution.CloudFrontServiceException
@Deprecated public StreamingDistributionConfig updateStreamingDistributionConfig(java.lang.String id, Origin origin, java.lang.String[] cnames, java.lang.String comment, boolean enabled, LoggingStatus loggingStatus) throws CloudFrontServiceException
updateDistributionConfig(String, DistributionConfig)
.
This method performs all the steps necessary to update the configuration. It
first performs lookup on the distribution using
getDistributionConfig(String)
to find its origin and caller reference
values, then uses this information to apply your configuration changes.
id
- the distribution's unique identifier.origin
- the origin to associate with the distribution, either an Amazon S3 bucket or
a custom HTTP/S-accessible location.cnames
- A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be null, in which case the original CNAME aliases are retained.comment
- An optional comment to describe the distribution in your own terms
(max 128 characters). May be null, in which case the original comment is retained.enabled
- Should the distribution should be enabled and publicly accessible after the
configuration update?loggingStatus
- Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.CloudFrontServiceException
@Deprecated public StreamingDistributionConfig updateStreamingDistributionConfig(java.lang.String id, Origin origin, java.lang.String[] cnames, java.lang.String comment, boolean enabled, LoggingStatus loggingStatus, boolean trustedSignerSelf, java.lang.String[] trustedSignerAwsAccountNumbers) throws CloudFrontServiceException
updateDistributionConfig(String, DistributionConfig)
.
This method performs all the steps necessary to update the configuration. It
first performs lookup on the distribution using
getDistributionConfig(String)
to find its origin and caller reference
values, then uses this information to apply your configuration changes.
id
- the distribution's unique identifier.cnames
- A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be null, in which case the original CNAME aliases are retained.comment
- An optional comment to describe the distribution in your own terms
(max 128 characters). May be null, in which case the original comment is retained.enabled
- Should the distribution should be enabled and publicly accessible after the
configuration update?loggingStatus
- Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.origin
- the origin to associate with the distribution, either an Amazon S3 bucket or
a custom HTTP/S-accessible location.trustedSignerSelf
- If true the owner of the distribution (you) will be be allowed to generate
signed URLs for a private distribution. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.trustedSignerAwsAccountNumbers
- Account Number identifiers for AWS account holders other than the
distribution's owner who will be allowed to generate signed URLs for a private
distribution. If null or empty, no additional AWS account holders may generate
signed URLs. Note: If either trustedSignerSelf or
trustedSignerAwsAccountNumbers parameters are provided the private distribution
will require signed URLs to access content.CloudFrontServiceException
public DistributionConfig updateDistributionConfig(java.lang.String id, Origin origin, java.lang.String[] cnames, java.lang.String comment, boolean enabled, LoggingStatus loggingStatus) throws CloudFrontServiceException
This method performs all the steps necessary to update the configuration. It
first performs lookup on the distribution using
getDistributionConfig(String)
to find its origin and caller reference
values, then uses this information to apply your configuration changes.
id
- the distribution's unique identifier.origin
- the origin to associate with the distribution, either an Amazon S3 bucket or
a custom HTTP/S-accessible location.cnames
- A list of up to 10 CNAME aliases to associate with the distribution. This
parameter may be null, in which case the original CNAME aliases are retained.comment
- An optional comment to describe the distribution in your own terms
(max 128 characters). May be null, in which case the original comment is retained.enabled
- Should the distribution should be enabled and publicly accessible after the
configuration update?loggingStatus
- Logging status settings (bucket, prefix) for the distribution. If this value
is null, logging will be disabled for the distribution.CloudFrontServiceException
public DistributionConfig updateDistributionConfig(java.lang.String id, DistributionConfig config) throws CloudFrontServiceException
This method performs all the steps necessary to update the configuration. It
first performs lookup on the distribution using
getDistributionConfig(String)
to find its origin and caller reference
values, then uses this information to apply your configuration changes.
id
- the distribution's unique identifier.config
- Configuration properties to apply to the distribution.CloudFrontServiceException
public void disableDistributionForDeletion(java.lang.String id) throws CloudFrontServiceException
updateDistributionConfig(String, Origin, String[], String, boolean, LoggingStatus)
method with default values for most of the distribution's configuration
settings.
Warning: Do not use this method on distributions you intend to keep, because it will reset most of the distribution's configuration settings such as CNAMEs and logging status.
id
- the distribution's unique identifier.CloudFrontServiceException
public void disableStreamingDistributionForDeletion(java.lang.String id) throws CloudFrontServiceException
updateStreamingDistributionConfig(String, Origin, String[], String, boolean, LoggingStatus)
method with default values for most of the distribution's configuration
settings.
Warning: Do not use this method on distributions you intend to keep, because it will reset most of the distribution's configuration settings such as CNAMEs and logging status.
id
- the distribution's unique identifier.CloudFrontServiceException
protected void deleteDistributionImpl(boolean isStreaming, java.lang.String distributionId) throws CloudFrontServiceException
isStreaming
- Only return streaming distributionsdistributionId
- The distribution's unique identifier.CloudFrontServiceException
public void deleteDistribution(java.lang.String id) throws CloudFrontServiceException
This method performs many of the steps necessary to delete a disabled
distribution. It first performs lookup on the distribution using
getDistributionConfig(String)
to find its ETag value, then uses
this information to delete the distribution.
Because it can take a long time (minutes) to disable a distribution, this task is not performed automatically by this method. In your own code, you need to verify that a distribution is disabled with a status of Deployed before you invoke this method.
id
- the distribution's unique identifier.CloudFrontServiceException
public void deleteStreamingDistribution(java.lang.String id) throws CloudFrontServiceException
This method performs many of the steps necessary to delete a disabled
distribution. It first performs lookup on the distribution using
getDistributionConfig(String)
to find its ETag value, then uses
this information to delete the distribution.
Because it can take a long time (minutes) to disable a distribution, this task is not performed automatically by this method. In your own code, you need to verify that a distribution is disabled with a status of Deployed before you invoke this method.
id
- the distribution's unique identifier.CloudFrontServiceException
public OriginAccessIdentity createOriginAccessIdentity(java.lang.String callerReference, java.lang.String comment) throws CloudFrontServiceException
callerReference
- A user-set unique reference value that ensures the request can't be replayed
(max UTF-8 encoding size 128 bytes). This parameter may be null, in which
case your computer's local epoch time in milliseconds will be used.comment
- An optional comment to describe the identity (max 128 characters). May be null.CloudFrontServiceException
public java.util.List<OriginAccessIdentity> getOriginAccessIdentityList() throws CloudFrontServiceException
OriginAccessIdentity
objects describing the identities.CloudFrontServiceException
public OriginAccessIdentity getOriginAccessIdentity(java.lang.String id) throws CloudFrontServiceException
id
- The identifier of the Origin Access Identity.CloudFrontServiceException
public OriginAccessIdentityConfig getOriginAccessIdentityConfig(java.lang.String id) throws CloudFrontServiceException
id
- The identifier of the Origin Access Identity.CloudFrontServiceException
public OriginAccessIdentityConfig updateOriginAccessIdentityConfig(java.lang.String id, java.lang.String comment) throws CloudFrontServiceException
id
- The identifier of the Origin Access Identity.comment
- A new comment to apply to the identity.CloudFrontServiceException
public void deleteOriginAccessIdentity(java.lang.String id) throws CloudFrontServiceException
id
- The identifier of the Origin Access Identity.CloudFrontServiceException
- exceptionpublic Invalidation invalidateObjects(java.lang.String distributionId, java.lang.String[] objectKeys, java.lang.String callerReference) throws CloudFrontServiceException
distributionId
- The distribution's unique identifier.objectKeys
- S3 object key names of object(s) to invalidate.callerReference
- Unique description for this distribution configCloudFrontServiceException
- exceptionpublic Invalidation invalidateObjects(java.lang.String distributionId, S3Object[] objects, java.lang.String callerReference) throws CloudFrontServiceException
distributionId
- The distribution's unique identifier.objects
- S3 object(s) to invalidate.callerReference
- Unique description for this distribution configCloudFrontServiceException
- exceptionpublic Invalidation getInvalidation(java.lang.String distributionId, java.lang.String invalidationId) throws CloudFrontServiceException
distributionId
- The distribution's unique identifier.invalidationId
- The identifier for the invalidation requestCloudFrontServiceException
- exceptionpublic InvalidationList listInvalidations(java.lang.String distributionId, java.lang.String nextMarker, int pagingSize) throws CloudFrontServiceException
distributionId
- The distribution's unique identifier.nextMarker
- a marker string indicating where to begin the next page of listing results.
Start with null for an initial listing page, then set to the NextMarker value
of each subsequent page returned.pagingSize
- maximum number of invalidation summaries to include in each result page, up to 100.CloudFrontServiceException
- exceptionpublic java.util.List<InvalidationSummary> listInvalidations(java.lang.String distributionId) throws CloudFrontServiceException
distributionId
- The distribution's unique identifier.CloudFrontServiceException
- exceptionpublic static java.lang.String sanitizeS3BucketName(java.lang.String proposedBucketName)
proposedBucketName
- the proposed S3 bucket name that will be sanitized.DEFAULT_BUCKET_SUFFIX
added, if necessary.protected static java.lang.String makeStringUrlSafe(java.lang.String str) throws java.io.UnsupportedEncodingException
str
- java.io.UnsupportedEncodingException
protected static java.lang.String makeBytesUrlSafe(byte[] bytes) throws java.io.UnsupportedEncodingException
bytes
- java.io.UnsupportedEncodingException
public static java.lang.String buildPolicyForSignedUrl(java.lang.String resourcePath, java.util.Date epochDateLessThan, java.lang.String limitToIpAddressCIDR, java.util.Date epochDateGreaterThan) throws CloudFrontServiceException
resourcePath
- An optional HTTP/S or RTMP resource path that restricts which distribution and S3 objects
will be accessible in a signed URL. For standard distributions the resource URL will be
"http://" + distributionName + "/" + objectKey (may also include URL
parameters. For distributions with the HTTPS required protocol, the resource URL
must start with "https://". RTMP resources do not take the form of a URL,
and instead the resource path is nothing but the stream's name.
The '*' and '?' characters can be used as a wildcards to allow multi-character or single-character matches respectively:
epochDateLessThan
- The 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 a CIDR range. If null, the CIDR will be 0.0.0.0/0 and any
client will be permitted.epochDateGreaterThan
- An optional time and date when the signed URL will become active. If null, the signed
URL will be active as soon as it is created.CloudFrontServiceException
- exceptionpublic static java.lang.String signUrl(java.lang.String resourceUrlOrPath, java.lang.String keyPairId, byte[] derPrivateKey, java.lang.String policy) throws CloudFrontServiceException
resourceUrlOrPath
- The URL or path that uniquely identifies a resource within a distribution.
For standard distributions the resource URL will be
"http://" + distributionName + "/" + objectKey (may also include URL
parameters. For distributions with the HTTPS required protocol, the resource URL
must start with "https://". RTMP resources do not take the form of a URL,
and instead the resource path is nothing but the stream's name.keyPairId
- Identifier of a public/private certificate keypair already configured in your
Amazon Web Services account.derPrivateKey
- The RSA private key data that corresponding to the certificate keypair identified by
keyPairId, in DER format. To convert a standard PEM private key file into this format
use the utility method EncryptionUtil.convertRsaPemToDer(java.io.InputStream)
policy
- A policy document that describes the access permissions that will be applied by the
signed URL. To generate a custom policy use
buildPolicyForSignedUrl(String, Date, String, Date)
.CloudFrontServiceException
- exceptionpublic static java.lang.String signUrlCanned(java.lang.String resourceUrlOrPath, java.lang.String keyPairId, byte[] derPrivateKey, java.util.Date epochDateLessThan) throws CloudFrontServiceException
resourceUrlOrPath
- The URL or path that uniquely identifies a resource within a distribution.
For standard distributions the resource URL will be
"http://" + distributionName + "/" + objectKey (may also include URL
parameters. For distributions with the HTTPS required protocol, the resource URL
must start with "https://". RTMP resources do not take the form of a URL,
and instead the resource path is nothing but the stream's name.keyPairId
- Identifier of a public/private certificate keypair already configured in your
Amazon Web Services account.derPrivateKey
- The RSA private key data that corresponding to the certificate keypair identified by
keyPairId, in DER format. To convert a standard PEM private key file into this format
use the utility method EncryptionUtil.convertRsaPemToDer(java.io.InputStream)
epochDateLessThan
- The time and date when the signed URL will expire. REQUIRED.CloudFrontServiceException
- exception