Package com.jalios.io

Class Signature

java.lang.Object
com.jalios.io.Signature
All Implemented Interfaces:
Comparable

public class Signature extends Object implements Comparable
  • Constructor Details

    • Signature

      public Signature()
      Creates a new empty Signature
    • Signature

      public Signature(String name, String urid, String type, 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 Details

    • generate

      public static Signature generate(File dirToSign, String name, String urid, String type, 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(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(File file, boolean readMap)
    • write

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

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

      public static 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 TreeSet<SignatureDiffEntry> diff(File baseFile, 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 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 TreeSet<SignatureDiff3Entry> diff3(File baseFile, File sourceFile, 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(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(Map<String,String> map, 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(Map<String,String> map, File file, int prefixLength, 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(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 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(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 String signFile(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 String signFile(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 String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(Object obj)
      Specified by:
      compareTo in interface Comparable
    • getName

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

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

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

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

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

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

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

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

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

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

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

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