Class SalmonAuthConfig

java.lang.Object
com.mku.salmon.SalmonAuthConfig

public class SalmonAuthConfig extends Object
Device Authorization Configuration. This represents the authorization that will be provided to the target device to allow writing operations for a virtual drive.
  • Constructor Details

    • SalmonAuthConfig

      public SalmonAuthConfig(byte[] contents) throws IOException
      Instantiate a class with the properties of the authorization config file.
      Parameters:
      contents - The byte array that contains the contents of the auth config file.
      Throws:
      IOException - Thrown if there is an IO error.
  • Method Details

    • getDriveId

      public byte[] getDriveId()
      Get the drive ID to grant authorization for.
      Returns:
      The drive ID
    • getAuthId

      public byte[] getAuthId()
      Get the authorization ID for the target device.
      Returns:
      The authorization Id
    • getStartNonce

      public byte[] getStartNonce()
      Get the nonce starting value the target device will use.
      Returns:
      The starting nonce
    • getMaxNonce

      public byte[] getMaxNonce()
      Get the nonce maximum value the target device will use.
      Returns:
      The maximum nonce
    • writeAuthFile

      public static void writeAuthFile(IRealFile authConfigFile, SalmonDrive drive, byte[] targetAuthId, byte[] targetStartingNonce, byte[] targetMaxNonce, byte[] configNonce) throws Exception
      Write the properties of the auth configuration to a config file that will be imported by another device. The new device will then be authorized editing operations ie: import, rename files, etc.
      Parameters:
      authConfigFile - The authorization configuration file
      drive - The drive you want to create an auth config for.
      targetAuthId - Authorization ID of the target device.
      targetStartingNonce - Starting nonce for the target device.
      targetMaxNonce - Maximum nonce for the target device.
      configNonce - Nonce for the file itself
      Throws:
      Exception - Thrown if error occurs during writing the file
    • writeToStream

      public static void writeToStream(RandomAccessStream stream, byte[] driveId, byte[] authId, byte[] nextNonce, byte[] maxNonce) throws Exception
      Write authorization configuration to a SalmonStream.
      Parameters:
      stream - The stream to write to.
      driveId - The drive id.
      authId - The auth id of the new device.
      nextNonce - The next nonce to be used by the new device.
      maxNonce - The max nonce to be used byte the new device.
      Throws:
      Exception - Thrown if error occurs during writing
    • getAuthConfig

      public static SalmonAuthConfig getAuthConfig(SalmonDrive drive, IRealFile authFile) throws Exception
      Get the app drive pair configuration properties for this drive
      Parameters:
      drive - The drive
      authFile - The encrypted authorization file.
      Returns:
      The decrypted authorization file.
      Throws:
      Exception - Thrown if error occurs during reading
    • importAuthFile

      public static void importAuthFile(SalmonDrive drive, IRealFile authConfigFile) throws Exception
      Import the device authorization file.
      Parameters:
      drive - The drive
      authConfigFile - The filepath to the authorization file.
      Throws:
      Exception - Thrown if error occurs during import
    • exportAuthFile

      public static void exportAuthFile(SalmonDrive drive, String targetAuthId, IRealFile file) throws Exception
      Export an authorization file for a drive and a specific device auth id.
      Parameters:
      drive - The drive
      targetAuthId - The authorization id of the target device.
      file - The config file.
      Throws:
      Exception - Thrown if error occurs during export