- {{realm.realm}}
- - Audit
- - Social
+ - Audit
+ - Config
{{realm.realm}} Audit Config
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-audit.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-audit.html
index 01543200fb..7b58c9c4b6 100755
--- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-audit.html
+++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-audit.html
@@ -9,8 +9,7 @@
- {{realm.realm}}
- - Audit
- - Social
+ - Audit
{{realm.realm}} Audit Log
diff --git a/pom.xml b/pom.xml
index 34ed8179b8..640300d717 100755
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,6 @@
1.5.10
7.1.1.Final
8.0.0.Final
-
20131018
1.6
@@ -286,12 +285,6 @@
2.3.19
-
- org.json
- json
- ${json.version}
-
-
com.google.http-client
diff --git a/project-integrations/aerogear-ups/auth-server/pom.xml b/project-integrations/aerogear-ups/auth-server/pom.xml
index e30625f80a..7c738b825f 100755
--- a/project-integrations/aerogear-ups/auth-server/pom.xml
+++ b/project-integrations/aerogear-ups/auth-server/pom.xml
@@ -73,10 +73,6 @@
keycloak-social-core
${project.version}
-
- org.json
- json
-
org.keycloak
keycloak-social-github
diff --git a/server/pom.xml b/server/pom.xml
index fc93352039..7fb498b502 100755
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -68,10 +68,6 @@
keycloak-social-core
${project.version}
-
- org.json
- json
-
org.keycloak
keycloak-social-github
diff --git a/services/src/main/java/org/keycloak/services/resources/AccountService.java b/services/src/main/java/org/keycloak/services/resources/AccountService.java
index 327f20ad1f..2f998e721b 100755
--- a/services/src/main/java/org/keycloak/services/resources/AccountService.java
+++ b/services/src/main/java/org/keycloak/services/resources/AccountService.java
@@ -234,13 +234,14 @@ public class AccountService {
e.setEvent(e.getEvent().replace('_', ' '));
Map details = new HashMap();
- Iterator itr = e.getDetails().keySet().iterator();
- for (Map.Entry d : e.getDetails().entrySet()) {
- if (AUDIT_DETAILS.contains(d.getKey())) {
- details.put(d.getKey().replace('_', ' '), d.getValue());
+ if (e.getDetails() != null) {
+ Iterator itr = e.getDetails().keySet().iterator();
+ for (Map.Entry d : e.getDetails().entrySet()) {
+ if (AUDIT_DETAILS.contains(d.getKey())) {
+ details.put(d.getKey().replace('_', ' '), d.getValue());
+ }
}
}
-
e.setDetails(details);
}
account.setEvents(events);
diff --git a/social/core/pom.xml b/social/core/pom.xml
index 457854326a..d19c6caa50 100755
--- a/social/core/pom.xml
+++ b/social/core/pom.xml
@@ -21,8 +21,8 @@
provided
- org.json
- json
+ org.codehaus.jackson
+ jackson-mapper-asl
provided
diff --git a/social/core/src/main/java/org/keycloak/social/AbstractOAuth2Provider.java b/social/core/src/main/java/org/keycloak/social/AbstractOAuth2Provider.java
index 92d64857af..f3fdea728b 100644
--- a/social/core/src/main/java/org/keycloak/social/AbstractOAuth2Provider.java
+++ b/social/core/src/main/java/org/keycloak/social/AbstractOAuth2Provider.java
@@ -1,6 +1,6 @@
package org.keycloak.social;
-import org.json.JSONObject;
+import org.codehaus.jackson.map.ObjectMapper;
import org.keycloak.OAuth2Constants;
import org.keycloak.social.utils.SimpleHttp;
@@ -14,6 +14,8 @@ import java.util.regex.Pattern;
*/
public abstract class AbstractOAuth2Provider implements SocialProvider {
+ private static ObjectMapper mapper = new ObjectMapper();
+
private static final String AUTHORIZATION_CODE = "authorization_code";
private static final String ACCESS_TOKEN = "access_token";
private static final String CLIENT_ID = "client_id";
@@ -76,7 +78,7 @@ public abstract class AbstractOAuth2Provider implements SocialProvider {
String accessToken;
if (response.startsWith("{")) {
- accessToken = new JSONObject(response).getString(ACCESS_TOKEN);
+ accessToken = mapper.readTree(response).get(ACCESS_TOKEN).getTextValue();
} else {
Matcher matcher = Pattern.compile(TOKEN_REGEX).matcher(response);
if (matcher.find()) {
diff --git a/social/core/src/main/java/org/keycloak/social/utils/SimpleHttp.java b/social/core/src/main/java/org/keycloak/social/utils/SimpleHttp.java
index d5ef204f07..757d58f3ae 100644
--- a/social/core/src/main/java/org/keycloak/social/utils/SimpleHttp.java
+++ b/social/core/src/main/java/org/keycloak/social/utils/SimpleHttp.java
@@ -1,6 +1,7 @@
package org.keycloak.social.utils;
-import org.json.JSONObject;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
import java.io.IOException;
import java.io.InputStream;
@@ -18,6 +19,8 @@ import java.util.Map;
*/
public class SimpleHttp {
+ private static ObjectMapper mapper = new ObjectMapper();
+
private String url;
private String method;
private Map headers;
@@ -52,8 +55,8 @@ public class SimpleHttp {
return this;
}
- public JSONObject asJson() throws IOException {
- return new JSONObject(asString());
+ public JsonNode asJson() throws IOException {
+ return mapper.readTree(asString());
}
public String asString() throws IOException {
diff --git a/social/core/src/main/test/java/org/keycloak/social/utils/SimpleHttpTest.java b/social/core/src/main/test/java/org/keycloak/social/utils/SimpleHttpTest.java
index dea58c7f1d..6f3103ded2 100644
--- a/social/core/src/main/test/java/org/keycloak/social/utils/SimpleHttpTest.java
+++ b/social/core/src/main/test/java/org/keycloak/social/utils/SimpleHttpTest.java
@@ -2,7 +2,7 @@ package org.keycloak.social.utils;
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.servlet.api.ServletInfo;
-import org.json.JSONObject;
+import org.codehaus.jackson.JsonNode;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -45,56 +45,56 @@ public class SimpleHttpTest {
@Test
public void testPostNoParams() throws IOException {
- JSONObject o = SimpleHttp.doPost("http://localhost:8081/tojson").asJson();
- JSONObject p = o.getJSONObject("params");
+ JsonNode o = SimpleHttp.doPost("http://localhost:8081/tojson").asJson();
+ JsonNode p = o.get("params");
- assertEquals(0, p.length());
+ assertEquals(0, p.size());
}
@Test
public void testPost() throws IOException {
- JSONObject o = SimpleHttp.doPost("http://localhost:8081/tojson").param("key-one", "value one ;)").param("key-two", "value two!&").asJson();
- JSONObject p = o.getJSONObject("params");
+ JsonNode o = SimpleHttp.doPost("http://localhost:8081/tojson").param("key-one", "value one ;)").param("key-two", "value two!&").asJson();
+ JsonNode p = o.get("params");
- assertEquals(2, p.length());
- assertEquals("value one ;)", p.getString("key-one"));
- assertEquals("value two!&", p.getString("key-two"));
+ assertEquals(2, p.size());
+ assertEquals("value one ;)", p.get("key-one").getTextValue());
+ assertEquals("value two!&", p.get("key-two").getTextValue());
}
@Test
public void testPostCustomHeader() throws IOException {
- JSONObject o = SimpleHttp.doPost("http://localhost:8081/tojson").header("Accept", "application/json").header("Authorization", "bearer dsfsadfsdf").asJson();
- JSONObject h = o.getJSONObject("headers");
+ JsonNode o = SimpleHttp.doPost("http://localhost:8081/tojson").header("Accept", "application/json").header("Authorization", "bearer dsfsadfsdf").asJson();
+ JsonNode h = o.get("headers");
- assertEquals("application/json", h.getString("Accept"));
- assertEquals("bearer dsfsadfsdf", h.getString("Authorization"));
+ assertEquals("application/json", h.get("Accept").getTextValue());
+ assertEquals("bearer dsfsadfsdf", h.get("Authorization").getTextValue());
}
@Test
public void testGetNoParams() throws IOException {
- JSONObject o = SimpleHttp.doGet("http://localhost:8081/tojson").asJson();
- JSONObject p = o.getJSONObject("params");
+ JsonNode o = SimpleHttp.doGet("http://localhost:8081/tojson").asJson();
+ JsonNode p = o.get("params");
- assertEquals(0, p.length());
+ assertEquals(0, p.size());
}
@Test
public void testGet() throws IOException {
- JSONObject o = SimpleHttp.doGet("http://localhost:8081/tojson").param("key-one", "value one ;)").param("key-two", "value two!&").asJson();
- JSONObject p = o.getJSONObject("params");
+ JsonNode o = SimpleHttp.doGet("http://localhost:8081/tojson").param("key-one", "value one ;)").param("key-two", "value two!&").asJson();
+ JsonNode p = o.get("params");
- assertEquals(2, p.length());
- assertEquals("value one ;)", p.getString("key-one"));
- assertEquals("value two!&", p.getString("key-two"));
+ assertEquals(2, p.size());
+ assertEquals("value one ;)", p.get("key-one").getTextValue());
+ assertEquals("value two!&", p.get("key-two").getTextValue());
}
@Test
public void testGetCustomHeader() throws IOException {
- JSONObject o = SimpleHttp.doGet("http://localhost:8081/tojson").header("Accept", "application/json").header("Authorization", "bearer dsfsadfsdf").asJson();
- JSONObject h = o.getJSONObject("headers");
+ JsonNode o = SimpleHttp.doGet("http://localhost:8081/tojson").header("Accept", "application/json").header("Authorization", "bearer dsfsadfsdf").asJson();
+ JsonNode h = o.get("headers");
- assertEquals("application/json", h.getString("Accept"));
- assertEquals("bearer dsfsadfsdf", h.getString("Authorization"));
+ assertEquals("application/json", h.get("Accept"));
+ assertEquals("bearer dsfsadfsdf", h.get("Authorization").getTextValue());
}
}
diff --git a/social/core/src/main/test/java/org/keycloak/social/utils/ToJsonServlet.java b/social/core/src/main/test/java/org/keycloak/social/utils/ToJsonServlet.java
index 1d738e7da1..e63b4b1bd5 100644
--- a/social/core/src/main/test/java/org/keycloak/social/utils/ToJsonServlet.java
+++ b/social/core/src/main/test/java/org/keycloak/social/utils/ToJsonServlet.java
@@ -1,6 +1,8 @@
package org.keycloak.social.utils;
-import org.json.JSONObject;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.node.ObjectNode;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -14,6 +16,8 @@ import java.util.Enumeration;
*/
public class ToJsonServlet extends HttpServlet {
+ private static final ObjectMapper mapper = new ObjectMapper();
+
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
toJson(req, resp);
@@ -25,9 +29,9 @@ public class ToJsonServlet extends HttpServlet {
}
private void toJson(HttpServletRequest req, HttpServletResponse resp) throws IOException {
- JSONObject o = new JSONObject();
+ ObjectNode o = mapper.createObjectNode();
- JSONObject headers = new JSONObject();
+ ObjectNode headers = mapper.createObjectNode();
Enumeration headerNames = req.getHeaderNames();
while (headerNames.hasMoreElements()) {
String n = headerNames.nextElement();
@@ -35,7 +39,7 @@ public class ToJsonServlet extends HttpServlet {
}
o.put("headers", headers);
- JSONObject params = new JSONObject();
+ ObjectNode params = mapper.createObjectNode();
Enumeration parameterNames = req.getParameterNames();
while (parameterNames.hasMoreElements()) {
String n = parameterNames.nextElement();
diff --git a/social/facebook/pom.xml b/social/facebook/pom.xml
index be3679c958..bcacfb8299 100755
--- a/social/facebook/pom.xml
+++ b/social/facebook/pom.xml
@@ -14,16 +14,16 @@
-
- org.json
- json
- provided
-
org.keycloak
keycloak-social-core
${project.version}
provided
+
+ org.codehaus.jackson
+ jackson-mapper-asl
+ provided
+
diff --git a/social/facebook/src/main/java/org/keycloak/social/facebook/FacebookProvider.java b/social/facebook/src/main/java/org/keycloak/social/facebook/FacebookProvider.java
index 9f6403608a..830abff642 100755
--- a/social/facebook/src/main/java/org/keycloak/social/facebook/FacebookProvider.java
+++ b/social/facebook/src/main/java/org/keycloak/social/facebook/FacebookProvider.java
@@ -1,6 +1,6 @@
package org.keycloak.social.facebook;
-import org.json.JSONObject;
+import org.codehaus.jackson.JsonNode;
import org.keycloak.social.AbstractOAuth2Provider;
import org.keycloak.social.AuthRequest;
import org.keycloak.social.SocialProviderConfig;
@@ -50,11 +50,12 @@ public class FacebookProvider extends AbstractOAuth2Provider {
@Override
protected SocialUser getProfile(String accessToken) throws SocialProviderException {
try {
- JSONObject profile = SimpleHttp.doGet(PROFILE_URL).header("Authorization", "Bearer " + accessToken).asJson();
+ JsonNode profile = SimpleHttp.doGet(PROFILE_URL).header("Authorization", "Bearer " + accessToken).asJson();
- SocialUser user = new SocialUser(profile.getString("id"), profile.getString("username"));
- user.setName(profile.optString("first_name"), profile.optString("last_name"));
- user.setEmail(profile.optString("email"));
+ SocialUser user = new SocialUser(profile.get("id").getTextValue(), profile.get("username").getTextValue());
+ user.setName(profile.has("first_name") ? profile.get("first_name").getTextValue() : null,
+ profile.has("last_name") ? profile.get("last_name").getTextValue() : null);
+ user.setEmail(profile.has("email") ? profile.get("email").getTextValue() : null);
return user;
} catch (Exception e) {
diff --git a/social/github/pom.xml b/social/github/pom.xml
index e8dc767d31..0c55002c6e 100755
--- a/social/github/pom.xml
+++ b/social/github/pom.xml
@@ -14,16 +14,16 @@
-
- org.json
- json
- provided
-
org.keycloak
keycloak-social-core
${project.version}
provided
+
+ org.codehaus.jackson
+ jackson-mapper-asl
+ provided
+
diff --git a/social/github/src/main/java/org/keycloak/social/github/GitHubProvider.java b/social/github/src/main/java/org/keycloak/social/github/GitHubProvider.java
index 95c1067e91..8e25bf4932 100755
--- a/social/github/src/main/java/org/keycloak/social/github/GitHubProvider.java
+++ b/social/github/src/main/java/org/keycloak/social/github/GitHubProvider.java
@@ -1,9 +1,7 @@
package org.keycloak.social.github;
-import org.json.JSONObject;
+import org.codehaus.jackson.JsonNode;
import org.keycloak.social.AbstractOAuth2Provider;
-import org.keycloak.social.AuthRequest;
-import org.keycloak.social.SocialProviderConfig;
import org.keycloak.social.SocialProviderException;
import org.keycloak.social.SocialUser;
import org.keycloak.social.utils.SimpleHttp;
@@ -50,11 +48,11 @@ public class GitHubProvider extends AbstractOAuth2Provider {
@Override
protected SocialUser getProfile(String accessToken) throws SocialProviderException {
try {
- JSONObject profile = SimpleHttp.doGet(PROFILE_URL).header("Authorization", "Bearer " + accessToken).asJson();
+ JsonNode profile = SimpleHttp.doGet(PROFILE_URL).header("Authorization", "Bearer " + accessToken).asJson();
- SocialUser user = new SocialUser(profile.get("id").toString(), profile.getString("login"));
- user.setName(profile.optString("name"));
- user.setEmail(profile.optString("email"));
+ SocialUser user = new SocialUser(profile.get("id").toString(), profile.get("login").getTextValue());
+ user.setName(profile.has("name") ? profile.get("name").getTextValue() : null);
+ user.setEmail(profile.has("email") ? profile.get("email").getTextValue() : null);
return user;
} catch (Exception e) {
diff --git a/social/google/pom.xml b/social/google/pom.xml
index c575a86985..ae6922a6b8 100755
--- a/social/google/pom.xml
+++ b/social/google/pom.xml
@@ -14,16 +14,16 @@
-
- org.json
- json
- provided
-
org.keycloak
keycloak-social-core
${project.version}
provided
+
+ org.codehaus.jackson
+ jackson-mapper-asl
+ provided
+
diff --git a/social/google/src/main/java/org/keycloak/social/google/GoogleProvider.java b/social/google/src/main/java/org/keycloak/social/google/GoogleProvider.java
index ab3d8f47ea..cd87d5722c 100755
--- a/social/google/src/main/java/org/keycloak/social/google/GoogleProvider.java
+++ b/social/google/src/main/java/org/keycloak/social/google/GoogleProvider.java
@@ -21,11 +21,11 @@
*/
package org.keycloak.social.google;
-import org.json.JSONObject;
+import org.codehaus.jackson.JsonNode;
import org.keycloak.social.AbstractOAuth2Provider;
-import org.keycloak.social.utils.SimpleHttp;
import org.keycloak.social.SocialProviderException;
import org.keycloak.social.SocialUser;
+import org.keycloak.social.utils.SimpleHttp;
/**
* @author Stian Thorgersen
@@ -69,11 +69,12 @@ public class GoogleProvider extends AbstractOAuth2Provider {
@Override
protected SocialUser getProfile(String accessToken) throws SocialProviderException {
try {
- JSONObject profile = SimpleHttp.doGet(PROFILE_URL).header("Authorization", "Bearer " + accessToken).asJson();
+ JsonNode profile = SimpleHttp.doGet(PROFILE_URL).header("Authorization", "Bearer " + accessToken).asJson();
- SocialUser user = new SocialUser(profile.getString("sub"), profile.getString("email"));
- user.setName(profile.optString("given_name"), profile.optString("family_name"));
- user.setEmail(profile.optString("email"));
+ SocialUser user = new SocialUser(profile.get("sub").getTextValue(), profile.get("email").getTextValue());
+ user.setName(profile.has("given_name") ? profile.get("given_name").getTextValue() : null,
+ profile.has("family_name") ? profile.get("family_name").getTextValue() : null);
+ user.setEmail(profile.has("email") ? profile.get("email").getTextValue() : null);
return user;
} catch (Exception e) {
diff --git a/social/twitter/pom.xml b/social/twitter/pom.xml
index 0511193976..65b976cc69 100755
--- a/social/twitter/pom.xml
+++ b/social/twitter/pom.xml
@@ -20,12 +20,6 @@
${project.version}
provided
-
-
- org.json
- json
- provided
-
org.twitter4j
twitter4j-core