cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6686] Optimizing reading/writing the introspection response
Date Fri, 15 Jan 2016 16:40:28 GMT
Repository: cxf
Updated Branches:
  refs/heads/master a0f096bbb -> 79d6097a0


[CXF-6686] Optimizing reading/writing the introspection response


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/79d6097a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/79d6097a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/79d6097a

Branch: refs/heads/master
Commit: 79d6097a021b621ddd716e34323a6b0a308c6b04
Parents: a0f096b
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Fri Jan 15 16:39:22 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Fri Jan 15 16:39:22 2016 +0000

----------------------------------------------------------------------
 .../oauth2/provider/OAuthJSONProvider.java      | 100 ++++++++++---------
 1 file changed, 52 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/79d6097a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/OAuthJSONProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/OAuthJSONProvider.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/OAuthJSONProvider.java
index b84f9ff..fb02230 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/OAuthJSONProvider.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/OAuthJSONProvider.java
@@ -74,30 +74,32 @@ public class OAuthJSONProvider implements MessageBodyWriter<Object>,
         StringBuilder sb = new StringBuilder();
         sb.append("{");
         appendJsonPair(sb, "active", obj.isActive(), false);
-        if (obj.getClientId() != null) {
-            sb.append(",");
-            appendJsonPair(sb, OAuthConstants.CLIENT_ID, obj.getClientId());
-        }
-        if (obj.getUsername() != null) {
-            sb.append(",");
-            appendJsonPair(sb, "username", obj.getUsername());
-        }
-        if (obj.getTokenType() != null) {
-            sb.append(",");
-            appendJsonPair(sb, OAuthConstants.ACCESS_TOKEN_TYPE, obj.getTokenType());
-        }
-        if (obj.getScope() != null) {
+        if (obj.isActive()) {
+            if (obj.getClientId() != null) {
+                sb.append(",");
+                appendJsonPair(sb, OAuthConstants.CLIENT_ID, obj.getClientId());
+            }
+            if (obj.getUsername() != null) {
+                sb.append(",");
+                appendJsonPair(sb, "username", obj.getUsername());
+            }
+            if (obj.getTokenType() != null) {
+                sb.append(",");
+                appendJsonPair(sb, OAuthConstants.ACCESS_TOKEN_TYPE, obj.getTokenType());
+            }
+            if (obj.getScope() != null) {
+                sb.append(",");
+                appendJsonPair(sb, OAuthConstants.SCOPE, obj.getScope());
+            }
+            if (obj.getAud() != null) {
+                sb.append(",");
+                appendJsonPair(sb, "aud", obj.getAud());
+            }
             sb.append(",");
-            appendJsonPair(sb, OAuthConstants.SCOPE, obj.getScope());
-        }
-        if (obj.getAud() != null) {
+            appendJsonPair(sb, "iat", obj.getIat(), false);
             sb.append(",");
-            appendJsonPair(sb, "aud", obj.getAud());
+            appendJsonPair(sb, "exp", obj.getExp(), false);
         }
-        sb.append(",");
-        appendJsonPair(sb, "iat", obj.getIat(), false);
-        sb.append(",");
-        appendJsonPair(sb, "exp", obj.getExp(), false);
         sb.append("}");
         String result = sb.toString();
         os.write(result.getBytes(StandardCharsets.UTF_8));
@@ -198,33 +200,35 @@ public class OAuthJSONProvider implements MessageBodyWriter<Object>,
     private Object fromMapToTokenIntrospection(Map<String, String> params) {
         TokenIntrospection resp = new TokenIntrospection();
         resp.setActive(Boolean.valueOf(params.get("active")));
-        String clientId = params.get(OAuthConstants.CLIENT_ID);
-        if (clientId != null) {
-            resp.setClientId(clientId);
-        }
-        String username = params.get("username");
-        if (username != null) {
-            resp.setUsername(username);
-        }
-        String scope = params.get(OAuthConstants.SCOPE);
-        if (scope != null) {
-            resp.setScope(scope);
-        }
-        String tokenType = params.get(OAuthConstants.ACCESS_TOKEN_TYPE);
-        if (tokenType != null) {
-            resp.setTokenType(tokenType);
-        }
-        String aud = params.get("aud");
-        if (aud != null) {
-            resp.setAud(aud);
-        }
-        String iat = params.get("iat");
-        if (iat != null) {
-            resp.setIat(Long.valueOf(iat));
-        }
-        String exp = params.get("exp");
-        if (exp != null) {
-            resp.setExp(Long.valueOf(exp));
+        if (resp.isActive()) {
+            String clientId = params.get(OAuthConstants.CLIENT_ID);
+            if (clientId != null) {
+                resp.setClientId(clientId);
+            }
+            String username = params.get("username");
+            if (username != null) {
+                resp.setUsername(username);
+            }
+            String scope = params.get(OAuthConstants.SCOPE);
+            if (scope != null) {
+                resp.setScope(scope);
+            }
+            String tokenType = params.get(OAuthConstants.ACCESS_TOKEN_TYPE);
+            if (tokenType != null) {
+                resp.setTokenType(tokenType);
+            }
+            String aud = params.get("aud");
+            if (aud != null) {
+                resp.setAud(aud);
+            }
+            String iat = params.get("iat");
+            if (iat != null) {
+                resp.setIat(Long.valueOf(iat));
+            }
+            String exp = params.get("exp");
+            if (exp != null) {
+                resp.setExp(Long.valueOf(exp));
+            }
         }
         return resp;
     }


Mime
View raw message