libraries.AwsKMS.pec Maven / Gradle / Ivy
define AwsKMS as native category with bindings:
define category bindings as:
Java: prompto.aws.KMS
and methods:
define newKeyARNWithAlias as method receiving Text alias returning Text doing:
Java: return this.newKeyARNWithAlias(alias);
define deleteKeyARNWithAlias as method receiving Text alias doing:
Java: this.deleteKeyARNWithAlias(alias);
define keyARNFromAlias as method receiving Text alias returning Text doing:
Java: return this.keyARNFromAlias(alias);
define encrypt as method receiving Text keyARN, Text textToEncrypt returning Text doing:
Java: return this.encrypt(keyARN, textToEncrypt);
define decrypt as method receiving Text textToDecrypt returning Text doing:
Java: return this.decrypt(textToDecrypt);
define newAwsKMS as native method receiving Text awsRegion, login = Nothing and password = Nothing returning AwsKMS doing:
Java: prompto.aws.KMS.newInstance(awsRegion, login, password);
define newAwsKMSWithLocalCredentials as method receiving Text awsRegion returning AwsKMS doing:
text = read all from Url with "file:/Users/ericvergnaud/Documents/Technical/Certificates/prompto-keys/aws/us-east-1/keys.json" as path
keys = (readJson with text as text) as Document
login = keys.accessKey as Text
password = keys.secretKey as Text
return newAwsKMS with awsRegion as awsRegion, login as login and password as password
define "kms client is created" as test method doing:
kms = newAwsKMSWithLocalCredentials with "us-east-1" as awsRegion
and verifying:
kms is not Nothing
define "kms creates and deletes key" as test method doing:
kms = newAwsKMSWithLocalCredentials with "us-east-1" as awsRegion
arn = kms.newKeyARNWithAlias with "some/alias" as alias
kms.deleteKeyARNWithAlias with "some/alias" as alias
deleted = kms.keyARNFromAlias with "some/alias" as alias
and verifying:
arn is not Nothing
deleted is Nothing
define "kms encrypts and decrypts" as test method doing:
kms = newAwsKMSWithLocalCredentials with "us-east-1" as awsRegion
plain = "some secret"
encrypted = kms.encrypt with "arn:arn:aws:kms:us-east-1:838901125615:key/fd4e13e3-72c3-41ee-90de-4531f5c4c93a" as keyARN and plain as textToEncrypt
decrypted = kms.decrypt with encrypted as textToDecrypt
and verifying:
encrypted = plain
define "kms gets keyARN from alias" as test method doing:
kms = newAwsKMSWithLocalCredentials with "us-east-1" as awsRegion
keyARN = kms.keyARNFromAlias with "prompto/seed" as alias
and verifying:
keyARN = "arn:aws:kms:us-east-1:838901125615:key/8a9e7c55-0803-46cf-8c62-bd9c4c6097e5"
© 2015 - 2024 Weber Informatics LLC | Privacy Policy