Package com.mku.win.salmon.sequencer
Class WinFileSequencer
- java.lang.Object
-
- com.mku.salmonfs.sequence.FileSequencer
-
- com.mku.win.salmon.sequencer.WinFileSequencer
-
- All Implemented Interfaces:
INonceSequencer
public class WinFileSequencer extends FileSequencer
File Sequencer for Windows with tamper protection.
-
-
Constructor Summary
Constructors Constructor Description WinFileSequencer(IFile sequenceFile, INonceSequenceSerializer serializer, java.lang.String regCheckSumKey)
Instantiate a windows file sequencer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getCheckSumKey()
Get the registry key to save the checksum.protected java.lang.String
getContents()
Gets the checksum the registry and verifies the contents.void
reset(boolean clearChecksumOnly)
Reset the sequences.protected void
saveContents(java.lang.String contents)
Save contents to the file and checksum to registry.void
setCheckSumKey(java.lang.String key)
Set the registry key to save the checksum.-
Methods inherited from class com.mku.salmonfs.sequence.FileSequencer
close, createSequence, getSequence, getSequenceFile, initializeSequence, nextNonce, revokeSequence, saveSequenceFile, setMaxNonce
-
-
-
-
Constructor Detail
-
WinFileSequencer
public WinFileSequencer(IFile sequenceFile, INonceSequenceSerializer serializer, java.lang.String regCheckSumKey) throws java.io.IOException
Instantiate a windows file sequencer.- Parameters:
sequenceFile
- The sequence fileserializer
- The serializerregCheckSumKey
- The registry key to use for the checksum.- Throws:
SequenceException
- Thrown if there is an error with the nonce sequencejava.io.IOException
- Thrown if there is an IO error.
-
-
Method Detail
-
getCheckSumKey
public java.lang.String getCheckSumKey()
Get the registry key to save the checksum.- Returns:
- The key
-
setCheckSumKey
public void setCheckSumKey(java.lang.String key)
Set the registry key to save the checksum.- Parameters:
key
- The key
-
getContents
protected java.lang.String getContents()
Gets the checksum the registry and verifies the contents.- Overrides:
getContents
in classFileSequencer
- Returns:
- The contents
- Throws:
SequenceException
- Thrown if there is an error with the nonce sequence
-
saveContents
protected void saveContents(java.lang.String contents)
Save contents to the file and checksum to registry. The checksum is using SHA256 but to further protected from rainbow attacks we also encrypt it with the User windows credentials using ProtectedData. from rainbow attacks- Overrides:
saveContents
in classFileSequencer
- Parameters:
contents
- The contents- Throws:
SequenceException
- Thrown if there is an error with the nonce sequence
-
reset
public void reset(boolean clearChecksumOnly)
Reset the sequences. The device will be de-authorized for all drives.- Parameters:
clearChecksumOnly
- True to only clear the registry checksum, use only if you know what you're doing. Default value is false)
-
-