Class C2Helper


  • public class C2Helper
    extends Object
    The C2Helper provides means to manage launching and connecting to a C2 server.
    • Constructor Detail

      • C2Helper

        public C2Helper​(String aInstanceAlias,
                        Class<?> aResourceLocator,
                        boolean isVerbose,
                        boolean isForce,
                        org.refcodes.logger.RuntimeLogger aLogger)
                 throws IOException
        Instantiates a new C2 helper.
        Parameters:
        aInstanceAlias - The alias identifying the invoking application's instance.
        aResourceLocator - The application's Class which to use when loading resources (of the according module) by invoking Class.getResourceAsStream(String).
        isVerbose - True to be more verbose.
        aLogger - The application's logger.
        Throws:
        IOException - thrown in I/O problems occurred building the C2Helper.
    • Method Detail

      • getLockFileName

        public String getLockFileName()
      • deleteLockFile

        public void deleteLockFile​(boolean isVerbose)
                            throws IOException
        Manually deletes the lockfile in case an orphaned lockfile is in the way.
        Parameters:
        isVerbose - Be more verbose.
        Throws:
        IOException - in case there were I/O problems reading the lock file.
      • readLockFile

        public org.refcodes.properties.Properties readLockFile​(boolean isVerbose)
                                                        throws IOException,
                                                               ParseException
        Reads the lockfile and returns its content as a Properties instance. The properties in the lockfiles are expected to be in TOML notation (as of TomlProperties).
        Parameters:
        isVerbose - Be more verbose.
        Returns:
        The lockfile's Properties.
        Throws:
        IOException - in case there were I/O problems reading the lock file.
        ParseException - thrown in case parsing the lockfile's properties failed.
      • writeLockFile

        public void writeLockFile​(org.refcodes.properties.Properties aProperties,
                                  boolean isVerbose)
                           throws IOException
        Writes the lockfile with the content of the provided Properties instance. The properties in the lockfiles are being written in TOML notation (as of TomlProperties).
        Parameters:
        isVerbose - Be more verbose.
        aProperties - The lockfile's Properties.
        Throws:
        IOException - in case there were I/O problems reading the file.
      • getInstanceAlias

        public String getInstanceAlias()
        Returns the instance alias assigned to this C2Helper instance.
        Returns:
        the according instance alias.