Class AuthConfig

java.lang.Object
com.mku.salmonfs.auth.AuthConfig

public class AuthConfig 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 Summary

    Constructors
    Constructor
    Description
    AuthConfig(byte[] contents)
    Instantiate a class with the properties of the authorization config file.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    exportAuthFile(AesDrive drive, String targetAuthId, IFile file)
    Export an authorization file for a drive and a specific device auth id.
    static AuthConfig
    getAuthConfig(AesDrive drive, IFile authFile)
    Get the app drive pair configuration properties for this drive
    byte[]
    Get the authorization ID for the target device.
    byte[]
    Get the drive ID to grant authorization for.
    byte[]
    Get the nonce maximum value the target device will use.
    byte[]
    Get the nonce starting value the target device will use.
    static void
    importAuthFile(AesDrive drive, IFile authConfigFile)
    Import the device authorization file.
    static void
    writeAuthFile(IFile authConfigFile, AesDrive drive, byte[] targetAuthId, byte[] targetStartingNonce, byte[] targetMaxNonce, byte[] configNonce)
    Write the properties of the auth configuration to a config file that will be imported by another device.
    static void
    writeToStream(RandomAccessStream stream, byte[] driveId, byte[] authId, byte[] nextNonce, byte[] maxNonce)
    Write authorization configuration to an AesStream.

    Methods inherited from class java.lang.Object

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

    • AuthConfig

      public AuthConfig(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(IFile authConfigFile, AesDrive 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 an AesStream.
      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 AuthConfig getAuthConfig(AesDrive drive, IFile 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(AesDrive drive, IFile 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(AesDrive drive, String targetAuthId, IFile 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