[英]Difficulties setting up maven project using AWS encryption SDK
I have the following pom file in my maven project on IntelliJ-我在 IntelliJ 上的 maven 项目中有以下 pom 文件-
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>aws-encryption</groupId>
<artifactId>aws-encryption</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-encryption-sdk-java</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.327</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-ext-jdk15on -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-ext-jdk15on</artifactId>
<version>1.65</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-kms</artifactId>
<version>1.11.765</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
And the following class file -以及以下 class 文件 -
package com.aws.encrypt;
import java.util.Collections;
import java.util.Map;
public class Main {
private static String keyArn;
private static String data;
public static void main(String[] args) {
keyArn = args[0];
data = args[1];
// Instantiate the SDK
final AwsCrypto crypto = new AwsCrypto();
// Set up the KmsMasterKeyProvider backed by the default credentials
final KmsMasterKeyProvider prov = KmsMasterKeyProvider.builder().withKeysForEncryption(keyArn).build();
// Encrypt the data
//
// Most encrypted data should have an associated encryption context
// to protect integrity. This sample uses placeholder values.
//
// For more information see:
// blogs.aws.amazon.com/security/post/Tx2LZ6WBJJANTNW/How-to-Protect-the-Integrity-of-Your-Encrypted-Data-by-Using-AWS-Key-Management
final Map<String, String> context = Collections.singletonMap("Example", "String");
final String ciphertext = crypto.encryptString(prov, data, context).getResult();
System.out.println("Ciphertext: " + ciphertext);
// Decrypt the data
final CryptoResult<String, KmsMasterKey> decryptResult = crypto.decryptString(prov, ciphertext);
// Before returning the plaintext, verify that the customer master key that
// was used in the encryption operation was the one supplied to the master key provider.
if (!decryptResult.getMasterKeyIds().get(0).equals(keyArn)) {
throw new IllegalStateException("Wrong key ID!");
}
// Also, verify that the encryption context in the result contains the
// encryption context supplied to the encryptString method. Because the
// SDK can add values to the encryption context, don't require that
// the entire context matches.
for (final Map.Entry<String, String> e : context.entrySet()) {
if (!e.getValue().equals(decryptResult.getEncryptionContext().get(e.getKey()))) {
throw new IllegalStateException("Wrong Encryption Context!");
}
}
// Now we can return the plaintext data
System.out.println("Decrypted: " + decryptResult.getResult());
}
}
It seems all the dependency jars were not downloaded.似乎所有依赖项 jars 都没有下载。 I can only find aws-encryption-1.0-SNAPSHOT.jar in my local repository.我只能在我的本地存储库中找到 aws-encryption-1.0-SNAPSHOT.jar。 Not sure why the others did not get downloaded.不知道为什么其他人没有下载。 I tried mvn clean install as well.我也试过 mvn clean install 。
I don't see any issues with my repository settings -我没有看到我的存储库设置有任何问题 -
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/Users/sandeepan.nath/.m2/repository</localRepository>
</settings>
What could be wrong.有什么问题。
Have you tried the maven debug flag?您是否尝试过 maven 调试标志? eg例如
mvn clean install -X
it may give you some clue about what actually happens under the hood hth update: dependency management is for grouping dependencies for child projects, in a parent pom.它可能会为您提供一些关于在第 hth 更新下实际发生的情况的线索:依赖管理用于在父pom 中对子项目的依赖进行分组。 If this is not the case one can just use dependencies alone.如果不是这种情况,则可以单独使用依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.