Class SerializationUtils


  • public final class SerializationUtils
    extends java.lang.Object
    Static utility to help with serialization.
    Author:
    Dave Syer, Gary Russell
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkAllowedList​(java.lang.Class<?> clazz, java.util.Set<java.lang.String> patterns)
      Verify that the class is in the allowed list.
      static java.lang.Object deserialize​(byte[] bytes)
      Deserialize the bytes.
      static java.lang.Object deserialize​(java.io.InputStream inputStream, java.util.Set<java.lang.String> allowedListPatterns, java.lang.ClassLoader classLoader)
      Deserialize the stream.
      static java.lang.Object deserialize​(java.io.ObjectInputStream stream)
      Deserialize the stream.
      static byte[] serialize​(java.lang.Object object)
      Serialize the object provided.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • serialize

        public static byte[] serialize​(java.lang.Object object)
        Serialize the object provided.
        Parameters:
        object - the object to serialize
        Returns:
        an array of bytes representing the object in a portable fashion
      • deserialize

        public static java.lang.Object deserialize​(byte[] bytes)
        Deserialize the bytes.
        Parameters:
        bytes - a serialized object created
        Returns:
        the result of deserializing the bytes
      • deserialize

        public static java.lang.Object deserialize​(java.io.ObjectInputStream stream)
        Deserialize the stream.
        Parameters:
        stream - an object stream created from a serialized object
        Returns:
        the result of deserializing the bytes
      • deserialize

        public static java.lang.Object deserialize​(java.io.InputStream inputStream,
                                                   java.util.Set<java.lang.String> allowedListPatterns,
                                                   java.lang.ClassLoader classLoader)
                                            throws java.io.IOException
        Deserialize the stream.
        Parameters:
        inputStream - the stream.
        allowedListPatterns - allowed classes.
        classLoader - the class loader.
        Returns:
        the result.
        Throws:
        java.io.IOException - IO Exception.
        Since:
        2.1
      • checkAllowedList

        public static void checkAllowedList​(java.lang.Class<?> clazz,
                                            java.util.Set<java.lang.String> patterns)
        Verify that the class is in the allowed list.
        Parameters:
        clazz - the class.
        patterns - the patterns.
        Since:
        2.1