- java.lang.Object
-
- org.apache.xml.security.utils.JavaUtils
-
public final class JavaUtils extends java.lang.ObjectA collection of different, general-purpose methods for JAVA-specific things
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.System.LoggerLOGprivate static java.security.SecurityPermissionREGISTER_PERMISSION
-
Constructor Summary
Constructors Modifier Constructor Description privateJavaUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidcheckRegisterPermission()Throws aSecurityExceptionif a security manager is installed and the caller is not allowed to register an implementation of an algorithm, transform, or other security sensitive XML Signature function.static byte[]convertDsaASN1toXMLDSIG(byte[] asn1Bytes, int size)Converts an ASN.1 DSA value to a XML Signature DSA Value.static byte[]convertDsaXMLDSIGtoASN1(byte[] xmldsigBytes, int size)Converts an XML Signature DSA Value to a ASN.1 DSA value.static byte[]getBytesFromFile(java.lang.String filePath)Deprecated, for removal: This API element is subject to removal in a future version.UseFiles.readAllBytes(java.nio.file.Path)static byte[]getBytesFromStream(java.io.InputStream inputStream)This method reads all bytes from the given InputStream till EOF and returns them as a byte array.static <T> TnewInstanceWithEmptyConstructor(java.lang.Class<T> clazz)Creates a new instance of this class with the empty constructor.static voidwriteBytesToFilename(java.lang.String filename, byte[] bytes)Method writeBytesToFilename
-
-
-
Method Detail
-
getBytesFromFile
@Deprecated(forRemoval=true, since="4.0.0") public static byte[] getBytesFromFile(java.lang.String filePath) throws java.io.FileNotFoundException, java.io.IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.UseFiles.readAllBytes(java.nio.file.Path)Method getBytesFromFile- Parameters:
filePath-- Returns:
- the bytes read from the file
- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
writeBytesToFilename
public static void writeBytesToFilename(java.lang.String filename, byte[] bytes)Method writeBytesToFilename- Parameters:
filename-bytes-
-
getBytesFromStream
public static byte[] getBytesFromStream(java.io.InputStream inputStream) throws java.io.IOExceptionThis method reads all bytes from the given InputStream till EOF and returns them as a byte array.The method doesn't close the input stream.
- Parameters:
inputStream-- Returns:
- the bytes read from the stream
- Throws:
java.io.FileNotFoundExceptionjava.io.IOException
-
convertDsaASN1toXMLDSIG
public static byte[] convertDsaASN1toXMLDSIG(byte[] asn1Bytes, int size) throws java.io.IOExceptionConverts an ASN.1 DSA value to a XML Signature DSA Value. The JCE DSA Signature algorithm creates ASN.1 encoded (r, s) value pairs (see section 2.2.2 of RFC 3279); the XML Signature requires the core BigInteger values.- Parameters:
asn1Bytes- the ASN.1 encoded bytessize- size of r and s in bytes- Returns:
- the XML Signature encoded bytes
- Throws:
java.io.IOException- if the bytes are not encoded correctly- See Also:
- 6.4.1 DSA
-
convertDsaXMLDSIGtoASN1
public static byte[] convertDsaXMLDSIGtoASN1(byte[] xmldsigBytes, int size) throws java.io.IOExceptionConverts an XML Signature DSA Value to a ASN.1 DSA value. The JCE DSA Signature algorithm creates ASN.1 encoded (r, s) value pairs (see section 2.2.2 of RFC 3279); the XML Signature requires the core BigInteger values.- Parameters:
xmldsigBytes- the XML Signature encoded bytessize- size of r and s in bytes- Returns:
- the ASN.1 encoded bytes
- Throws:
java.io.IOException- if the bytes are not encoded correctly- See Also:
- 6.4.1 DSA
-
checkRegisterPermission
public static void checkRegisterPermission()
Throws aSecurityExceptionif a security manager is installed and the caller is not allowed to register an implementation of an algorithm, transform, or other security sensitive XML Signature function.- Throws:
java.lang.SecurityException- if a security manager is installed and the caller has not been granted the "org.apache.xml.security.register"SecurityPermission
-
newInstanceWithEmptyConstructor
public static <T> T newInstanceWithEmptyConstructor(java.lang.Class<T> clazz) throws java.lang.InstantiationException, java.lang.IllegalAccessExceptionCreates a new instance of this class with the empty constructor.- Type Parameters:
T- the type of the class- Parameters:
clazz- the class- Returns:
- the new instance
- Throws:
java.lang.InstantiationExceptionjava.lang.IllegalAccessException
-
-