Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently JavaThemis deals only with asymmetric keys and thus has an
AsymmetricKey
class providing common implementation of storage and utilities for PrivateKey and PublicKey classes. However, we are going to introduce a new type of keys —SymmetricKey
— which will need theseutilities as well. Since it's not an AsymmetricKey, let's refactor our class hierarchy a bit.
Extract declaration of the
toByteArray()
utility method into a new interfaceIKey
. This interface will be implemented by all key classes of Themis and will provide common utilities. (E.g., base64 formatting may be added here in the future.)Extract storage implementation into a new
KeyBytes
class. It is an abstract package-private class, intended to be a base class for all keys implemented by Themis. It provideskey
field to access key bytes directly and implements IKey interface. It also maintains the invariant that all valid keys must be non-null and not empty.AsymmetricKey is left as a marker abstract class. It inherits storage and IKey implementation from KeyBytes. Plus, it still hosts the constants for asymmetric key types.
Checklist
Benchmark results are attached(not applicable)Example projects and code samples are updated(not significant)