Package org.apache.xml.security.utils
Class JavaUtils
java.lang.Object
org.apache.xml.security.utils.JavaUtils
A collection of different, general-purpose methods for JAVA-specific things
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Throws aSecurityException
if 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
(String fileName) Method getBytesFromFilestatic byte[]
getBytesFromStream
(InputStream inputStream) This method reads all bytes from the given InputStream till EOF and returns them as a byte array.static void
writeBytesToFilename
(String filename, byte[] bytes) Method writeBytesToFilename
-
Method Details
-
getBytesFromFile
Method getBytesFromFile- Parameters:
fileName
-- Returns:
- the bytes read from the file
- Throws:
FileNotFoundException
IOException
-
writeBytesToFilename
Method writeBytesToFilename- Parameters:
filename
-bytes
-
-
getBytesFromStream
This method reads all bytes from the given InputStream till EOF and returns them as a byte array.- Parameters:
inputStream
-- Returns:
- the bytes read from the stream
- Throws:
FileNotFoundException
IOException
-
convertDsaASN1toXMLDSIG
Converts 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:
IOException
- if the bytes are not encoded correctly- See Also:
-
convertDsaXMLDSIGtoASN1
Converts 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:
IOException
- if the bytes are not encoded correctly- See Also:
-
checkRegisterPermission
public static void checkRegisterPermission()Throws aSecurityException
if 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:
SecurityException
- if a security manager is installed and the caller has not been granted the "org.apache.xml.security.register"SecurityPermission
-