cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [cxf-fediz] branch 1.3.x-fixes updated: FEDIZ-209 - Make FedizResponse properly serializable
Date Tue, 12 Sep 2017 12:11:32 GMT
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 1.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf-fediz.git


The following commit(s) were added to refs/heads/1.3.x-fixes by this push:
     new 7d3dea6  FEDIZ-209 - Make FedizResponse properly serializable
7d3dea6 is described below

commit 7d3dea6239c04ec1069df8d052c2ce5b95d3596e
Author: Colm O hEigeartaigh <coheigea@apache.org>
AuthorDate: Tue Sep 12 13:10:09 2017 +0100

    FEDIZ-209 - Make FedizResponse properly serializable
---
 .../cxf/fediz/core/processor/FedizResponse.java    | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/FedizResponse.java
b/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/FedizResponse.java
index 255765d..13c6726 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/FedizResponse.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/FedizResponse.java
@@ -19,14 +19,24 @@
 
 package org.apache.cxf.fediz.core.processor;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.io.Serializable;
+import java.io.StringReader;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
+
 import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
 
 import org.apache.cxf.fediz.core.Claim;
+import org.apache.cxf.fediz.core.util.DOMUtils;
+import org.apache.wss4j.common.util.DOM2Writer;
 
 public class FedizResponse implements Serializable {
 
@@ -38,6 +48,7 @@ public class FedizResponse implements Serializable {
     private String issuer;
     private List<Claim> claims;
     private transient Element token;
+    private String tokenStr;
     private String uniqueTokenId;
 
     /**
@@ -116,5 +127,19 @@ public class FedizResponse implements Serializable {
         return token;
     }
 
+    private void writeObject(ObjectOutputStream stream) throws IOException {
+        if (token != null && tokenStr == null) {
+            tokenStr = DOM2Writer.nodeToString(token);
+        }
+        stream.defaultWriteObject();
+    }
+
+    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException,
+        XMLStreamException, SAXException, ParserConfigurationException {
+        in.defaultReadObject();
 
+        if (token == null && tokenStr != null) {
+            token = DOMUtils.readXml(new StringReader(tokenStr)).getDocumentElement();
+        }
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@cxf.apache.org" <commits@cxf.apache.org>'].

Mime
View raw message