Skip to content

Commit

Permalink
Add alias -> key mapping.
Browse files Browse the repository at this point in the history
Former-commit-id: d8c4bcbb6f3f6d7028cad0beefb3393c53aa4a87
  • Loading branch information
ylangisc committed Jun 6, 2016
1 parent d3ce995 commit 137d833
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions s3/src/main/java/ch/cyberduck/core/kms/KMSEncryptionFeature.java
Expand Up @@ -37,11 +37,11 @@
import ch.cyberduck.core.s3.S3PathContainerService;
import ch.cyberduck.core.s3.S3Session;

import com.amazonaws.services.kms.model.AliasListEntry;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;

import java.util.HashSet;
import java.util.Set;
import java.util.*;
import java.util.concurrent.Callable;

import com.amazonaws.AmazonClientException;
Expand Down Expand Up @@ -162,10 +162,17 @@ public String getAWSSecretKey() {
);
try {
final Set<Algorithm> keys = new HashSet<Algorithm>();
for(KeyListEntry entry : client.listKeys().getKeys()) {
final Map<String, String> aliases = new HashMap<String, String>();
for (AliasListEntry entry : client.listAliases().getAliases()) {
aliases.put(entry.getAliasArn(), entry.getAliasName());
}
for (KeyListEntry entry : client.listKeys().getKeys()) {
keys.add(new Algorithm(SSE_KMS_DEFAULT.algorithm, entry.getKeyArn()) {
@Override
public String getDescription() {
if (aliases.containsKey(entry.getKeyArn())) {
return String.format("SSE-KMS (%s - %s)", aliases.get(entry.getKeyArn()), entry.getKeyArn());
}
return String.format("SSE-KMS (%s)", entry.getKeyArn());
}
});
Expand Down

0 comments on commit 137d833

Please sign in to comment.