APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xml.internal.security.utils

public final Class JavaUtils

extends Object
Class Inheritance
Imports
java.io.FileNotFoundException, .IOException, .InputStream, .OutputStream, java.lang.reflect.InvocationTargetException, java.nio.file.Files, .Paths, java.security.SecurityPermission

A collection of different, general-purpose methods for JAVA-specific things

Field Summary

Modifier and TypeField and Description
private static final Logger
private static final SecurityPermission
REGISTER_PERMISSION

References Deprecated SecurityPermission is deprecated or references (maybe indirectly) at least one deprecated element.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
checkRegisterPermission()

Throws a SecurityException 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.

public static byte[]

Returns:

the XML Signature encoded bytes
convertDsaASN1toXMLDSIG
(byte[]
the ASN.1 encoded bytes
asn1Bytes
,
int
size of r and s in bytes
size
)

Converts an ASN.1 DSA value to a XML Signature DSA Value.

public static byte[]

Returns:

the ASN.1 encoded bytes
convertDsaXMLDSIGtoASN1
(byte[]
the XML Signature encoded bytes
xmldsigBytes
,
int
size of r and s in bytes
size
)

Converts an XML Signature DSA Value to a ASN.1 DSA value.

public static byte[]

Returns:

the bytes read from the file
getBytesFromFile
(String fileName)

Method getBytesFromFile

public static byte[]

Returns:

the bytes read from the stream
getBytesFromStream
(InputStream inputStream)

This method reads all bytes from the given InputStream till EOF and returns them as a byte array.

public static <
the type of the class
T
>
T

Returns:

the new instance
newInstanceWithEmptyConstructor
(Class<T>
the class
clazz
)

Creates a new instance of this class with the empty constructor.

public static void
writeBytesToFilename(String filename, byte[] bytes)

Method writeBytesToFilename

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Logger LOG
REGISTER_PERMISSIONback to summary
private static final SecurityPermission REGISTER_PERMISSION

References Deprecated

SecurityPermission is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Annotations
@SuppressWarnings:removal

Constructor Detail

JavaUtilsback to summary
private JavaUtils()

Method Detail

checkRegisterPermissionback to summary
public static void checkRegisterPermission()

Throws a SecurityException 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.

Exceptions
SecurityException:
if a security manager is installed and the caller has not been granted the "com.sun.org.apache.xml.internal.security.register" SecurityPermission
convertDsaASN1toXMLDSIGback to summary
public static byte[] convertDsaASN1toXMLDSIG(byte[] asn1Bytes, int size) throws IOException

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:byte[]

the ASN.1 encoded bytes

size:int

size of r and s in bytes

Returns:byte[]

the XML Signature encoded bytes

Exceptions
IOException:
if the bytes are not encoded correctly
See Also
6.4.1 DSA
convertDsaXMLDSIGtoASN1back to summary
public static byte[] convertDsaXMLDSIGtoASN1(byte[] xmldsigBytes, int size) throws IOException

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:byte[]

the XML Signature encoded bytes

size:int

size of r and s in bytes

Returns:byte[]

the ASN.1 encoded bytes

Exceptions
IOException:
if the bytes are not encoded correctly
See Also
6.4.1 DSA
getBytesFromFileback to summary
public static byte[] getBytesFromFile(String fileName) throws FileNotFoundException, IOException

Method getBytesFromFile

Returns:byte[]

the bytes read from the file

getBytesFromStreamback to summary
public static byte[] getBytesFromStream(InputStream inputStream) throws IOException

This 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.

Returns:byte[]

the bytes read from the stream

newInstanceWithEmptyConstructorback to summary
public static <T> T newInstanceWithEmptyConstructor(Class<T> clazz) throws InstantiationException, IllegalAccessException, InvocationTargetException

Creates a new instance of this class with the empty constructor.

Parameters
<T>
the type of the class
clazz:Class<T>

the class

Returns:T

the new instance

writeBytesToFilenameback to summary
public static void writeBytesToFilename(String filename, byte[] bytes)

Method writeBytesToFilename