Class StashObjectInputStream

java.lang.Object
java.io.InputStream
java.io.ObjectInputStream
com.atlassian.confluence.impl.backuprestore.restore.stash.StashObjectInputStream
All Implemented Interfaces:
Closeable, DataInput, ObjectInput, ObjectStreamConstants, AutoCloseable

public class StashObjectInputStream extends ObjectInputStream
This class extends the ObjectInputStream class and overrides the resolveClass method. It is used to deserialize objects of specific allowed classes only. Unauthorized deserialization attempts will throw an InvalidClassException.
  • Constructor Details

    • StashObjectInputStream

      public StashObjectInputStream(InputStream in, HibernateMetadataHelper hibernateMetadataHelper, Set<Class<?>> allowedClasses) throws IOException
      Constructs a new StashObjectInputStream with the specified input stream, HibernateMetadataHelper, allowed classes, and a flag indicating whether the deserialization allowlist is enabled.
      Parameters:
      in - The InputStream from which to read the serialized object.
      hibernateMetadataHelper - The HibernateMetadataHelper instance used to get all exportable entities by class.
      allowedClasses - The set of classes that are allowed to be deserialized.
      Throws:
      IOException - If an I/O error occurs while reading stream header.
  • Method Details

    • resolveClass

      protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException
      Resolves the class for the provided ObjectStreamClass descriptor. Only classes that are in the ALLOWED_CLASSES set are allowed to be deserialized.
      Overrides:
      resolveClass in class ObjectInputStream
      Parameters:
      desc - An instance of ObjectStreamClass.
      Returns:
      The Class object for the class with the specified name.
      Throws:
      IOException - If an I/O error occurs while reading class descriptor.
      ClassNotFoundException - If class of a serialized object cannot be found.