Skip to content

Commit

Permalink
rm decoder class
Browse files Browse the repository at this point in the history
  • Loading branch information
d-t-w committed Dec 6, 2022
1 parent 7ac5a14 commit f27c8c5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 122 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).

## [1.0.3] - 2022-12-06

- rm Decoder class entirely

## [1.0.2] - 2022-12-06

- rm java src path

## [1.0.1] - 2022-12-06

- rm AOT
Expand Down
56 changes: 1 addition & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,58 +328,4 @@ SECURITY_PROTOCOL=SASL_PLAINTEXT
SASL_MECHANISM=PLAIN
SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="kpow" password="kpow-secret";
SSL_TRUSTSTORE_LOCATION=/ssl/truststore.jks```
```

## Java API

Kpow Secure is implemented in our langauge of choice, Clojure.

Use the Java `io.kpow.secure.Decoder` to decrypt payloads `java.lang.String` or `java.util.Properties`.

#### Decrypt payload to java.lang.String with base64 key text

```java
String plainText = Decoder.text("//iQh9KYe7pM+mevjifZPrm7YE2+rRloG1E15zzjR88=", "ARAOGa3BAZ2TMxbU1aj+tFYfNHNwnRh3r/w2sG7FA4L7fVRzArpzrxAd2dUovyDfel++FHgW1IFrinZddTo+KiYFYm2rsn+ul65eQ1L5t9MsBq3LpuGjoFDSxkYFZweo/w0=");
```

```
=>
SSL_KEYSTORE_PASSWORD=keypass1234\nSSL_TRUSTSTORE_PASSWORD=trustpass1234
```

#### Decrypt payload to java.lang.String where key is expected in KPOW_SECURE_KEY environment variable or at KPOW_SECURE_KEY_LOCATION

```java
String plainText = Decoder.text( "ARAOGa3BAZ2TMxbU1aj+tFYfNHNwnRh3r/w2sG7FA4L7fVRzArpzrxAd2dUovyDfel++FHgW1IFrinZddTo+KiYFYm2rsn+ul65eQ1L5t9MsBq3LpuGjoFDSxkYFZweo/w0=");
```

```
=>
SSL_KEYSTORE_PASSWORD=keypass1234\nSSL_TRUSTSTORE_PASSWORD=trustpass1234
```

#### Decrypt payload to java.util.Properties with base64 key text

```java
Properties myProps = Decoder.properties("//iQh9KYe7pM+mevjifZPrm7YE2+rRloG1E15zzjR88=", "ARAOGa3BAZ2TMxbU1aj+tFYfNHNwnRh3r/w2sG7FA4L7fVRzArpzrxAd2dUovyDfel++FHgW1IFrinZddTo+KiYFYm2rsn+ul65eQ1L5t9MsBq3LpuGjoFDSxkYFZweo/w0=");
```

```clojure
;; Java API returns this as a java.util.Properties object
=>
{"SSL_TRUSTSTORE_PASSWORD" "trustpass1234"
"SSL_KEYSTORE_PASSWORD" "keypass1234"}
```

#### Decrypt payload to java.util.Properties where key is expected in KPOW_SECURE_KEY environment variable or at KPOW_SECURE_KEY_LOCATION

```java
Properties myProps = Decoder.properties("ARAOGa3BAZ2TMxbU1aj+tFYfNHNwnRh3r/w2sG7FA4L7fVRzArpzrxAd2dUovyDfel++FHgW1IFrinZddTo+KiYFYm2rsn+ul65eQ1L5t9MsBq3LpuGjoFDSxkYFZweo/w0=");
```

```clojure
;; Java API returns this as a java.util.Properties object
=>
{"SSL_TRUSTSTORE_PASSWORD" "trustpass1234"
"SSL_KEYSTORE_PASSWORD" "keypass1234"}
```
```
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject io.factorhouse/kpow-secure "1.0.2"
(defproject io.factorhouse/kpow-secure "1.0.3"

:description "Secure Key Generation and Payload Encryption"

Expand Down
48 changes: 0 additions & 48 deletions src-java/io/kpow/secure/Decoder.java

This file was deleted.

21 changes: 3 additions & 18 deletions test/kpow/secure_test.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
(ns kpow.secure-test
(:require [clojure.test :refer [deftest is testing]]
(:require [clojure.test :refer [deftest is]]
[kpow.secure :as secure]
[kpow.secure.key :as key])
(:import (io.kpow.secure Decoder)))
[kpow.secure.key :as key]))

(def sample-input (str "SSL_KEYSTORE_PASSWORD=keypass1234\n"
"SSL_TRUSTSTORE_PASSWORD=trustpass1234"))
Expand Down Expand Up @@ -101,21 +100,7 @@
"ssl.truststore.location" "/ssl/truststore.jks"
"ssl.truststore.password" "1234"}
(-> (secure/decrypted (slurp "dev-resources/secure/passphrase.key") (slurp "dev-resources/secure/props.env.aes"))
(secure/->map))))

(testing "interop"

(is (= {"SASL_JAAS_CONFIG" "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"kpow\" password=\"kpow-secret\";"
"SASL_MECHANISM" "PLAIN"
"SECURITY_PROTOCOL" "SASL_PLAINTEXT"
"SSL_TRUSTSTORE_LOCATION" "/ssl/truststore.jks"
"SSL_TRUSTSTORE_PASSWORD" "password1234"}
(into {} (Decoder/properties (slurp "dev-resources/secure/passphrase.key") (slurp "dev-resources/secure/config.env.aes")))))

(is (= sample-input
(Decoder/text
"//iQh9KYe7pM+mevjifZPrm7YE2+rRloG1E15zzjR88="
"ARDuFSOqVc5l8dPe2l8jLnRvf2Y2/ZnhWNtkuZuoP1Updxo4cFAsFr+eM4WVcH/yIogK3ypO4sLp7sSXjkXv3L5Ci/5poJG2U/+No5ySBR1BhDjcV3mkO3TBYp4nQu65mpA="))))))
(secure/->map))))))

(deftest special-characters

Expand Down

0 comments on commit f27c8c5

Please sign in to comment.