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] Expermenting with a google button
Date Thu, 25 Jun 2015 13:24:05 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 0a91c7b36 -> 557dc292f


[CXF-5607] Expermenting with a google button


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

Branch: refs/heads/master
Commit: 557dc292f63176ba971ebc8c8e23e1fb74c5c4a1
Parents: 0a91c7b
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu Jun 25 14:23:51 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu Jun 25 14:23:51 2015 +0100

----------------------------------------------------------------------
 .../release/samples/jax_rs/big_query/pom.xml    |  2 +-
 .../main/webapp/WEB-INF/applicationContext.xml  |  2 +
 .../src/main/webapp/googlePlusSignIn.html       | 21 +++++++
 .../src/main/webapp/googlePlusSignInFlow.html   | 59 ++++++++++++++++++++
 .../jax_rs/big_query/src/main/webapp/index.html | 59 --------------------
 .../oidc/rp/OidcRpAuthenticationService.java    | 17 ++++--
 6 files changed, 94 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/557dc292/distribution/src/main/release/samples/jax_rs/big_query/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/big_query/pom.xml b/distribution/src/main/release/samples/jax_rs/big_query/pom.xml
index 22d273a..de9f5db 100644
--- a/distribution/src/main/release/samples/jax_rs/big_query/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/big_query/pom.xml
@@ -103,7 +103,7 @@
                             <filtering>true</filtering>
                             <includes>
                                 <include>**/applicationContext.xml</include>
-                                <include>**/index.html</include>
+                                <include>**/googlePlusSignIn.html</include>
                             </includes>
                         </resource>
                     </webResources>

http://git-wip-us.apache.org/repos/asf/cxf/blob/557dc292/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 9da7e37..528aa50 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,8 @@
      <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="idTokenValidator" ref="userInfoClient"/>
+         <property name="consumer" ref="consumer"/>
      </bean>
      
      <jaxrs:server id="oidcRpServer" address="/oidc">

http://git-wip-us.apache.org/repos/asf/cxf/blob/557dc292/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
new file mode 100644
index 0000000..72e9567
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/googlePlusSignIn.html
@@ -0,0 +1,21 @@
+<html lang="en">
+  <head>
+    <meta name="google-signin-scope" content="profile email">
+    <meta name="google-signin-client_id" content="${client_id}">
+    <script src="https://apis.google.com/js/platform.js" async defer></script>
+  </head>
+  <body>
+    <div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
+    <script>
+      function onSignIn(googleUser) {
+        var id_token = googleUser.getAuthResponse().id_token;
+        var xhr = new XMLHttpRequest();
+        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>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/557dc292/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/googlePlusSignInFlow.html
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/googlePlusSignInFlow.html
b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/googlePlusSignInFlow.html
new file mode 100644
index 0000000..0f128ff
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/googlePlusSignInFlow.html
@@ -0,0 +1,59 @@
+<html itemscope itemtype="http://schema.org/Article">
+<head>
+  <!-- BEGIN Pre-requisites -->
+  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
+  </script>
+  <script src="https://apis.google.com/js/client:platform.js?onload=start" async defer>
+  </script>
+  <!-- END Pre-requisites -->
+</head>
+<body>
+<div id="signinButton">
+  <span class="g-signin"
+    data-scope="https://www.googleapis.com/auth/plus.login"
+    data-clientid="${client_id}"
+    data-redirecturi="postmessage"
+    data-accesstype="offline"
+    data-cookiepolicy="single_host_origin"
+    data-callback="signInCallback">
+  </span>
+</div>
+<div id="result"></div>
+<script>
+function signInCallback(authResult) {
+  if (authResult['code']) {
+
+    // Hide the sign-in button now that the user is authorized, for example:
+    $('#signinButton').attr('style', 'display: none');
+
+    // Send the code to the server
+    $.ajax({
+      type: 'POST',
+      url: 'service/search',
+      contentType: 'application/octet-stream; charset=utf-8',
+      success: function(result) {
+        // Handle or verify the server response if necessary.
+        // Prints the list of people that the user has allowed the app to know
+        // to the console.
+        console.log(result);
+        //if (result['profile'] && result['people']){
+        //  $('#results').html('Hello ' + result['profile']['displayName'] + '. You successfully
made a server side call to people.get and people.list');
+        //} else {
+        //  $('#results').html('Failed to make a server-side call. Check your configuration
and console.');
+        //}
+      },
+      processData: false,
+      data: authResult['code']
+    });
+  } else if (authResult['error']) {
+    // There was an error.
+    // Possible error codes:
+    //   "access_denied" - User denied access to your app
+    //   "immediate_failed" - Could not automatially log in the user
+    // console.log('There was an error: ' + authResult['error']);
+  }
+}
+</script>
+</body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/557dc292/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/index.html
b/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/index.html
deleted file mode 100644
index 0f128ff..0000000
--- a/distribution/src/main/release/samples/jax_rs/big_query/src/main/webapp/index.html
+++ /dev/null
@@ -1,59 +0,0 @@
-<html itemscope itemtype="http://schema.org/Article">
-<head>
-  <!-- BEGIN Pre-requisites -->
-  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
-  </script>
-  <script src="https://apis.google.com/js/client:platform.js?onload=start" async defer>
-  </script>
-  <!-- END Pre-requisites -->
-</head>
-<body>
-<div id="signinButton">
-  <span class="g-signin"
-    data-scope="https://www.googleapis.com/auth/plus.login"
-    data-clientid="${client_id}"
-    data-redirecturi="postmessage"
-    data-accesstype="offline"
-    data-cookiepolicy="single_host_origin"
-    data-callback="signInCallback">
-  </span>
-</div>
-<div id="result"></div>
-<script>
-function signInCallback(authResult) {
-  if (authResult['code']) {
-
-    // Hide the sign-in button now that the user is authorized, for example:
-    $('#signinButton').attr('style', 'display: none');
-
-    // Send the code to the server
-    $.ajax({
-      type: 'POST',
-      url: 'service/search',
-      contentType: 'application/octet-stream; charset=utf-8',
-      success: function(result) {
-        // Handle or verify the server response if necessary.
-        // Prints the list of people that the user has allowed the app to know
-        // to the console.
-        console.log(result);
-        //if (result['profile'] && result['people']){
-        //  $('#results').html('Hello ' + result['profile']['displayName'] + '. You successfully
made a server side call to people.get and people.list');
-        //} else {
-        //  $('#results').html('Failed to make a server-side call. Check your configuration
and console.');
-        //}
-      },
-      processData: false,
-      data: authResult['code']
-    });
-  } else if (authResult['error']) {
-    // There was an error.
-    // Possible error codes:
-    //   "access_denied" - User denied access to your app
-    //   "immediate_failed" - Could not automatially log in the user
-    // console.log('There was an error: ' + authResult['error']);
-  }
-}
-</script>
-</body>
-</html>
-

http://git-wip-us.apache.org/repos/asf/cxf/blob/557dc292/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 f7001b7..70a7224 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
@@ -41,20 +41,20 @@ public class OidcRpAuthenticationService {
     private String tokenFormParameter = "idtoken"; 
     @Context
     private MessageContext mc; 
-    private UserInfoClient userInfoClient;
+    private IdTokenValidator idTokenValidator;
     private Consumer consumer;
     
-    public void setUserInfoClient(UserInfoClient userInfoClient) {
-        this.userInfoClient = userInfoClient;
+    public void setIdTokenValidator(IdTokenValidator validator) {
+        this.idTokenValidator = validator;
     }
     
     @POST
-    @Path("complete")
+    @Path("signin")
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     public Response completeScriptAuthentication(MultivaluedMap<String, String> map)
{
         String idTokenParamValue = map.getFirst(tokenFormParameter);
         OidcClientTokenContextImpl ctx = new OidcClientTokenContextImpl();
-        ctx.setIdToken(userInfoClient.getIdToken(idTokenParamValue, consumer.getKey()));
+        ctx.setIdToken(idTokenValidator.getIdToken(idTokenParamValue, consumer.getKey()));
         return completeAuthentication(ctx);   
     }
     
@@ -63,7 +63,8 @@ public class OidcRpAuthenticationService {
     public Response completeAuthentication(@Context OidcClientTokenContext oidcContext) {
         stateManager.setClientTokenContext(mc, oidcContext);
         URI redirectUri = null;
-        String location = oidcContext.getState().getFirst("state");
+        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();
@@ -84,4 +85,8 @@ public class OidcRpAuthenticationService {
     public void setTokenFormParameter(String tokenFormParameter) {
         this.tokenFormParameter = tokenFormParameter;
     }
+
+    public void setConsumer(Consumer consumer) {
+        this.consumer = consumer;
+    }
 }


Mime
View raw message