-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Encryption autoconfiguration with AES as a default
- Loading branch information
Showing
15 changed files
with
135 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
...ring/everest/starterkit/axon/cryptoshredding/encryption/AesEncrypterDecrypterFactory.java
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
src/main/java/engineering/everest/starterkit/axon/cryptoshredding/encryption/Decrypter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package engineering.everest.starterkit.axon.cryptoshredding.encryption; | ||
|
||
import javax.crypto.SecretKey; | ||
|
||
public interface Decrypter { | ||
String decrypt(SecretKey secretKey, byte[] ciphertext); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...erest/starterkit/axon/cryptoshredding/encryption/DefaultAesEncrypterDecrypterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package engineering.everest.starterkit.axon.cryptoshredding.encryption; | ||
|
||
import java.security.SecureRandom; | ||
|
||
class DefaultAesEncrypterDecrypterFactory implements EncrypterDecrypterFactory { | ||
|
||
private final SecureRandom secureRandom; | ||
|
||
public DefaultAesEncrypterDecrypterFactory() { | ||
this.secureRandom = new SecureRandom(); | ||
} | ||
|
||
public Encrypter createEncrypter() { | ||
return new DefaultAesEncrypter(secureRandom); | ||
} | ||
|
||
public Decrypter createDecrypter() { | ||
return new DefaultAesDecrypter(secureRandom); | ||
} | ||
} |
7 changes: 2 additions & 5 deletions
7
...shredding/encryption/AesKeyGenerator.java → ...ng/encryption/DefaultAesKeyGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/java/engineering/everest/starterkit/axon/cryptoshredding/encryption/Encrypter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package engineering.everest.starterkit.axon.cryptoshredding.encryption; | ||
|
||
import javax.crypto.SecretKey; | ||
|
||
public interface Encrypter { | ||
byte[] encrypt(SecretKey secretKey, String cleartext); | ||
} |
7 changes: 7 additions & 0 deletions
7
...neering/everest/starterkit/axon/cryptoshredding/encryption/EncrypterDecrypterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package engineering.everest.starterkit.axon.cryptoshredding.encryption; | ||
|
||
public interface EncrypterDecrypterFactory { | ||
Encrypter createEncrypter(); | ||
|
||
Decrypter createDecrypter(); | ||
} |
23 changes: 23 additions & 0 deletions
23
...ering/everest/starterkit/axon/cryptoshredding/encryption/EncryptionAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package engineering.everest.starterkit.axon.cryptoshredding.encryption; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.security.NoSuchAlgorithmException; | ||
|
||
@Configuration | ||
public class EncryptionAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(EncrypterDecrypterFactory.class) | ||
public EncrypterDecrypterFactory encrypterDecrypterFactory() { | ||
return new DefaultAesEncrypterDecrypterFactory(); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(engineering.everest.starterkit.axon.cryptoshredding.encryption.KeyGenerator.class) | ||
public KeyGenerator keyGenerator() throws NoSuchAlgorithmException { | ||
return new DefaultAesKeyGenerator(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...ain/java/engineering/everest/starterkit/axon/cryptoshredding/encryption/KeyGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package engineering.everest.starterkit.axon.cryptoshredding.encryption; | ||
|
||
import javax.crypto.SecretKey; | ||
|
||
public interface KeyGenerator { | ||
SecretKey generateKey(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.