버전 1에서 버전 2로 Amazon CloudFront 사전 서명 변경
이 주제에서는 버전 1(v1)에서 버전 2(v2)로의 Amazon CloudFront 변경 사항에 대해 자세히 설명합니다.
높은 수준의 변경 사항
| 변경 사항 |
v1 |
v2 |
|
Maven 종속성
|
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.12.5871</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>cloudfront</artifactId>
</dependency>
</dependencies>
|
<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.27.212</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>cloudfront</artifactId>
</dependency>
</dependencies>
|
| 패키지 이름 |
com.amazonaws.services.cloudfront |
software.amazon.awssdk.services.cloudfront |
| 클래스 이름 |
CloudFrontUrlSigner
CloudFrontCookieSigner
|
CloudFrontUtilities
SignedUrl
CannedSignerRequest
CustomSignerRequest
|
1 최신 버전. 2 최신 버전.
API 변경 사항
| 동작 |
v1 |
v2 |
| 미리 준비된 요청 구축 |
인수는 API로 직접 전달됩니다. |
CannedSignerRequest cannedRequest =
CannedSignerRequest.builder()
.resourceUrl(resourceUrl)
.privateKey(privateKey)
.keyPairId(keyPairId)
.expirationDate(expirationDate)
.build();
|
| 사용자 지정 요청 구축 |
인수는 API로 직접 전달됩니다. |
CustomSignerRequest customRequest =
CustomSignerRequest.builder()
.resourceUrl(resourceUrl)
.resourceUrlPattern(resourceUrlPattern)
.privateKey(keyFile)
.keyPairId(keyPairId)
.expirationDate(expirationDate)
.activeDate(activeDate)
.ipRange(ipRange)
.build();
|
| 서명된 URL 생성(미리 준비됨) |
String signedUrl =
CloudFrontUrlSigner.getSignedURLWithCannedPolicy(
resourceUrl, keyPairId, privateKey, expirationDate);
|
CloudFrontUtilities cloudFrontUtilities =
CloudFrontUtilities.create();
SignedUrl signedUrl =
cloudFrontUtilities.getSignedUrlWithCannedPolicy(cannedRequest);
String url = signedUrl.url();
|
| 서명된 쿠키 생성(사용자 지정) |
CookiesForCustomPolicy cookies =
CloudFrontCookieSigner.getCookiesForCustomPolicy(
resourceUrl, privateKey, keyPairId, expirationDate,
activeDate, ipRange);
|
CloudFrontUtilities cloudFrontUtilities =
CloudFrontUtilities.create();
CookiesForCustomPolicy cookies =
cloudFrontUtilities.getCookiesForCustomPolicy(customRequest);
|
Java v1에서 Java SDK는 쿠키 헤더를 Map.Entry<String,
String>으로 제공합니다.
Map.Entry<String, String> signatureMap = cookies.getSignature();
String signatureKey = signatureMap.getKey(); // "CloudFront-Signature"
String signatureValue = signatureMap.getValue(); // "[SIGNATURE_VALUE]"
Java v2 SDK는 전체 헤더를 단일 String으로 제공합니다.
String signatureHeaderValue = cookies.signatureHeaderValue(); // "CloudFront-Signature=[SIGNATURE_VALUE]"