This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Encrypt in ColdFusion | |
Summary | |
1. Generate a cryptographically random key with GenerateSecretKey(). Do *not* use a self generated | |
password, which is less secure. | |
2. Generate a random IV (initialization vector)][2] and decode into binary. | |
3. Encrypt the plain text with AES/CBC/PKCS5Padding | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Amazon S3 REST Wrapper | |
* Version Date: 2016-04-12 | |
* | |
* Copyright 2015 CF Webtools | cfwebtools.com | |
* | |
* Licensed 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 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Amazon Web Services Signature 4 Utility for ColdFusion | |
* Version Date: 2016-04-12 (Alpha) | |
* | |
* Copyright 2016 Leigh (cfsearching) | |
* | |
* Requirements: Adobe ColdFusion 10+ | |
* AWS Signature 4 specifications: http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/** | |
* URI encoding per RFC 3986, which has treats the following as unreserved: ALPHA / DIGIT / "-" / "." / "_" / "~" | |
* @text Text to encode | |
* @returns URI encoded text | |
*/ | |
public function encodeRFC3986(required string text) { | |
// Requires CF10+ | |
Local.encoded = encodeForURL(arguments.text); | |
// Reverse encoding of tilde "~" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
CFML translation of Amazon Web Services Example - Task 1: | |
http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html | |
---> | |
<h1>Task 1: Create a Canonical Request for Signature Version 4 (ColdFusion)</h1> | |
<div> | |
<strong>Canonical request pseudocode</strong> | |
<pre>CanonicalRequest = HTTPRequestMethod + '\n' + | |
CanonicalURI + '\n' + | |
CanonicalQueryString + '\n' + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
CFML translation of Amazon Web Services Example - Task 2: | |
http://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html | |
---> | |
<h1>Task 2: Create a String to Sign for Signature Version 4</h1> | |
<div> | |
<strong>Structure of string to sign</strong> | |
<pre>StringToSign = Algorithm + '\n' + | |
RequestDate + '\n' + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
CFML translation of Amazon Web Services Example - Task 3: | |
http://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html | |
---> | |
<h1>Task 3: Calculate the AWS Signature Version 4</h1> | |
<div> | |
<strong>Pseudocode for deriving a signing key</strong> | |
<pre> | |
kSecret = Your AWS Secret Access Key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
CFML translation of Amazon Web Services Example - Task 4: | |
http://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html | |
Note: Translation only includes generating Authorization header | |
---> | |
<h1>Task 4: Add the Signing Information to the Request</h1> | |
<div> | |
After you calculate the signature, you add it to the request. You can add the signing information to a request in one of two ways: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/* | |
IMPORTANT: Make sure fileGetMimeType("c:/path/article.json") returns the | |
correct mime type in your environment: | |
ie: Should return: "application/json" | |
... and not : "text/plain" | |
*/ | |
// Modify these variables for your environment |