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-5607] Trying to finalize the demo work for now
Date Fri, 26 Jun 2015 16:30:14 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 321d87279 -> 6d44bab6a


[CXF-5607] Trying to finalize the demo work for now


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

Branch: refs/heads/master
Commit: 6d44bab6a03832c3fb73b57ae68edc5bda2029ea
Parents: 321d872
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Jun 26 17:29:46 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Jun 26 17:29:46 2015 +0100

----------------------------------------------------------------------
 .../main/webapp/WEB-INF/applicationContext.xml  |  6 +++++
 .../webapp/forms/oidcClientTokenContext.jsp     | 12 ++++++++++
 .../src/main/webapp/googlePlusSignIn.html       |  5 ++--
 .../oidc/rp/OidcRpAuthenticationService.java    | 25 +++++++++++++-------
 4 files changed, 38 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6d44bab6/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/WEB-INF/applicationContext.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/WEB-INF/applicationContext.xml
b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/WEB-INF/applicationContext.xml
index b6498c6..b004067 100644
--- a/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/WEB-INF/applicationContext.xml
@@ -130,6 +130,9 @@
      <bean id="oidcRpService" class="org.apache.cxf.rs.security.oidc.rp.OidcRpAuthenticationService">
          <property name="stateManager" ref="stateManager"/>
          <property name="defaultLocation" value="/forms/startSearch.jsp"/>
+         <!--
+         <property name="useRedirect" value="false"/>
+         -->
      </bean>
      
      <jaxrs:server id="oidcRpServer" address="/oidc">
@@ -142,6 +145,9 @@
            -->
            <ref bean="rpOidcTokenFilter"/>
            <!--
+           <ref bean="searchView"/>
+           -->
+           <!--
            <bean class="org.apache.cxf.rs.security.oauth2.client.ClientTokenContextProvider"/>
            -->
            <bean class="org.apache.cxf.rs.security.oidc.rp.OidcIdTokenProvider"/>

http://git-wip-us.apache.org/repos/asf/cxf/blob/6d44bab6/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/forms/oidcClientTokenContext.jsp
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/forms/oidcClientTokenContext.jsp
b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/forms/oidcClientTokenContext.jsp
new file mode 100644
index 0000000..58d183d
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/forms/oidcClientTokenContext.jsp
@@ -0,0 +1,12 @@
+<%@ page import="javax.servlet.http.HttpServletRequest, org.apache.cxf.rs.security.oidc.rp.OidcClientTokenContext"
%>
+
+<%
+    OidcClientTokenContext context = (OidcClientTokenContext) request.getAttribute("oidcclienttokencontext");
+%>
+<html>
+<body>
+<div class="padded">
+<h2>Welcome, <%= context.getIdToken().getClaim("email") %></h2>
+</div>
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/cxf/blob/6d44bab6/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/googlePlusSignIn.html
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/googlePlusSignIn.html
b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/googlePlusSignIn.html
index 72e9567..59db61a 100644
--- a/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/googlePlusSignIn.html
+++ b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/googlePlusSignIn.html
@@ -10,11 +10,12 @@
       function onSignIn(googleUser) {
         var id_token = googleUser.getAuthResponse().id_token;
         var xhr = new XMLHttpRequest();
+        xhr.onload = function() {
+          alert(xhr.response);
+        }
         xhr.open('POST', 'https://localhost:8080/bigquery/service/oidc/rp/signin');
         xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
         xhr.send('idtoken=' + id_token);
-        var location = xhr.getResponseHeader('Location');
-        xhr.open('GET', location);
       };
     </script>
   </body>

http://git-wip-us.apache.org/repos/asf/cxf/blob/6d44bab6/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcRpAuthenticationService.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcRpAuthenticationService.java
b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcRpAuthenticationService.java
index 1c4eebe..74cccf0 100644
--- a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcRpAuthenticationService.java
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcRpAuthenticationService.java
@@ -38,6 +38,7 @@ import org.apache.cxf.rs.security.oidc.common.IdToken;
 public class OidcRpAuthenticationService {
     private ClientTokenContextManager stateManager;
     private String defaultLocation;
+    private boolean useRedirect;
     @Context
     private MessageContext mc; 
     
@@ -54,16 +55,20 @@ public class OidcRpAuthenticationService {
     @Path("complete")
     public Response completeAuthentication(@Context OidcClientTokenContext oidcContext) {
         stateManager.setClientTokenContext(mc, oidcContext);
-        URI redirectUri = null;
-        MultivaluedMap<String, String> state = oidcContext.getState();
-        String location = state != null ? state.getFirst("state") : null;
-        if (location == null) {
-            String basePath = (String)mc.get("http.base.path");
-            redirectUri = UriBuilder.fromUri(basePath).path(defaultLocation).build();
+        if (useRedirect) {
+            URI redirectUri = null;
+            MultivaluedMap<String, String> state = oidcContext.getState();
+            String location = state != null ? state.getFirst("state") : null;
+            if (location == null) {
+                String basePath = (String)mc.get("http.base.path");
+                redirectUri = UriBuilder.fromUri(basePath).path(defaultLocation).build();
+            } else {
+                redirectUri = URI.create(location);
+            }
+            return Response.seeOther(redirectUri).build();
         } else {
-            redirectUri = URI.create(location);
+            return Response.ok(oidcContext).build();
         }
-        return Response.seeOther(redirectUri).build();
     }
 
     public void setDefaultLocation(String defaultLocation) {
@@ -73,4 +78,8 @@ public class OidcRpAuthenticationService {
     public void setStateManager(ClientTokenContextManager stateManager) {
         this.stateManager = stateManager;
     }
+
+    public void setUseRedirect(boolean useRedirect) {
+        this.useRedirect = useRedirect;
+    }
 }


Mime
View raw message