Skip to content

Commit

Permalink
Merge pull request #18 from mercari/redesigned_package_structure
Browse files Browse the repository at this point in the history
Redesigned package structure
  • Loading branch information
laughingman7743 authored Mar 13, 2023
2 parents b4a5876 + 96eb8f3 commit 9186e05
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
import com.github.hpgrahsl.kafka.connect.transforms.kryptonite.validators.KeySourceValidator;
import com.github.hpgrahsl.kafka.connect.transforms.kryptonite.validators.TimeUnitValidator;
import com.github.hpgrahsl.kryptonite.CipherMode;
import com.github.hpgrahsl.kryptonite.ConfigDataKeyVault;
import com.github.hpgrahsl.kryptonite.GcpSecretManagerKeyVault;
import com.github.hpgrahsl.kryptonite.Kryptonite;
import com.github.hpgrahsl.kryptonite.NoOpKeyStrategy;
import com.github.hpgrahsl.kryptonite.key.ConfigDataKeyVault;
import com.github.hpgrahsl.kryptonite.key.NoOpKeyStrategy;
import com.github.hpgrahsl.kryptonite.key.gcp.GcpSecretManagerKeyVault;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package com.github.hpgrahsl.kryptonite;

import com.github.hpgrahsl.kryptonite.crypto.AesGcmNoPadding;
import com.github.hpgrahsl.kryptonite.crypto.CryptoAlgorithm;
import com.github.hpgrahsl.kryptonite.key.KeyVault;
import java.util.Base64;
import java.util.LinkedHashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.github.hpgrahsl.kryptonite;
package com.github.hpgrahsl.kryptonite.crypto;

import java.nio.ByteBuffer;
import java.security.SecureRandom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.github.hpgrahsl.kryptonite;
package com.github.hpgrahsl.kryptonite.crypto;

public interface CryptoAlgorithm {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.github.hpgrahsl.kryptonite;
package com.github.hpgrahsl.kryptonite.key;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.github.hpgrahsl.kryptonite;
package com.github.hpgrahsl.kryptonite.key;

@SuppressWarnings("serial")
public class KeyException extends RuntimeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.github.hpgrahsl.kryptonite;
package com.github.hpgrahsl.kryptonite.key;

@SuppressWarnings("serial")
public class KeyInvalidException extends KeyException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.github.hpgrahsl.kryptonite;
package com.github.hpgrahsl.kryptonite.key;

@SuppressWarnings("serial")
public class KeyNotFoundException extends KeyException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.github.hpgrahsl.kryptonite;
package com.github.hpgrahsl.kryptonite.key;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -27,5 +27,5 @@ public Map<String, byte[]> getKeyCache() {
return keyCache;
}

abstract byte[] processKey(byte[] origKeyBytes, String identifier);
public abstract byte[] processKey(byte[] origKeyBytes, String identifier);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* limitations under the License.
*/

package com.github.hpgrahsl.kryptonite;
package com.github.hpgrahsl.kryptonite.key;

public abstract class KeyVault {

KeyStrategy keyStrategy;
protected KeyStrategy keyStrategy;

public KeyVault(KeyStrategy keyStrategy) {
this.keyStrategy = keyStrategy;
}

abstract byte[] readKey(String identifier);
public abstract byte[] readKey(String identifier);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.github.hpgrahsl.kryptonite;
package com.github.hpgrahsl.kryptonite.key;

public class NoOpKeyStrategy extends KeyStrategy {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.hpgrahsl.kryptonite;
package com.github.hpgrahsl.kryptonite.key.gcp;

import com.github.hpgrahsl.kryptonite.key.KeyStrategy;
import com.google.cloud.kms.v1.CryptoKeyName;
import com.google.cloud.kms.v1.DecryptResponse;
import com.google.cloud.kms.v1.KeyManagementServiceClient;
Expand All @@ -21,7 +22,7 @@ public GcpKmsKeyStrategy(String keyName) throws IOException {
}

@Override
byte[] processKey(byte[] origKeyBytes, String identifier) {
public byte[] processKey(byte[] origKeyBytes, String identifier) {
LOGGER.info("Process key: " + identifier);
LOGGER.info("KEK name: " + keyName);
DecryptResponse resp = client.decrypt(keyName, ByteString.copyFrom(origKeyBytes));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.github.hpgrahsl.kryptonite;
package com.github.hpgrahsl.kryptonite.key.gcp;

import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.github.benmanes.caffeine.cache.RemovalCause;
import com.github.benmanes.caffeine.cache.RemovalListener;
import com.github.hpgrahsl.kryptonite.key.KeyStrategy;
import com.github.hpgrahsl.kryptonite.key.KeyVault;
import com.google.cloud.secretmanager.v1.AccessSecretVersionResponse;
import com.google.cloud.secretmanager.v1.SecretManagerServiceClient;
import com.google.cloud.secretmanager.v1.SecretManagerServiceClient.ListSecretVersionsPagedResponse;
Expand Down Expand Up @@ -79,7 +81,7 @@ private byte[] accessSecretVersion(String identifier) {
}

@Override
byte[] readKey(String identifier) {
public byte[] readKey(String identifier) {
byte[] keyBytes = secretCache.get(identifier);
if (keyBytes == null) {
LOGGER.info("Read key: " + identifier);
Expand Down

0 comments on commit 9186e05

Please sign in to comment.