Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

DefaultSamlAuthentication is not serializable despite being implementing Serializable interface #450

Open
gnom7 opened this issue Jul 18, 2019 · 3 comments

Comments

@gnom7
Copy link

gnom7 commented Jul 18, 2019

I'd like to store authentication in redis, but it fails to serialize object despite java.io.Serializable interface is implemented by org.springframework.security.saml.spi.DefaultSamlAuthentication.

Caused by: java.io.NotSerializableException: org.springframework.security.saml.saml2.authentication.Assertion
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)

From java.io.Serializable javadoc:

The writeObject method is responsible for writing the state of the object for its particular class so that the corresponding readObject method can restore it.

When traversing a graph, an object may be encountered that does not support the Serializable interface. In this case the NotSerializableException will be thrown and will identify the class of the non-serializable object.

So, I would need to customize serialization on my own, at least for now.

@cbgr
Copy link

cbgr commented Sep 13, 2019

org.springframework.security.saml.saml2.Saml2Object Must be serializable

@hello-josh
Copy link

@gnom7 did you resolve this?

@gnom7
Copy link
Author

gnom7 commented Oct 6, 2021

@hello-josh my workaround was custom (de)serialization to json string, although I would expect this to be implemented by spring

So, I would need to customize serialization on my own, at least for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants