public class Utils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DISABLE_XML_SECURE_PROCESSING |
| Constructor and Description |
|---|
Utils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
absolutizePath(java.lang.String basePath,
java.lang.String candidatePath,
char separatorChar)
Absolutizes a specified candidate path using a specified base path and a specified separator character.
|
static byte[] |
base64Decode(byte[] encodedData)
Transforms the specified base64 encoded data into the corresponding plain data.
|
static byte[] |
base64Encode(byte[] plainData)
Transforms the specified plain data into base64 encoded data.
|
static java.lang.String |
byteArrayToString(byte[] bytes)
Produces a string representation of a given byte array.
|
static void |
checkArgForCondition(java.lang.String argName,
boolean condition)
Throws an
IXSILIllegalArgumentException if the specified condition is fulfilled. |
static void |
checkArgForNull(java.lang.Object arg,
java.lang.String argName)
Throws an
IXSILIllegalArgumentException if the specified argument equals null
. |
static java.lang.String |
name2XMLSignatureDNameString(Name name)
Serializes a
Name object into a DName string compliant with the rules of section 4.4.4 of
XML-Signature Syntax and Processing. |
static java.lang.String |
normalizePathSeparator(java.lang.String candidatePath)
Replaces all occurences of the platform dependent file separator (e.
|
static byte[] |
readFromInputStream(java.io.InputStream inputStream)
Reads from the specified InputStream until EOF is detected.
|
static char[] |
readFromReader(java.io.Reader reader)
Reads from the specified character stream until the end of the stream is detected.
|
static java.lang.String |
searchReplace(java.lang.String candidateStr,
java.lang.String searchStr,
java.lang.String replaceStr)
Replaces all occurences of a pattern string in a candidate string with the value of a replacement
string.
|
static void |
setSecureProcessing(javax.xml.parsers.DocumentBuilderFactory bFactory)
Tries to set the secure Processing feature for the DocumentBuilderFactory using the JAXP 1.3
setFeature() API.
|
static void |
setSecureProcessing(javax.xml.transform.TransformerFactory tFactory)
Tries to set the secure Processing feature for the TransformFactory using the JAXP 1.3
setFeature() API.
|
static Name |
xMLSignatureDNameString2Name(java.lang.String dNameString)
Parses a DName string which is encoded according to the rules specfied in section 4.4.4 of XML-Signature Syntax and Processing.
|
public static final java.lang.String DISABLE_XML_SECURE_PROCESSING
public static byte[] base64Encode(byte[] plainData)
throws UtilsException
plainData - The data bytes to be encoded. Must not be null.UtilsException - if the transform fails for any reason.public static Name xMLSignatureDNameString2Name(java.lang.String dNameString) throws RFC2253NameParserException
dNameString - The DName string to be parsed.Name object parsed from the DName string.RFC2253NameParserException - If parsing the DName string fails for any reasion.public static java.lang.String name2XMLSignatureDNameString(Name name)
Name object into a DName string compliant with the rules of section 4.4.4 of
XML-Signature Syntax and Processing.name - The Name object to be serialized.Name object.public static byte[] base64Decode(byte[] encodedData)
throws UtilsException
encodedData - The base64 encoded data bytes. Must not be null.UtilsException - if the transform fails for any reason.public static byte[] readFromInputStream(java.io.InputStream inputStream)
throws UtilsException
inputStream - The input byte stream to be read from. Must not be null.UtilsException - if an IO error occurs while reading from the byte stream.public static char[] readFromReader(java.io.Reader reader)
throws UtilsException
reader - The character stream to be read from. Must not be null.UtilsException - if reading form the stream fails for any reson.public static java.lang.String searchReplace(java.lang.String candidateStr,
java.lang.String searchStr,
java.lang.String replaceStr)
candidateStr - The candiate string. Must not be null.searchStr - The pattern string. Must not be null.replaceStr - The replacement string. Must not be null.public static java.lang.String absolutizePath(java.lang.String basePath,
java.lang.String candidatePath,
char separatorChar)
throws UtilsException
basePath - The base path used for making the candidate path absolute. Must not be null
.candidatePath - The candidate path to be made absolute. Must not be null.separatorChar - The character employed for separating path segments.UtilsException - if the specified candidate path cannot be absolutized using the specified
base path.public static java.lang.String normalizePathSeparator(java.lang.String candidatePath)
'\' on Windows
platforms in a specified path with the character '/'.candidatePath - The file path which separators are to be normalized. Must not be null
.public static java.lang.String byteArrayToString(byte[] bytes)
15 will
result in 0x0F. The values are separated by a single space. After 10 values a line break
will be inserted.bytes - The byte array to be transformed into a string. May be also null.public static void checkArgForNull(java.lang.Object arg,
java.lang.String argName)
IXSILIllegalArgumentException if the specified argument equals null
.arg - The candidate argument to test.argName - The name of the argument to be shown in the exception message.public static void checkArgForCondition(java.lang.String argName,
boolean condition)
IXSILIllegalArgumentException if the specified condition is fulfilled.argName - The name of the argument to be shown in the exception message.condition - The condition to be fulfilled.public static void setSecureProcessing(javax.xml.transform.TransformerFactory tFactory)
This method will throw a RuntimeException if there is a problem setting the secure processing feature
and the System property iaik.ixsil.util.Utils.disableXMLSecureProcessing is set to true.
By default this system property is set to false.
tFactory - The TransformerFactory which will set the Secure processing featurepublic static void setSecureProcessing(javax.xml.parsers.DocumentBuilderFactory bFactory)
This method will throw a RuntimeException if there is a problem setting the secure processing feature
and the System property iaik.ixsil.util.Utils.disableXMLSecureProcessing is set to true.
By default this system property is set to false.
bFactory - the DocumentBuildeFactory which will set the secure processing featureUtilsException - if the feature cannot be setDOMUtilsException