Class ProtectedContentUtil
- java.lang.Object
-
- de.trustable.ca3s.core.service.util.ProtectedContentUtil
-
@Service public class ProtectedContentUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static InstantMAX_INSTANT
-
Constructor Summary
Constructors Constructor Description ProtectedContentUtil(ProtectedContentRepository protContentRepository, String protectionSecretFallback, String protectionSecret, String salt, int iterations, String pbeAlgo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProtectedContentcreateProtectedContent(String plainText, ProtectedContentType pct, ContentRelationType crt, long connectionId)create a new ProtectedContent object and save the given contentProtectedContentcreateProtectedContent(String plainText, ProtectedContentType pct, ContentRelationType crt, long connectionId, int leftUsages, Instant validTo)create a new ProtectedContent object and save the given contentbyte[]deriveSecret(char[] secret)byte[]deriveSecret(String secret)StringprotectString(String content)List<ProtectedContent>retrieveProtectedContent(ProtectedContentType type, ContentRelationType crt, long id)StringunprotectString(String protectedContent)voidupdateServersideKeyRetentionSettings(long csrId, Instant validTo, int usages)
-
-
-
Field Detail
-
MAX_INSTANT
public static final Instant MAX_INSTANT
-
-
Constructor Detail
-
ProtectedContentUtil
public ProtectedContentUtil(ProtectedContentRepository protContentRepository, @Value("${protectionSecret:mJvR25yt4NHTIqe5Hz7nUHhQNUuM}") String protectionSecretFallback, @Value("${ca3s.protectionSecret:#{null}}") String protectionSecret, @Value("${ca3s.connection.salt:ca3sSalt}") String salt, @Value("${ca3s.connection.iterations:4567}") int iterations, @Value("${ca3s.connection.pbeAlgo:PBKDF2WithHmacSHA256}") String pbeAlgo)
-
-
Method Detail
-
createProtectedContent
public ProtectedContent createProtectedContent(String plainText, ProtectedContentType pct, ContentRelationType crt, long connectionId)
create a new ProtectedContent object and save the given content- Parameters:
plainText- the plain text to be protectedpct- the content type of the plainTextcrt- the related entityconnectionId- the related entity- Returns:
- the freshly created object
-
createProtectedContent
public ProtectedContent createProtectedContent(String plainText, ProtectedContentType pct, ContentRelationType crt, long connectionId, int leftUsages, Instant validTo)
create a new ProtectedContent object and save the given content- Parameters:
plainText- the plain text to be protectedpct- the content type of the plainTextcrt- the related entityconnectionId- the related entityleftUsages- number of left usages for this elementvalidTo- element usable until 'validTo'- Returns:
- the freshly created object
-
retrieveProtectedContent
public List<ProtectedContent> retrieveProtectedContent(ProtectedContentType type, ContentRelationType crt, long id)
- Parameters:
type- the type of object which is requiredcrt- the related entityid- the object id- Returns:
- list of
-
updateServersideKeyRetentionSettings
public void updateServersideKeyRetentionSettings(long csrId, Instant validTo, int usages)
-
deriveSecret
public byte[] deriveSecret(String secret) throws NoSuchAlgorithmException, InvalidKeySpecException
-
deriveSecret
public byte[] deriveSecret(char[] secret) throws NoSuchAlgorithmException, InvalidKeySpecException
-
-