Class SNPGuestWrapper


  • public class SNPGuestWrapper
    extends java.lang.Object
    Wrapper to execute the command line tool SNPGuest.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.apache.logging.log4j.Logger LOGGER  
      private java.lang.Runtime runtime  
      private static java.nio.file.Path SNPGUEST  
      private static org.apache.logging.log4j.Marker STDERR_MARKER  
      private static org.apache.logging.log4j.Marker STDOUT_MARKER  
    • Constructor Summary

      Constructors 
      Constructor Description
      SNPGuestWrapper()
      Default constructor.
      SNPGuestWrapper​(java.lang.Runtime runtimeIn)
      Constructor to specify a runtime.
    • Field Detail

      • STDOUT_MARKER

        private static final org.apache.logging.log4j.Marker STDOUT_MARKER
      • STDERR_MARKER

        private static final org.apache.logging.log4j.Marker STDERR_MARKER
      • LOGGER

        private static final org.apache.logging.log4j.Logger LOGGER
      • SNPGUEST

        private static final java.nio.file.Path SNPGUEST
      • runtime

        private final java.lang.Runtime runtime
    • Constructor Detail

      • SNPGuestWrapper

        public SNPGuestWrapper()
        Default constructor.
      • SNPGuestWrapper

        SNPGuestWrapper​(java.lang.Runtime runtimeIn)
        Constructor to specify a runtime. For unit testing.
        Parameters:
        runtimeIn - the runtime used to execute processes
    • Method Detail

      • fetchVCEK

        public ProcessOutput fetchVCEK​(EpycGeneration generation,
                                       java.nio.file.Path certsDir,
                                       java.nio.file.Path report)
                                throws java.util.concurrent.ExecutionException
        Fetch the VCEK from the KDS.
        Parameters:
        generation - Specify the processor model for the certificate chain.
        certsDir - Directory to store the certificates in
        report - Path to attestation report to use to request VCEK
        Returns:
        the exit code of the fetching process
        Throws:
        java.util.concurrent.ExecutionException - when an error happens during the process execution
      • verifyCertificates

        public ProcessOutput verifyCertificates​(java.nio.file.Path certsDir)
                                         throws java.util.concurrent.ExecutionException
        Verify the certificate chain.
        Parameters:
        certsDir - Path to directory containing certificate chain
        Returns:
        the exit code of the verification process
        Throws:
        java.util.concurrent.ExecutionException - when an error happens during the process execution
      • verifyAttestation

        public ProcessOutput verifyAttestation​(java.nio.file.Path certsDir,
                                               java.nio.file.Path report)
                                        throws java.util.concurrent.ExecutionException
        Verify the attestation report.
        Parameters:
        certsDir - Path to directory containing VCEK.
        report - Path to attestation report to use for validation.
        Returns:
        the exit code of the verification process
        Throws:
        java.util.concurrent.ExecutionException - when an error happens during the process execution
      • displayReport

        public ProcessOutput displayReport​(java.nio.file.Path report)
                                    throws java.util.concurrent.ExecutionException
        Display the attestation report.
        Parameters:
        report - Path to attestation report to use for validation.
        Returns:
        the exit code of the verification process
        Throws:
        java.util.concurrent.ExecutionException - when an error happens during the process execution
      • executeProcess

        protected ProcessOutput executeProcess​(java.lang.String... command)
                                        throws java.util.concurrent.ExecutionException
        Executes a commandline process
        Parameters:
        command - the command line to execute
        Returns:
        the exit code returned by the process
        Throws:
        java.util.concurrent.ExecutionException - when an error happens during the process execution
      • getOutput

        private static java.lang.String getOutput​(java.io.InputStream stream,
                                                  org.apache.logging.log4j.Marker logMarker)
                                           throws java.io.IOException
        Throws:
        java.io.IOException