-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relaxed isolation of CryptoShreddingKeyService::getExistingSecretKey()
to allow reading of commited keys within an ongoing transaction
- Loading branch information
Showing
5 changed files
with
135 additions
and
48 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
57 changes: 51 additions & 6 deletions
57
src/main/java/engineering/everest/axon/cryptoshredding/persistence/PersistableSecretKey.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 |
---|---|---|
@@ -1,22 +1,67 @@ | ||
package engineering.everest.axon.cryptoshredding.persistence; | ||
|
||
import engineering.everest.axon.cryptoshredding.TypeDifferentiatedSecretKeyId; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.Hibernate; | ||
|
||
import javax.persistence.EmbeddedId; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Lob; | ||
import java.util.Objects; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Entity(name = "cryptoshreddingkeys") | ||
public class PersistableSecretKey { | ||
@EmbeddedId | ||
private TypeDifferentiatedSecretKeyId id; | ||
@Lob | ||
private byte[] key; | ||
private String algorithm; | ||
|
||
public PersistableSecretKey() {} | ||
|
||
public PersistableSecretKey(TypeDifferentiatedSecretKeyId id, byte[] key, String algorithm) { | ||
this.id = id; | ||
this.key = key; | ||
this.algorithm = algorithm; | ||
} | ||
|
||
public TypeDifferentiatedSecretKeyId getId() { | ||
return id; | ||
} | ||
|
||
public void setId(TypeDifferentiatedSecretKeyId id) { | ||
this.id = id; | ||
} | ||
|
||
public byte[] getKey() { | ||
return key; | ||
} | ||
|
||
public void setKey(byte[] key) { | ||
this.key = key; | ||
} | ||
|
||
public String getAlgorithm() { | ||
return algorithm; | ||
} | ||
|
||
public void setAlgorithm(String algorithm) { | ||
this.algorithm = algorithm; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) { | ||
return false; | ||
} | ||
PersistableSecretKey that = (PersistableSecretKey) o; | ||
return id != null && Objects.equals(id, that.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
} |
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