Package com.iizix.server.security
Class ServerSecurityManager
java.lang.Object
com.iizix.server.security.ServerSecurityManager
- All Implemented Interfaces:
- ISensitiveParameterHandler
The security manager keeps keys and other security information for the server.
- Author:
- Christopher Mindus
- Field SummaryFieldsModifier and TypeFieldDescription- static final StringThe default server keys file name: "iiziServer.keys".
- Method SummaryModifier and TypeMethodDescription- decodeParameter- (String data) Decodes a sensitive information device parameter using the previously exchanged keys.- static byte[]- digest- (byte[] data) Digests the bytes using preferably SHA-512, SHA-384, SHA-256, then SHA-1 and worst case MD5.- void- dispose()Disposes of the instance.- encodeParameter- (String data) Encodes a sensitive information device parameter using the previously exchanged keys.- static ServerSecurityManagerGets the instance of the security manager.Gets the key to use for encryption.- voidLoads the server keys from the specified file.- void- setKeyTimeout- (long timeout) Assigns the timeout in milliseconds a key is valid.
- Field Details- DEFAULT_SERVER_KEYS_FILENAMEThe default server keys file name: "iiziServer.keys".- See Also:
 
 
- Method Details- getInstanceGets the instance of the security manager.- Returns:
- The security manager.
 
- digestpublic static byte[] digest- (byte[] data) Digests the bytes using preferably SHA-512, SHA-384, SHA-256, then SHA-1 and worst case MD5.- Parameters:
- data- The data to digest.
- Returns:
- The digested data.
 
- setKeyTimeoutpublic void setKeyTimeout- (long timeout) Assigns the timeout in milliseconds a key is valid.- Parameters:
- timeout- The timeout for a key in milliseconds, default is 90 days.
- Throws:
- IllegalArgumentException- If the timeout is less than 1 hour (3_600_000 ms).
 
- loadKeysLoads the server keys from the specified file.- Parameters:
- file- The file.
- Throws:
- IOException- For I/O errors.
- PropException- For property exceptions.
 
- getServerKeyGets the key to use for encryption. The last server key is used when possible, otherwise a new key is generated. Upon generation, the keys are saved in the server and other clustered server are informed (asynchronously).- Returns:
- The key.
 
- disposepublic void dispose()Disposes of the instance.
- decodeParameterpublic String decodeParameter- (String data) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException, DigestException Decodes a sensitive information device parameter using the previously exchanged keys.- Specified by:
- decodeParameterin interface- ISensitiveParameterHandler
- Parameters:
- data- The base64 encoded data.
- Returns:
- The decoded string.
- Throws:
- IllegalArgumentException- If the data encoding is invalid (not base64).
- NoSuchPaddingException
- NoSuchAlgorithmException
- InvalidAlgorithmParameterException
- InvalidKeyException
- BadPaddingException
- IllegalBlockSizeException
- DigestException
 
- encodeParameterpublic String encodeParameter- (String data) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException Encodes a sensitive information device parameter using the previously exchanged keys.- Specified by:
- encodeParameterin interface- ISensitiveParameterHandler
- Parameters:
- data- The parameter to encode.
- Returns:
- The base64 encoded data.
- Throws:
- IllegalArgumentException- If the data encoding is invalid (not base64).
- NoSuchPaddingException
- NoSuchAlgorithmException
- InvalidAlgorithmParameterException
- InvalidKeyException
- BadPaddingException
- IllegalBlockSizeException
- UnsupportedEncodingException