Package com.mku.salmonfs.auth
Class AuthConfig
- java.lang.Object
-
- com.mku.salmonfs.auth.AuthConfig
-
public class AuthConfig extends java.lang.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
exportAuthFile(AesDrive drive, java.lang.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 drivebyte[]
getAuthId()
Get the authorization ID for the target device.byte[]
getDriveId()
Get the drive ID to grant authorization for.byte[]
getMaxNonce()
Get the nonce maximum value the target device will use.byte[]
getStartNonce()
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.
-
-
-
Constructor Detail
-
AuthConfig
public AuthConfig(byte[] contents) throws java.io.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:
java.io.IOException
- Thrown if there is an IO error.
-
-
Method Detail
-
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 java.lang.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 filedrive
- 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:
java.lang.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 java.lang.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:
java.lang.Exception
- Thrown if error occurs during writing
-
getAuthConfig
public static AuthConfig getAuthConfig(AesDrive drive, IFile authFile) throws java.lang.Exception
Get the app drive pair configuration properties for this drive- Parameters:
drive
- The driveauthFile
- The encrypted authorization file.- Returns:
- The decrypted authorization file.
- Throws:
java.lang.Exception
- Thrown if error occurs during reading
-
importAuthFile
public static void importAuthFile(AesDrive drive, IFile authConfigFile) throws java.lang.Exception
Import the device authorization file.- Parameters:
drive
- The driveauthConfigFile
- The filepath to the authorization file.- Throws:
java.lang.Exception
- Thrown if error occurs during import
-
exportAuthFile
public static void exportAuthFile(AesDrive drive, java.lang.String targetAuthId, IFile file) throws java.lang.Exception
Export an authorization file for a drive and a specific device auth id.- Parameters:
drive
- The drivetargetAuthId
- The authorization id of the target device.file
- The config file.- Throws:
java.lang.Exception
- Thrown if error occurs during export
-
-