Package com.mku.salmon
Class SalmonAuthConfig
java.lang.Object
com.mku.salmon.SalmonAuthConfig
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
ConstructorDescriptionSalmonAuthConfig
(byte[] contents) Instantiate a class with the properties of the authorization config file. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
exportAuthFile
(SalmonDrive drive, String targetAuthId, IRealFile file) Export an authorization file for a drive and a specific device auth id.static SalmonAuthConfig
getAuthConfig
(SalmonDrive drive, IRealFile authFile) Get the app drive pair configuration properties for this drivebyte[]
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
(SalmonDrive drive, IRealFile authConfigFile) Import the device authorization file.static void
writeAuthFile
(IRealFile authConfigFile, SalmonDrive 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 a SalmonStream.
-
Constructor Details
-
SalmonAuthConfig
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 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:
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 driveauthFile
- The encrypted authorization file.- Returns:
- The decrypted authorization file.
- Throws:
Exception
- Thrown if error occurs during reading
-
importAuthFile
Import the device authorization file.- Parameters:
drive
- The driveauthConfigFile
- 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 drivetargetAuthId
- The authorization id of the target device.file
- The config file.- Throws:
Exception
- Thrown if error occurs during export
-