summaryrefslogtreecommitdiffstats
path: root/daemon/src/main/java/org/openslx/taskmanager/util/Util.java
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/src/main/java/org/openslx/taskmanager/util/Util.java')
-rw-r--r--daemon/src/main/java/org/openslx/taskmanager/util/Util.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/daemon/src/main/java/org/openslx/taskmanager/util/Util.java b/daemon/src/main/java/org/openslx/taskmanager/util/Util.java
new file mode 100644
index 0000000..bf52ecb
--- /dev/null
+++ b/daemon/src/main/java/org/openslx/taskmanager/util/Util.java
@@ -0,0 +1,24 @@
+package org.openslx.taskmanager.util;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public class Util
+{
+
+ private static GsonBuilder gsonBuilder = new GsonBuilder();
+
+ /**
+ * Small helper to create a gson instance that will only handle class members with the
+ * "@Exposed" annotation. Decided against the default of explicitly excluding fields by
+ * making them transient, as you might easily forget to exclude an important field, which
+ * can in turn be a security issue.
+ *
+ * @return Gson instance
+ */
+ public static Gson explicitGsonInstance()
+ {
+ return gsonBuilder.excludeFieldsWithoutExposeAnnotation().create();
+ }
+
+}