Class ProtectedContentUtil


  • @Service
    public class ProtectedContentUtil
    extends Object
    • Field Detail

      • MAX_INSTANT

        public static final Instant MAX_INSTANT
    • Constructor Detail

      • ProtectedContentUtil

        public ProtectedContentUtil​(@Value("${protectionSecret:S3cr3t}")
                                    String protectionSecret)
    • Method Detail

      • protectString

        public String protectString​(String content)
      • unprotectString

        public String unprotectString​(String protectedContent)
      • 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 protected
        pct - the content type of the plainText
        crt - the related entity
        connectionId - 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 protected
        pct - the content type of the plainText
        crt - the related entity
        connectionId - the related entity
        leftUsages - number of left usages for this element
        validTo - element usable until 'validTo'
        Returns:
        the freshly created object