cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject cxf-fediz git commit: Checkstyle fix
Date Wed, 19 Apr 2017 09:35:28 GMT
Repository: cxf-fediz
Updated Branches:
  refs/heads/1.3.x-fixes c90528742 -> 8aeeed22a


Checkstyle fix


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

Branch: refs/heads/1.3.x-fixes
Commit: 8aeeed22aa5b1e9f70c9a0148b037f104aa62ccf
Parents: c905287
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Wed Apr 19 10:35:20 2017 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Wed Apr 19 10:35:20 2017 +0100

----------------------------------------------------------------------
 .../oidc/clients/ClientRegistrationService.java | 40 ++++++++++++--------
 1 file changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/8aeeed22/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
index f2860eb..50b38ad 100644
--- a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/clients/ClientRegistrationService.java
@@ -256,7 +256,6 @@ public class ClientRegistrationService {
         return null;
     }
 
-    //CHECKSTYLE:OFF
     @POST
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     @Produces(MediaType.TEXT_HTML)
@@ -268,22 +267,11 @@ public class ClientRegistrationService {
                                  @FormParam("client_homeRealm") String homeRealm,
                                  @FormParam("client_csrfToken") String csrfToken
     ) {
-        // CSRF
-        if (!checkCSRFToken(csrfToken)) {
-            return invalidRegistrationResponse("Invalid CSRF Token");
+        InvalidRegistration invalidRegistration = checkForm(csrfToken, appName, appType);
+        if (invalidRegistration != null) {
+            return Response.ok(invalidRegistration).build();
         }
 
-        // Client Name
-        if (StringUtils.isEmpty(appName)) {
-            return invalidRegistrationResponse("The client name must not be empty");
-        }
-        // Client Type
-        if (StringUtils.isEmpty(appType)) {
-            return invalidRegistrationResponse("The client type must not be empty");
-        }
-        if (!("confidential".equals(appType) || "public".equals(appType))) {
-            return invalidRegistrationResponse("An invalid client type was specified: " +
appType);
-        }
         // Client ID
         String clientId = generateClientId();
         boolean isConfidential = "confidential".equals(appType);
@@ -358,7 +346,27 @@ public class ClientRegistrationService {
 
         return Response.ok(registerNewClient(newClient)).build();
     }
-    //CHECKSTYLE:ON
+
+    private InvalidRegistration checkForm(String csrfToken, String appName, String appType)
{
+        // CSRF
+        if (!checkCSRFToken(csrfToken)) {
+            return new InvalidRegistration("Invalid CSRF Token");
+        }
+
+        // Client Name
+        if (StringUtils.isEmpty(appName)) {
+            return new InvalidRegistration("The client name must not be empty");
+        }
+        // Client Type
+        if (StringUtils.isEmpty(appType)) {
+            return new InvalidRegistration("The client type must not be empty");
+        }
+        if (!("confidential".equals(appType) || "public".equals(appType))) {
+            return new InvalidRegistration("An invalid client type was specified: " + appType);
+        }
+
+        return null;
+    }
 
     private Response invalidRegistrationResponse(String error) {
         return Response.ok(new InvalidRegistration(error)).build();


Mime
View raw message