Module org.refcodes.forwardsecrecy
Package org.refcodes.forwardsecrecy
Class AbstractDecryptionService
java.lang.Object
org.refcodes.forwardsecrecy.AbstractDecryptionService
- All Implemented Interfaces:
DecryptionService
- Direct Known Subclasses:
LoopbackDecryptionService
,PublicKeyDecryptionService
Abstract base implementation for non abstract
DecryptionService
implementations.-
Field Summary
Modifier and TypeFieldDescriptionprotected static long
protected static long
-
Constructor Summary
ConstructorDescriptionAbstractDecryptionService
(String aNamespace, DecryptionServer aDecryptionServer, long aCipherVersionsExpireTimeMillis) Constructs the service with the required services and configuration. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract String
Creates a message for which a signature is to be created in order to authenticate for the retrieval of the cipher versions.Returns the currently available cipher versions.long
Returns the the expire time (in milliseconds) after which once loaded cipher versions expire.void
setCipherVersionsExpireTimeMillis
(long aCipherVersionsExpireTimeMillis) Injection method for setting the the expire time (in milliseconds) after which once loaded cipher versions expire.protected abstract <CV extends CipherVersion>
CVtoDecryptedCipherVersion
(CV aEncyrptedCipherVersion) Hook factory method to be implemented by subclasses.protected abstract String
toSignature
(String aMessage) Creates a signature for the given message.withCipherVersionsExpireTimeMillis
(long aCipherVersionsExpireTimeMillis) Builder method for thesetCipherVersionsExpireTimeMillis(long)
method.
-
Field Details
-
EXPIRE_TIME_NEVER
protected static long EXPIRE_TIME_NEVER -
EXPIRE_TIME_IMMEDIATELY
protected static long EXPIRE_TIME_IMMEDIATELY
-
-
Constructor Details
-
AbstractDecryptionService
public AbstractDecryptionService(String aNamespace, DecryptionServer aDecryptionServer, long aCipherVersionsExpireTimeMillis) Constructs the service with the required services and configuration. The cipher versions expire time is set to 0 (expire immediately). SeesetCipherVersionsExpireTimeMillis(long)
.- Parameters:
aNamespace
- The name space to which service belongsaDecryptionServer
- The server to which the service is being "connected"aCipherVersionsExpireTimeMillis
- The time in milliseconds after which them loaded cipher versions expire and are reloaded. A value of 0 indicates that them cipher versions expire immediately (default). A value of -1 indicate that them cipher versions expire never.
-
-
Method Details
-
getCipherVersions
Returns the currently available cipher versions.- Specified by:
getCipherVersions
in interfaceDecryptionService
- Returns:
- A list with the currently known cipher versions.
-
getCipherVersionsExpireTimeMillis
public long getCipherVersionsExpireTimeMillis()Returns the the expire time (in milliseconds) after which once loaded cipher versions expire. A value of 0 indicates that them cipher versions are always reloaded upon accessing the cipher versions (default). A value of -1 indicates that the cipher versions are just loaded once and then never reloaded (them never expire).- Returns:
- The time in milliseconds after which them loaded cipher versions expire and are reloaded. A value of 0 indicates that them cipher versions expire immediately (default). A value of -1 indicate that them cipher versions expire never.
-
setCipherVersionsExpireTimeMillis
public void setCipherVersionsExpireTimeMillis(long aCipherVersionsExpireTimeMillis) Injection method for setting the the expire time (in milliseconds) after which once loaded cipher versions expire. A value of 0 indicates that them cipher versions are always reloaded upon accessing the cipher versions (default). A value of -1 indicates that the cipher versions are just loaded once and then never reloaded (them never expire).- Parameters:
aCipherVersionsExpireTimeMillis
- The time in milliseconds after which them loaded cipher versions expire and are reloaded. A value of 0 indicates that them cipher versions expire immediately (default). A value of -1 indicate that them cipher versions expire never.
-
withCipherVersionsExpireTimeMillis
Builder method for thesetCipherVersionsExpireTimeMillis(long)
method.- Parameters:
aCipherVersionsExpireTimeMillis
- The time in milliseconds after which them loaded cipher versions expire and are reloaded (default). A value of 0 indicates that them cipher versions expire immediately. A value of -1 indicate that them cipher versions expire never.- Returns:
- This instance as of the builder pattern.
-
toSignature
Creates a signature for the given message.- Parameters:
aMessage
- The message for which a signature is to be generated- Returns:
- The signature for the message
-
createMessage
Creates a message for which a signature is to be created in order to authenticate for the retrieval of the cipher versions. A decryption server should deny any requests to get cipher versions in case the same message is used twice.- Returns:
- The message
-
toDecryptedCipherVersion
protected abstract <CV extends CipherVersion> CV toDecryptedCipherVersion(CV aEncyrptedCipherVersion) Hook factory method to be implemented by subclasses. The provided cipher is to be decrypted (e.g. with the private key of an asymmetric encryption approach) so that an decryption server only receives encrypted data.- Type Parameters:
CV
- The type of theCipherVersion
to be used.- Parameters:
aEncyrptedCipherVersion
- TheCipherVersion
to be decrypted.- Returns:
- The decrypted
CipherVersion
.
-