o added support for JSON data format (FC-250)
o updated the realm version to latest snapshot
diff --git a/pom.xml b/pom.xml
index e83c9da..6484689 100755
--- a/pom.xml
+++ b/pom.xml
@@ -93,7 +93,7 @@
<title>${project.name} ${project.version}</title>
<!-- Dependencies version -->
- <fortress.realm.version>2.0.2</fortress.realm.version>
+ <fortress.realm.version>${project.version}</fortress.realm.version>
<cxf.version>3.2.6</cxf.version>
<httpclient.version>3.1</httpclient.version>
<java.version>1.8</java.version>
@@ -104,6 +104,7 @@
<slf4j.log4j12.version>1.7.21</slf4j.log4j12.version>
<spring.version>5.0.9.RELEASE</spring.version>
<spring.security.version>5.0.7.RELEASE</spring.security.version>
+ <jackson-jaxrs.version>2.9.7</jackson-jaxrs.version>
<!-- Other properties -->
<base.dir>.</base.dir>
@@ -138,6 +139,12 @@
<version>${cxf.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ <version>${jackson-jaxrs.version}</version>
+ </dependency>
+
<!-- Spring Dependencies -->
<dependency>
<groupId>org.springframework</groupId>
diff --git a/src/main/java/org/apache/directory/fortress/rest/JacksonFieldOnlyMapper.java b/src/main/java/org/apache/directory/fortress/rest/JacksonFieldOnlyMapper.java
new file mode 100644
index 0000000..41cc7d0
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/rest/JacksonFieldOnlyMapper.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.fortress.rest;
+
+import org.apache.directory.fortress.core.model.FortEntity;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * This class is used to marshall/unmarshall subtypes of {@link FortEntity} using only the fields.
+ * This mapper ignores all the getter and setters.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class JacksonFieldOnlyMapper extends ObjectMapper
+{
+ public JacksonFieldOnlyMapper()
+ {
+ super();
+ // allow access to fields
+ setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
+ setVisibility(PropertyAccessor.GETTER, Visibility.NONE); // and do not use getters and setters
+ setVisibility(PropertyAccessor.IS_GETTER, Visibility.NONE);
+ setVisibility(PropertyAccessor.SETTER, Visibility.NONE);
+ }
+}
diff --git a/src/main/resources/applicationContext.xml b/src/main/resources/applicationContext.xml
index fc17f78..5649b86 100644
--- a/src/main/resources/applicationContext.xml
+++ b/src/main/resources/applicationContext.xml
@@ -38,6 +38,13 @@
<property name="securedObject" ref="securedObject"/>
</bean>
+ <bean id="customMapper" class="org.apache.directory.fortress.rest.JacksonFieldOnlyMapper">
+ </bean>
+
+ <bean id="customJsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider">
+ <constructor-arg ref="customMapper"/>
+ </bean>
+
<jaxrs:server id="restContainer" address="/">
<jaxrs:serviceBeans>
<ref bean="fortressService"/>
@@ -51,6 +58,9 @@
<bean class="org.apache.directory.fortress.rest.SecurityOutFaultInterceptor"/>
</jaxrs:outFaultInterceptors>
+ <jaxrs:providers>
+ <ref bean="customJsonProvider"/>
+ </jaxrs:providers>
</jaxrs:server>
</beans>
diff --git a/src/test/java/org/apache/directory/fortress/rest/JsonSerializationTest.java b/src/test/java/org/apache/directory/fortress/rest/JsonSerializationTest.java
new file mode 100644
index 0000000..b83f55a
--- /dev/null
+++ b/src/test/java/org/apache/directory/fortress/rest/JsonSerializationTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.fortress.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.directory.fortress.core.model.User;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class JsonSerializationTest {
+ @Test
+ public void testFqcn() throws Exception {
+ User u = new User();
+ JacksonFieldOnlyMapper om = new JacksonFieldOnlyMapper();
+ byte[] data = om.writeValueAsBytes(u);
+ JsonNode json = om.readTree(data);
+ assertEquals(User.class.getName(), json.get("fqcn").asText());
+ User read = om.readValue(data, User.class);
+ assertNotNull(read);
+ }
+}