Class FileSequencer

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close this file sequencer.
      void createSequence​(java.lang.String driveId, java.lang.String authId)
      Create a sequence for the drive ID and auth ID provided.
      protected java.lang.String getContents()
      Get the contents of a sequence file.
      NonceSequence getSequence​(java.lang.String driveId)
      Get the sequence by the drive ID.
      IFile getSequenceFile()
      Get the file used by this sequencer.
      void initializeSequence​(java.lang.String driveId, java.lang.String authId, byte[] startNonce, byte[] maxNonce)
      Initialize the sequence.
      byte[] nextNonce​(java.lang.String driveId)
      Get the next nonce.
      void revokeSequence​(java.lang.String driveId)
      Revoke the current sequence for a specific drive.
      protected void saveContents​(java.lang.String contents)
      Save the contents of the file
      protected void saveSequenceFile​(java.util.HashMap<java.lang.String,​NonceSequence> sequences)
      Save the sequence file.
      void setMaxNonce​(java.lang.String driveId, java.lang.String authId, byte[] maxNonce)
      Set the maximum nonce.
      • Methods inherited from class java.lang.Object

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

      • FileSequencer

        public FileSequencer​(IFile sequenceFile,
                             INonceSequenceSerializer serializer)
                      throws java.io.IOException
        Instantiate a nonce file sequencer.
        Parameters:
        sequenceFile - The sequence file.
        serializer - The serializer to be used.
        Throws:
        java.io.IOException - Thrown if there is an IO error.
        SequenceException - Thrown if there is an error with the nonce sequence
    • Method Detail

      • getSequenceFile

        public IFile getSequenceFile()
        Get the file used by this sequencer.
        Returns:
        The file.
      • createSequence

        public void createSequence​(java.lang.String driveId,
                                   java.lang.String authId)
        Create a sequence for the drive ID and auth ID provided.
        Specified by:
        createSequence in interface INonceSequencer
        Parameters:
        driveId - The drive ID.
        authId - The authorization ID of the drive.
        Throws:
        SequenceException - Thrown if there is an error with the nonce sequence
      • initializeSequence

        public void initializeSequence​(java.lang.String driveId,
                                       java.lang.String authId,
                                       byte[] startNonce,
                                       byte[] maxNonce)
                                throws java.io.IOException
        Initialize the sequence.
        Specified by:
        initializeSequence in interface INonceSequencer
        Parameters:
        driveId - The drive ID.
        authId - The auth ID of the device for the drive.
        startNonce - The starting nonce.
        maxNonce - The maximum nonce.
        Throws:
        SequenceException - Thrown if there is an error with the nonce sequence
        java.io.IOException - Thrown if there is an IO error.
      • setMaxNonce

        public void setMaxNonce​(java.lang.String driveId,
                                java.lang.String authId,
                                byte[] maxNonce)
        Set the maximum nonce.
        Specified by:
        setMaxNonce in interface INonceSequencer
        Parameters:
        driveId - The drive ID.
        authId - The auth ID of the device for the drive.
        maxNonce - The maximum nonce.
        Throws:
        SequenceException - Thrown if there is an error with the nonce sequence
      • nextNonce

        public byte[] nextNonce​(java.lang.String driveId)
        Get the next nonce.
        Specified by:
        nextNonce in interface INonceSequencer
        Parameters:
        driveId - The drive ID.
        Returns:
        The next nonce
        Throws:
        SequenceException - Thrown if there is an error with the nonce sequence
        RangeExceededException - Thrown if the nonce exceeds its range
      • getContents

        protected java.lang.String getContents()
        Get the contents of a sequence file.
        Returns:
        The contents
        Throws:
        SequenceException - Thrown if there is an error with the nonce sequence
      • revokeSequence

        public void revokeSequence​(java.lang.String driveId)
        Revoke the current sequence for a specific drive.
        Specified by:
        revokeSequence in interface INonceSequencer
        Parameters:
        driveId - The drive ID.
        Throws:
        SequenceException - Thrown if there is an error with the nonce sequence
      • getSequence

        public NonceSequence getSequence​(java.lang.String driveId)
        Get the sequence by the drive ID.
        Specified by:
        getSequence in interface INonceSequencer
        Parameters:
        driveId - The drive ID.
        Returns:
        The sequence
        Throws:
        SequenceException - Thrown if there is an error with the nonce sequence
      • close

        public void close()
        Close this file sequencer.
        Specified by:
        close in interface INonceSequencer
      • saveSequenceFile

        protected void saveSequenceFile​(java.util.HashMap<java.lang.String,​NonceSequence> sequences)
        Save the sequence file.
        Parameters:
        sequences - The sequences.
        Throws:
        SequenceException - Thrown if there is an error with the nonce sequence
      • saveContents

        protected void saveContents​(java.lang.String contents)
        Save the contents of the file
        Parameters:
        contents - The contents