Class RdeUploadAction

  • All Implemented Interfaces:
    google.registry.rde.EscrowTaskRunner.EscrowTask, java.lang.Runnable

    public final class RdeUploadAction
    extends java.lang.Object
    implements java.lang.Runnable, google.registry.rde.EscrowTaskRunner.EscrowTask
    Action that securely uploads an RDE XML file from Cloud Storage to a trusted third party (such as Iron Mountain) via SFTP.

    This action is invoked by RdeStagingAction once it's created the files we need. The date is calculated from Cursor.CursorType.RDE_UPLOAD.

    Once this action completes, it rolls the cursor forward a day and triggers RdeReportAction.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PATH  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void run()  
      void runWithLock​(org.joda.time.DateTime watermark)
      Performs task logic while the lock is held.
      protected void upload​(com.google.cloud.storage.BlobId xmlFile, long xmlLength, org.joda.time.DateTime watermark, java.lang.String name, java.lang.String nameWithoutPrefix)
      Performs a blocking upload of a cloud storage XML file to escrow provider, converting it to the RyDE format along the way by applying tar+compress+encrypt+sign, and saving the created RyDE file on GCS for future reference.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • runWithLock

        public void runWithLock​(org.joda.time.DateTime watermark)
                         throws java.lang.Exception
        Description copied from interface: google.registry.rde.EscrowTaskRunner.EscrowTask
        Performs task logic while the lock is held.
        Specified by:
        runWithLock in interface google.registry.rde.EscrowTaskRunner.EscrowTask
        Parameters:
        watermark - the logical time for a point-in-time view of Datastore
        Throws:
        java.lang.Exception
      • upload

        protected void upload​(com.google.cloud.storage.BlobId xmlFile,
                              long xmlLength,
                              org.joda.time.DateTime watermark,
                              java.lang.String name,
                              java.lang.String nameWithoutPrefix)
                       throws java.lang.Exception
        Performs a blocking upload of a cloud storage XML file to escrow provider, converting it to the RyDE format along the way by applying tar+compress+encrypt+sign, and saving the created RyDE file on GCS for future reference.

        This is done by layering a bunch of FilterOutputStreams on top of each other in reverse order that turn XML bytes into a RyDE file while simultaneously uploading it to the SFTP endpoint, and then using ByteStreams.copy(java.io.InputStream, java.io.OutputStream) to blocking-copy bytes from the cloud storage InputStream to the RyDE/SFTP pipeline.

        In pseudo-shell, the whole process looks like the following:

        
         gcs read $xmlFile \                                   # Get GhostRyDE from cloud storage.
           | decrypt | decompress \                            # Convert it to XML.
           | tar | file | compress | encrypt | sign /tmp/sig \ # Convert it to a RyDE file.
           | tee gs://bucket/$rydeFilename.ryde \              # Save a copy of the RyDE file to GCS.
           | sftp put $dstUrl/$rydeFilename.ryde \             # Upload to SFTP server.
          && sftp put $dstUrl/$rydeFilename.sig </tmp/sig \    # Upload detached signature.
          && cat /tmp/sig > gs://bucket/$rydeFilename.sig      # Save a copy of signature to GCS.
        
         
        Throws:
        java.lang.Exception