Package org.apache.commons.crypto.utils
Class Utils
java.lang.Object
org.apache.commons.crypto.utils.Utils
General utility methods.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
The file name of configuration file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkArgument
(boolean expression) Ensures the truth of an expression involving one or more parameters to the calling method.static void
checkArgument
(boolean expression, Object errorMessage) Checks the truth of an expression.static <T> T
checkNotNull
(T reference) Deprecated.static void
checkState
(boolean expression) Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.static void
checkState
(boolean expression, String message) Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.static CryptoCipher
getCipherInstance
(String transformation, Properties properties) Helper method to create a CryptoCipher instance and throws only IOException.static Properties
Gets a properties instance that defaults to the System Properties plus any other properties found in the fileSYSTEM_PROPERTIES_FILE
static Properties
getProperties
(Properties newProp) Gets the properties merged with default properties.(package private) static String
libraryPath
(String name) splitClassNames
(String clazzNames, String separator) Splits class names sequence into substrings, Trim each substring into an entry,and returns an list of the entries.
-
Field Details
-
SYSTEM_PROPERTIES_FILE
The file name of configuration file.- See Also:
-
-
Constructor Details
-
Utils
private Utils()The private constructor ofUtils
.
-
-
Method Details
-
checkArgument
public static void checkArgument(boolean expression) Ensures the truth of an expression involving one or more parameters to the calling method.- Parameters:
expression
- a boolean expression.- Throws:
IllegalArgumentException
- if expression is false.
-
checkArgument
Checks the truth of an expression.- Parameters:
expression
- a boolean expression.errorMessage
- the exception message to use if the check fails; will be converted to a string usingString .valueOf(Object)
.- Throws:
IllegalArgumentException
- if expression is false.
-
checkNotNull
Deprecated.Ensures that an object reference passed as a parameter to the calling method is not null.- Type Parameters:
T
- the type of the object reference to be checked.- Parameters:
reference
- an object reference.- Returns:
- the non-null reference that was validated.
- Throws:
NullPointerException
- if reference is null.
-
checkState
public static void checkState(boolean expression) Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.- Parameters:
expression
- a boolean expression.- Throws:
IllegalStateException
- if expression is false.
-
checkState
Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.- Parameters:
expression
- a boolean expression.message
- Error message for the exception when the expression is false.- Throws:
IllegalStateException
- if expression is false.
-
getCipherInstance
public static CryptoCipher getCipherInstance(String transformation, Properties properties) throws IOException Helper method to create a CryptoCipher instance and throws only IOException.- Parameters:
transformation
- the name of the transformation, e.g., AES/CBC/PKCS5Padding. See the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard transformation names.properties
- TheProperties
class represents a set of properties.- Returns:
- the CryptoCipher instance.
- Throws:
IOException
- if an I/O error occurs.
-
getDefaultProperties
Gets a properties instance that defaults to the System Properties plus any other properties found in the fileSYSTEM_PROPERTIES_FILE
- Returns:
- a Properties instance with defaults
-
getProperties
Gets the properties merged with default properties.- Parameters:
newProp
- User-defined properties- Returns:
- User-defined properties with the default properties
-
libraryPath
-
splitClassNames
Splits class names sequence into substrings, Trim each substring into an entry,and returns an list of the entries.- Parameters:
clazzNames
- a string consist of a list of the entries joined by a delimiter, may be null or empty in which case an empty list is returned.separator
- a delimiter for the input string.- Returns:
- a list of class entries.
-
Objects.requireNonNull(Object)
.