Package com.jalios.io

Class Signature

  • All Implemented Interfaces:
    java.lang.Comparable

    public class Signature
    extends java.lang.Object
    implements java.lang.Comparable
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String REVISION  
    • Constructor Summary

      Constructors 
      Constructor Description
      Signature()
      Creates a new empty Signature
      Signature​(Signature signature)
      Creates a new Signature
      Signature​(java.lang.String name, java.lang.String urid, java.lang.String type, java.util.Date date)
      Creates a new Signature
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(Signature signature)
      Put all the map entry of a given signature to this signature
      int compareTo​(java.lang.Object obj)  
      static java.util.TreeSet<SignatureDiffEntry> diff​(Signature base, Signature source)
      Perform a diff between 2 signatures
      static java.util.TreeSet<SignatureDiffEntry> diff​(java.io.File baseFile, java.io.File sourceFile)
      Perform a diff between 2 signatures files
      static java.util.TreeSet<SignatureDiff3Entry> diff3​(Signature base, Signature source, Signature target)
      Perform a diff3 between 3 signatures
      static java.util.TreeSet<SignatureDiff3Entry> diff3​(java.io.File baseFile, java.io.File sourceFile, java.io.File targetFile)
      Perform a diff between 3 signatures files
      static boolean diff3SetIsConflict​(java.util.Set<SignatureDiff3Entry> diff3Set)
      Tests whether the given diff3Set contains at least one conflict.
      static Signature generate​(java.io.File dirToSign, java.lang.String name, java.lang.String urid, java.lang.String type, java.lang.String regexp)
      Generates a new Signature from a given directory
      java.util.Date getDate()
      Get the value of date.
      java.io.File getFile()
      Get the value of file.
      static java.lang.String getLineDelimiterIgnoredFileExtensions()
      Retrieve the file extensions used to know which files must have their line delimiters ignored during signing.
      java.util.TreeMap<java.lang.String,​java.lang.String> getMap()
      Get the value of map.
      java.lang.String getName()
      Get the value of name.
      java.lang.String getType()
      Get the value of type.
      java.lang.String getUrid()
      Get the value of urid.
      static boolean ignoreLineDelimiter​(java.io.File file)
      Check if line delimiter of specified file should be ignored during creation of its signature.
      boolean isTypeBase()  
      boolean isTypeSource()  
      boolean isTypeTarget()  
      static Signature read​(java.io.File file)
      Read a signature file and return a map
      static Signature read​(java.io.File file, boolean readMap)  
      void setDate​(java.util.Date v)
      Set the value of date.
      void setFile​(java.io.File v)
      Set the value of file.
      static void setLineDelimiterIgnoredFileExtensions​(java.lang.String extensions)
      Change the current file extensions used to know which files must have their line delimiters ignored during signing.
      void setMap​(java.util.TreeMap<java.lang.String,​java.lang.String> v)
      Set the value of map.
      void setName​(java.lang.String v)
      Set the value of name.
      void setType​(java.lang.String v)
      Set the value of type.
      void setUrid​(java.lang.String v)
      Set the value of urid.
      static java.lang.String signFile​(java.io.File file)
      Sign a File and return the signature.
      Line delimiter the specified file will be ignored depending on the value returned by ignoreLineDelimiter(File).
      static java.lang.String signFile​(java.io.File file, boolean ignoreLineDelimiter)
      Sign a File and return the signature.
      static void signFiles​(java.util.Map<java.lang.String,​java.lang.String> map, java.io.File file, int prefixLength)
      Fill a Map with key = the relative file and Value, the signed value
      static void signFiles​(java.util.Map<java.lang.String,​java.lang.String> map, java.io.File file, int prefixLength, java.lang.String regexp)
      Fill a Map with key = the relative file and Value, the signed value
      java.lang.String toString()  
      void write​(java.io.File file)
      Write the signature map into a file
      void write​(java.io.OutputStream out)
      Write the signature map into a stream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Signature

        public Signature()
        Creates a new empty Signature
      • Signature

        public Signature​(java.lang.String name,
                         java.lang.String urid,
                         java.lang.String type,
                         java.util.Date date)
        Creates a new Signature
        Parameters:
        name - the name of the webapp
        urid - the urid of the webapp
        type - the type of signature
        date - the date of signature
      • Signature

        public Signature​(Signature signature)
        Creates a new Signature
        Parameters:
        signature - the signature to clone
    • Method Detail

      • generate

        public static Signature generate​(java.io.File dirToSign,
                                         java.lang.String name,
                                         java.lang.String urid,
                                         java.lang.String type,
                                         java.lang.String regexp)
                                  throws org.apache.oro.text.regex.MalformedPatternException
        Generates a new Signature from a given directory
        Parameters:
        dirToSign - the directory to sign
        name - the name of the webapp
        urid - the urid of the webapp
        type - the type of signature
        regexp - files matching this Perl5 regexp will be excluded
        Returns:
        the Signature of the specified directory
        Throws:
        org.apache.oro.text.regex.MalformedPatternException - if the specified regexp could not be compiled
      • read

        public static Signature read​(java.io.File file)
        Read a signature file and return a map
        Parameters:
        file - the file where to read signature
        Returns:
        a map(file,signature)
        Since:
        jcms-4.0.2
      • read

        public static Signature read​(java.io.File file,
                                     boolean readMap)
      • write

        public void write​(java.io.File file)
                   throws java.io.IOException
        Write the signature map into a file
        Parameters:
        file - the file where to write signature
        Throws:
        java.io.IOException - if an output stream to the specified file could not be created
        Since:
        jcms-4.0.2
      • write

        public void write​(java.io.OutputStream out)
        Write the signature map into a stream
        Parameters:
        out - the OutputStream
        Since:
        jcms-4.0.2
      • diff

        public static java.util.TreeSet<SignatureDiffEntry> diff​(Signature base,
                                                                 Signature source)
        Perform a diff between 2 signatures
        Parameters:
        base - the base (i.e. common) signatures
        source - the signature to get the file from
        Returns:
        TreeSet of SignatureDiffEntry
        Since:
        jcms-4.0.2
      • diff

        public static java.util.TreeSet<SignatureDiffEntry> diff​(java.io.File baseFile,
                                                                 java.io.File sourceFile)
        Perform a diff between 2 signatures files
        Parameters:
        baseFile - the file for the base (i.e. common) signatures
        sourceFile - the file for the signature to get the file from
        Returns:
        TreeSet of SignatureDiffEntry
        Since:
        jcms-4.0.2
      • diff3

        public static java.util.TreeSet<SignatureDiff3Entry> diff3​(Signature base,
                                                                   Signature source,
                                                                   Signature target)
        Perform a diff3 between 3 signatures
        Parameters:
        base - the base (i.e. common) signatures
        source - the signature to get the file from
        target - the signature to merge with
        Returns:
        TreeSet of SignatureDiff3Entry
        Since:
        jcms-4.0.2
      • diff3

        public static java.util.TreeSet<SignatureDiff3Entry> diff3​(java.io.File baseFile,
                                                                   java.io.File sourceFile,
                                                                   java.io.File targetFile)
        Perform a diff between 3 signatures files
        Parameters:
        baseFile - the file for the base (i.e. common) signatures
        sourceFile - the file for the signature to get the file from
        targetFile - the file for the signature to merge with
        Returns:
        TreeSet of SignatureDiff3Entry
        Since:
        jcms-4.0.2
      • diff3SetIsConflict

        public static boolean diff3SetIsConflict​(java.util.Set<SignatureDiff3Entry> diff3Set)
        Tests whether the given diff3Set contains at least one conflict. I.E. diffEntry.isConflict().
        Parameters:
        diff3Set - the diff3Set to test
        Returns:
        true if there is at least one conflict.
        Since:
        jcms-4.0.2
      • signFiles

        public static void signFiles​(java.util.Map<java.lang.String,​java.lang.String> map,
                                     java.io.File file,
                                     int prefixLength)
        Fill a Map with key = the relative file and Value, the signed value
        Parameters:
        map - where to put all the File / Signature
        file - the first file to introspect
        prefixLength - the length of the prefix to remove
      • signFiles

        public static void signFiles​(java.util.Map<java.lang.String,​java.lang.String> map,
                                     java.io.File file,
                                     int prefixLength,
                                     java.lang.String regexp)
                              throws org.apache.oro.text.regex.MalformedPatternException
        Fill a Map with key = the relative file and Value, the signed value
        Parameters:
        map - where to put all the File / Signature
        file - the first file to introspect
        prefixLength - the length of the prefix to remove
        regexp - files matching this Perl5 regexp will be excluded
        Throws:
        org.apache.oro.text.regex.MalformedPatternException - if the specified regexp could not be compiled
      • setLineDelimiterIgnoredFileExtensions

        public static void setLineDelimiterIgnoredFileExtensions​(java.lang.String extensions)
        Change the current file extensions used to know which files must have their line delimiters ignored during signing.
        Parameters:
        extensions - a space/coma seperated string of extension, e.g "jsp xml txt html"
      • getLineDelimiterIgnoredFileExtensions

        public static java.lang.String getLineDelimiterIgnoredFileExtensions()
        Retrieve the file extensions used to know which files must have their line delimiters ignored during signing.
        Returns:
        extensions space seperated string of extension, e.g "jsp xml txt html"
      • ignoreLineDelimiter

        public static boolean ignoreLineDelimiter​(java.io.File file)
        Check if line delimiter of specified file should be ignored during creation of its signature.
        Parameters:
        file - the file to sign
        Returns:
        true if line delimiter must be ignored, false otherwise.
      • signFile

        public static java.lang.String signFile​(java.io.File file)
        Sign a File and return the signature.
        Line delimiter the specified file will be ignored depending on the value returned by ignoreLineDelimiter(File).
        Parameters:
        file - the file to sign
        Returns:
        the signature of the file
      • signFile

        public static java.lang.String signFile​(java.io.File file,
                                                boolean ignoreLineDelimiter)
        Sign a File and return the signature.
        Parameters:
        file - the file to sign
        ignoreLineDelimiter - true to ignore line delimiter during signature, false to sign file as is. Signing is a bit longer when ignoring line delimiter.
        Returns:
        the signature of the file
      • add

        public void add​(Signature signature)
        Put all the map entry of a given signature to this signature
        Parameters:
        signature - the signature
        Since:
        jcms-4.0.2
      • isTypeBase

        public boolean isTypeBase()
      • isTypeSource

        public boolean isTypeSource()
      • isTypeTarget

        public boolean isTypeTarget()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • compareTo

        public int compareTo​(java.lang.Object obj)
        Specified by:
        compareTo in interface java.lang.Comparable
      • getName

        public java.lang.String getName()
        Get the value of name.
        Returns:
        Value of name.
      • setName

        public void setName​(java.lang.String v)
        Set the value of name.
        Parameters:
        v - Value to assign to name.
      • getUrid

        public java.lang.String getUrid()
        Get the value of urid.
        Returns:
        Value of urid.
      • setUrid

        public void setUrid​(java.lang.String v)
        Set the value of urid.
        Parameters:
        v - Value to assign to urid.
      • getDate

        public java.util.Date getDate()
        Get the value of date.
        Returns:
        Value of date.
      • setDate

        public void setDate​(java.util.Date v)
        Set the value of date.
        Parameters:
        v - Value to assign to date.
      • getFile

        public java.io.File getFile()
        Get the value of file.
        Returns:
        Value of file.
      • setFile

        public void setFile​(java.io.File v)
        Set the value of file.
        Parameters:
        v - Value to assign to file.
      • getType

        public java.lang.String getType()
        Get the value of type.
        Returns:
        Value of type.
      • setType

        public void setType​(java.lang.String v)
        Set the value of type.
        Parameters:
        v - Value to assign to type.
      • getMap

        public java.util.TreeMap<java.lang.String,​java.lang.String> getMap()
        Get the value of map.
        Returns:
        Value of map.
      • setMap

        public void setMap​(java.util.TreeMap<java.lang.String,​java.lang.String> v)
        Set the value of map.
        Parameters:
        v - Value to assign to map.