summaryrefslogtreecommitdiffstats
path: root/base/common
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2017-06-13 21:09:52 +0200
committerEndi S. Dewata <edewata@redhat.com>2017-06-14 02:33:59 +0200
commite5f6ed7be301a3531b871ef3b0ce64bea0fe1973 (patch)
treedb240d98a7a5d2623b4a996125b1e60e0c1619db /base/common
parent5e0dcb69a734c9f52cca673a7a5189d31fb15774 (diff)
downloadpki-e5f6ed7be301a3531b871ef3b0ce64bea0fe1973.tar.gz
pki-e5f6ed7be301a3531b871ef3b0ce64bea0fe1973.tar.xz
pki-e5f6ed7be301a3531b871ef3b0ce64bea0fe1973.zip
Fixed access banner encoding.
The Info service and client have been modified to transmit access banner in Base64-encoded form. The PKI UI has been modified to decode the access banner properly. https://pagure.io/dogtagpki/issue/2671 Change-Id: Ic8526bac4c4d6b99e627aced64ab24cf675f5d50
Diffstat (limited to 'base/common')
-rw-r--r--base/common/src/org/dogtagpki/common/Base64Adapter.java34
-rw-r--r--base/common/src/org/dogtagpki/common/Info.java2
2 files changed, 36 insertions, 0 deletions
diff --git a/base/common/src/org/dogtagpki/common/Base64Adapter.java b/base/common/src/org/dogtagpki/common/Base64Adapter.java
new file mode 100644
index 000000000..f777745c7
--- /dev/null
+++ b/base/common/src/org/dogtagpki/common/Base64Adapter.java
@@ -0,0 +1,34 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2017 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package org.dogtagpki.common;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+public class Base64Adapter extends XmlAdapter<byte[], String> {
+
+ @Override
+ public String unmarshal(byte[] bytes) throws Exception {
+ return new String(bytes);
+ }
+
+ @Override
+ public byte[] marshal(String string) throws Exception {
+ return string.getBytes();
+ }
+}
diff --git a/base/common/src/org/dogtagpki/common/Info.java b/base/common/src/org/dogtagpki/common/Info.java
index 0a216f434..7ea3fd73a 100644
--- a/base/common/src/org/dogtagpki/common/Info.java
+++ b/base/common/src/org/dogtagpki/common/Info.java
@@ -26,6 +26,7 @@ import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,6 +67,7 @@ public class Info extends ResourceMessage {
}
@XmlElement(name="Banner")
+ @XmlJavaTypeAdapter(Base64Adapter.class)
public String getBanner() {
return banner;
}