You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2017/02/08 16:43:10 UTC

[1/2] cxf-fediz git commit: NPE guard

Repository: cxf-fediz
Updated Branches:
  refs/heads/master e8aec20af -> 2bcb3b328


NPE guard


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

Branch: refs/heads/master
Commit: 841f380b914848743db284adfefede0621c524c7
Parents: e8aec20
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Wed Feb 8 16:21:00 2017 +0000
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Wed Feb 8 16:21:00 2017 +0000

----------------------------------------------------------------------
 .../core/processor/FederationProcessorImpl.java | 31 +++++++++++---------
 1 file changed, 17 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/841f380b/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/FederationProcessorImpl.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/FederationProcessorImpl.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/FederationProcessorImpl.java
index fa8778e..88e8da1 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/FederationProcessorImpl.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/FederationProcessorImpl.java
@@ -574,14 +574,16 @@ public class FederationProcessorImpl extends AbstractFedizProcessor {
                     callback
                 });
                 Map<String, String> signInQueryMap = callback.getSignInQueryParamMap();
-                StringBuilder sbQuery = new StringBuilder();
-                for (Entry<String, String> entry : signInQueryMap.entrySet()) {
-                    if (sbQuery.length() > 0) {
-                        sbQuery.append("&");
+                if (signInQueryMap != null) {
+                    StringBuilder sbQuery = new StringBuilder();
+                    for (Entry<String, String> entry : signInQueryMap.entrySet()) {
+                        if (sbQuery.length() > 0) {
+                            sbQuery.append("&");
+                        }
+                        sbQuery.append(entry.getKey()).append('=').append(URLEncoder.encode(entry.getValue(), "UTF-8"));
                     }
-                    sbQuery.append(entry.getKey()).append('=').append(URLEncoder.encode(entry.getValue(), "UTF-8"));
+                    signInQuery = sbQuery.toString();
                 }
-                signInQuery = sbQuery.toString();
 
             }
         }
@@ -601,16 +603,17 @@ public class FederationProcessorImpl extends AbstractFedizProcessor {
                 frCB.handle(new Callback[] {
                     callback
                 });
-                Map<String, String> signInQueryMap = callback.getSignOutQueryParamMap();
-                StringBuilder sbQuery = new StringBuilder();
-                for (Entry<String, String> entry : signInQueryMap.entrySet()) {
-                    if (sbQuery.length() > 0) {
-                        sbQuery.append("&");
+                Map<String, String> signOutQueryMap = callback.getSignOutQueryParamMap();
+                if (signOutQueryMap != null) {
+                    StringBuilder sbQuery = new StringBuilder();
+                    for (Entry<String, String> entry : signOutQueryMap.entrySet()) {
+                        if (sbQuery.length() > 0) {
+                            sbQuery.append("&");
+                        }
+                        sbQuery.append(entry.getKey()).append('=').append(URLEncoder.encode(entry.getValue(), "UTF-8"));
                     }
-                    sbQuery.append(entry.getKey()).append('=').append(URLEncoder.encode(entry.getValue(), "UTF-8"));
+                    signOutQuery = sbQuery.toString();
                 }
-                signOutQuery = sbQuery.toString();
-    
             }
         }
         return signOutQuery;


[2/2] cxf-fediz git commit: Add SignOutQueryHandler

Posted by co...@apache.org.
Add SignOutQueryHandler


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

Branch: refs/heads/master
Commit: 2bcb3b328a9590983bd4d780d6bce8e4fbcd210b
Parents: 841f380
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Wed Feb 8 16:42:57 2017 +0000
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Wed Feb 8 16:42:57 2017 +0000

----------------------------------------------------------------------
 .../oidc/logout/SignoutQueryHandler.java        | 58 ++++++++++++++++++++
 1 file changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2bcb3b32/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/logout/SignoutQueryHandler.java
----------------------------------------------------------------------
diff --git a/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/logout/SignoutQueryHandler.java b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/logout/SignoutQueryHandler.java
new file mode 100644
index 0000000..89c7ffd
--- /dev/null
+++ b/services/oidc/src/main/java/org/apache/cxf/fediz/service/oidc/logout/SignoutQueryHandler.java
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.fediz.service.oidc.logout;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.cxf.fediz.core.spi.SignOutQueryCallback;
+import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants;
+
+/**
+ * Set the client_id on the signout request to the IdP. This is needed after we redirect to the "finalize" method of 
+ * the LogoutService.
+ */
+public class SignoutQueryHandler implements CallbackHandler {
+
+    @Override
+    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+        if (callbacks != null) {
+            for (Callback callback : callbacks) {
+                if (callback instanceof SignOutQueryCallback) {
+                    SignOutQueryCallback signOutQueryCallback = (SignOutQueryCallback)callback;
+                    HttpServletRequest request = signOutQueryCallback.getRequest();
+                    if (request != null && request.getParameter(OAuthConstants.CLIENT_ID) != null) {
+                        Map<String, String> signOutQueryMap = new HashMap<>();
+                        signOutQueryMap.put(OAuthConstants.CLIENT_ID, request.getParameter(OAuthConstants.CLIENT_ID));
+                        signOutQueryCallback.setSignOutQueryParamMap(signOutQueryMap);
+                    }
+                }
+            }
+        }
+    }
+
+
+}