加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

我们可以拒绝序列化的java对象,而不是给出transient关键字

发布时间:2020-12-14 17:48:09 所属栏目:Java 来源:网络整理
导读:我们可以通过使用transient关键字来避免序列化字段. 有没有其他的方法呢? 解决方法 http://java.sun.com/javase/6/docs/platform/serialization/spec/security.html SUMMARY:Preventing Serialization of Sensitive Data Fields containing sensitive data
我们可以通过使用transient关键字来避免序列化字段.
有没有其他的方法呢?

解决方法

http://java.sun.com/javase/6/docs/platform/serialization/spec/security.html

SUMMARY:Preventing Serialization of
Sensitive Data Fields containing
sensitive data should not be
serialized; doing so exposes their
values to any party with access to the
serialization stream. There are
several methods for preventing a field
from being serialized:

  1. Declare the field as private transient.
  2. Define the serialPersistentFields
    field of the class in question,and
    omit the field from the list of
    field descriptors.
  3. Write a class-specific serialization
    method (i.e.,writeObject or
    writeExternal) which does not write
    the field to the serialization
    stream (i.e.,by not calling
    ObjectOutputStream.defaultWriteObject).

这里有一些链接.

Declaring serialPersistenetFields.

Serialization architecture specification.

Security in Object Serialization.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读