Package org.apache.commons.crypto.utils
Class Utils
- java.lang.Object
-
- org.apache.commons.crypto.utils.Utils
-
public final class Utils extends java.lang.Object
General utility methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Utils.DefaultPropertiesHolder
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
SYSTEM_PROPERTIES_FILE
The file name of configuration file.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
checkArgument(boolean expression)
Ensures the truth of an expression involving one or more parameters to the calling method.static void
checkArgument(boolean expression, java.lang.Object errorMessage)
Checks the truth of an expression.static <T> T
checkNotNull(T reference)
Deprecated.UseObjects.requireNonNull(Object)
.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, java.lang.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(java.lang.String transformation, java.util.Properties properties)
Helper method to create a CryptoCipher instance and throws only IOException.static java.util.Properties
getDefaultProperties()
Gets a properties instance that defaults to the System Properties plus any other properties found in the fileSYSTEM_PROPERTIES_FILE
static java.util.Properties
getProperties(java.util.Properties newProp)
Gets the properties merged with default properties.(package private) static java.lang.String
libraryPath(java.lang.String name)
static java.util.List<java.lang.String>
splitClassNames(java.lang.String clazzNames, java.lang.String separator)
Splits class names sequence into substrings, Trim each substring into an entry,and returns an list of the entries.
-
-
-
Field Detail
-
SYSTEM_PROPERTIES_FILE
private static final java.lang.String SYSTEM_PROPERTIES_FILE
The file name of configuration file.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Utils
private Utils()
The private constructor ofUtils
.
-
-
Method Detail
-
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:
java.lang.IllegalArgumentException
- if expression is false.
-
checkArgument
public static void checkArgument(boolean expression, java.lang.Object errorMessage)
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:
java.lang.IllegalArgumentException
- if expression is false.
-
checkNotNull
@Deprecated public static <T> T checkNotNull(T reference)
Deprecated.UseObjects.requireNonNull(Object)
.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:
java.lang.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:
java.lang.IllegalStateException
- if expression is false.
-
checkState
public static void checkState(boolean expression, java.lang.String message)
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:
java.lang.IllegalStateException
- if expression is false.
-
getCipherInstance
public static CryptoCipher getCipherInstance(java.lang.String transformation, java.util.Properties properties) throws java.io.IOException
Helper method to create a CryptoCipher instance and throws only IOException.- Parameters:
properties
- TheProperties
class represents a set of properties.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.- Returns:
- the CryptoCipher instance.
- Throws:
java.io.IOException
- if an I/O error occurs.
-
getDefaultProperties
public static java.util.Properties 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
public static java.util.Properties getProperties(java.util.Properties newProp)
Gets the properties merged with default properties.- Parameters:
newProp
- User-defined properties- Returns:
- User-defined properties with the default properties
-
libraryPath
static java.lang.String libraryPath(java.lang.String name)
-
splitClassNames
public static java.util.List<java.lang.String> splitClassNames(java.lang.String clazzNames, java.lang.String separator)
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.
-
-