Package org.wildfly.security.tool
Class FileSystemEncryptRealmCommand
- java.lang.Object
-
- org.wildfly.security.tool.Command
-
- org.wildfly.security.tool.FileSystemEncryptRealmCommand
-
class FileSystemEncryptRealmCommand extends Command
Elytron-Tool command to convert un-encrypted FileSystemRealms into an encrypted realm with the use of a SecretKey. Also, optionally provides a WildFly CLI script to register the FileSystemRealm and corresponding security-domain in WildFly.- Author:
- Ashpan Raskar
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classFileSystemEncryptRealmCommand.Descriptor
-
Field Summary
-
Fields inherited from class org.wildfly.security.tool.Command
GENERAL_CONFIGURATION_ERROR, INPUT_DATA_NOT_CONFIRMED, WIDTH
-
-
Constructor Summary
Constructors Constructor Description FileSystemEncryptRealmCommand()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleancheckDescriptorFields(FileSystemEncryptRealmCommand.Descriptor descriptor)private voidcopyAddResetDescriptor(FileSystemEncryptRealmCommand.Descriptor original)Copies a Descriptor into a temporary one for it can be cloned into the list of descriptorsprivate voidcreateFileSystemRealm()Handles creating the Elytron filesystem-realm from the descriptor arrayprivate voidcreateWildFlyScript()Creates the script/commands the user must run for Elytron to recognize and use the new filesystem-realmprivate voiderrorHandler(Exception e)Determines if a summary needs to be printed and prints summary after an error is thrownvoidexecute(String[] args)private voidfindMissingRequiredValuesAndSetValues(int count, FileSystemEncryptRealmCommand.Descriptor descriptor)Determines if the current descriptor block is missing any required values and then if it is, prints out a warning message and sets that required value and the optional values to nullprivate StringgetDescriptorParam(String param, FileSystemEncryptRealmCommand.Descriptor descriptor)Returns the value for a given param in a Descriptor objectvoidhelp()Displays the help for the commandprivate voidparseDescriptorFile(String file)Handles input being given as a descriptor fileprivate voidprintDescriptorBlocks(int count)Prints out information found in a descriptor file for summary modeprivate voidwarningHandler(String warning)Prints out a warning message if silentMode is not enabled and adds the warning to the summary if summaryMode is enabled-
Methods inherited from class org.wildfly.security.tool.Command
aliases, getProvidersSupplier, getStatus, getToolCommand, isAlias, isEnableDebug, isWindows, printDuplicatesWarning, printDuplicatesWarning, prompt, setEnableDebug, setStatus, setToolCommand
-
-
-
-
Field Detail
-
GENERAL_CONFIGURATION_WARNING
static final int GENERAL_CONFIGURATION_WARNING
- See Also:
- Constant Field Values
-
FILE_SYSTEM_ENCRYPT_COMMAND
static final String FILE_SYSTEM_ENCRYPT_COMMAND
- See Also:
- Constant Field Values
-
SUMMARY_WIDTH
static final int SUMMARY_WIDTH
- See Also:
- Constant Field Values
-
HELP_PARAM
private static final String HELP_PARAM
- See Also:
- Constant Field Values
-
DEBUG_PARAM
private static final String DEBUG_PARAM
- See Also:
- Constant Field Values
-
SILENT_PARAM
private static final String SILENT_PARAM
- See Also:
- Constant Field Values
-
SUMMARY_PARAM
private static final String SUMMARY_PARAM
- See Also:
- Constant Field Values
-
INPUT_REALM_LOCATION_PARAM
private static final String INPUT_REALM_LOCATION_PARAM
- See Also:
- Constant Field Values
-
REALM_NAME_PARAM
private static final String REALM_NAME_PARAM
- See Also:
- Constant Field Values
-
OUTPUT_REALM_LOCATION_PARAM
private static final String OUTPUT_REALM_LOCATION_PARAM
- See Also:
- Constant Field Values
-
CREDENTIAL_STORE_LOCATION_PARAM
private static final String CREDENTIAL_STORE_LOCATION_PARAM
- See Also:
- Constant Field Values
-
CREATE_CREDENTIAL_STORE_PARAM
private static final String CREATE_CREDENTIAL_STORE_PARAM
- See Also:
- Constant Field Values
-
SECRET_KEY_ALIAS_PARAM
private static final String SECRET_KEY_ALIAS_PARAM
- See Also:
- Constant Field Values
-
HASH_ENCODING_PARAM
private static final String HASH_ENCODING_PARAM
- See Also:
- Constant Field Values
-
ENCODED_PARAM
private static final String ENCODED_PARAM
- See Also:
- Constant Field Values
-
LEVELS_PARAM
private static final String LEVELS_PARAM
- See Also:
- Constant Field Values
-
POPULATE_SECRET_KEY_PARAM
private static final String POPULATE_SECRET_KEY_PARAM
- See Also:
- Constant Field Values
-
BULK_CONVERT_PARAM
private static final String BULK_CONVERT_PARAM
- See Also:
- Constant Field Values
-
FILE_ARG
private static final String FILE_ARG
- See Also:
- Constant Field Values
-
DIRECTORY_ARG
private static final String DIRECTORY_ARG
- See Also:
- Constant Field Values
-
NAME_ARG
private static final String NAME_ARG
- See Also:
- Constant Field Values
-
DEFAULT_FILESYSTEM_REALM_NAME
private static final String DEFAULT_FILESYSTEM_REALM_NAME
- See Also:
- Constant Field Values
-
descriptors
private final List<FileSystemEncryptRealmCommand.Descriptor> descriptors
-
options
private final org.apache.commons.cli.Options options
-
parser
private final org.apache.commons.cli.CommandLineParser parser
-
cmdLine
private org.apache.commons.cli.CommandLine cmdLine
-
silentMode
private boolean silentMode
-
summaryMode
private boolean summaryMode
-
summaryString
private StringBuilder summaryString
-
warningOccurred
private boolean warningOccurred
-
-
Method Detail
-
warningHandler
private void warningHandler(String warning)
Prints out a warning message if silentMode is not enabled and adds the warning to the summary if summaryMode is enabled- Parameters:
warning- The warning to be shown
-
errorHandler
private void errorHandler(Exception e) throws Exception
Determines if a summary needs to be printed and prints summary after an error is thrown- Parameters:
e- The exception thrown during execution- Throws:
Exception- The exception to be handled by Elytron Tool
-
printDescriptorBlocks
private void printDescriptorBlocks(int count)
Prints out information found in a descriptor file for summary mode- Parameters:
count- The amount of descriptor blocks in the file
-
getDescriptorParam
private String getDescriptorParam(String param, FileSystemEncryptRealmCommand.Descriptor descriptor)
Returns the value for a given param in a Descriptor object- Parameters:
param- The parameter to be obtained from the Descriptor objectdescriptor- The Descriptor object to be used- Returns:
- The value of the given parameter
-
parseDescriptorFile
private void parseDescriptorFile(String file) throws Exception
Handles input being given as a descriptor file- Throws:
Exception- Exception to be handled by Elytron Tool
-
copyAddResetDescriptor
private void copyAddResetDescriptor(FileSystemEncryptRealmCommand.Descriptor original)
Copies a Descriptor into a temporary one for it can be cloned into the list of descriptors- Parameters:
original- The original descriptor that is continually modified
-
findMissingRequiredValuesAndSetValues
private void findMissingRequiredValuesAndSetValues(int count, FileSystemEncryptRealmCommand.Descriptor descriptor)Determines if the current descriptor block is missing any required values and then if it is, prints out a warning message and sets that required value and the optional values to null- Parameters:
count- The index of the current descriptor block
-
createFileSystemRealm
private void createFileSystemRealm() throws ExceptionHandles creating the Elytron filesystem-realm from the descriptor array- Throws:
Exception- Exception to be handled by Elytron Tool
-
createWildFlyScript
private void createWildFlyScript() throws ExceptionCreates the script/commands the user must run for Elytron to recognize and use the new filesystem-realm- Throws:
Exception
-
checkDescriptorFields
private boolean checkDescriptorFields(FileSystemEncryptRealmCommand.Descriptor descriptor)
-
-