oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asa...@apache.org
Subject svn commit: r1480644 - in /oltu/trunk: demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/controller/ openid-connect/client/src/main/java/org/apache/oltu/openidconnect/ openid-connect/client/src/main/java/org/apache/oltu/openidconnect/c...
Date Thu, 09 May 2013 14:08:13 GMT
Author: asanso
Date: Thu May  9 14:08:12 2013
New Revision: 1480644

URL: http://svn.apache.org/r1480644
Log:
OLTU-78 - Implement Plaintext JWT :
*  adapt the client demo to the latest changes

Added:
    oltu/trunk/openid-connect/client/src/main/java/org/apache/oltu/openidconnect/OpenIdConnect.java
Modified:
    oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/controller/TokenController.java
    oltu/trunk/openid-connect/client/src/main/java/org/apache/oltu/openidconnect/client/response/OpenIdConnectResponse.java

Modified: oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/controller/TokenController.java
URL: http://svn.apache.org/viewvc/oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/controller/TokenController.java?rev=1480644&r1=1480643&r2=1480644&view=diff
==============================================================================
--- oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/controller/TokenController.java
(original)
+++ oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/controller/TokenController.java
Thu May  9 14:08:12 2013
@@ -22,6 +22,7 @@
 package org.apache.oltu.oauth2.client.demo.controller;
 
 import java.io.IOException;
+import java.net.URL;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -37,7 +38,8 @@ import org.apache.oltu.oauth2.client.res
 import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
 import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
 import org.apache.oltu.oauth2.common.message.types.GrantType;
-import org.apache.oltu.oauth2.jwt.JWTUtil;
+import org.apache.oltu.oauth2.jwt.JWT;
+import org.apache.oltu.oauth2.jwt.JWTUtils;
 import org.apache.oltu.openidconnect.client.response.OpenIdConnectResponse;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.ModelAttribute;
@@ -92,11 +94,14 @@ public class TokenController {
             oauthParams.setRefreshToken(Utils.isIssued(oauthResponse.getRefreshToken()));
             
             if (Utils.GOOGLE.equalsIgnoreCase(app)){
-            	String idToken = ((OpenIdConnectResponse)oauthResponse).getIdToken();
             	
+            	OpenIdConnectResponse openIdConnectResponse = ((OpenIdConnectResponse)oauthResponse);
           	
+            	String idToken = openIdConnectResponse.getIdToken();  
             	oauthParams.setIdToken(idToken);
-            	oauthParams.setHeader(JWTUtil.getHeader(idToken));
-            	oauthParams.setClaimsSet(JWTUtil.getClaimsSet(idToken));
+            	
+            	JWT jwt = JWTUtils.parseJWT(idToken);
+            	oauthParams.setHeader(JWTUtils.toJsonString(jwt.getHeader()));
+            	oauthParams.setClaimsSet(JWTUtils.toJsonString(jwt.getClaimsSet()));
             	
             }
 

Added: oltu/trunk/openid-connect/client/src/main/java/org/apache/oltu/openidconnect/OpenIdConnect.java
URL: http://svn.apache.org/viewvc/oltu/trunk/openid-connect/client/src/main/java/org/apache/oltu/openidconnect/OpenIdConnect.java?rev=1480644&view=auto
==============================================================================
--- oltu/trunk/openid-connect/client/src/main/java/org/apache/oltu/openidconnect/OpenIdConnect.java
(added)
+++ oltu/trunk/openid-connect/client/src/main/java/org/apache/oltu/openidconnect/OpenIdConnect.java
Thu May  9 14:08:12 2013
@@ -0,0 +1,26 @@
+/*
+ * 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.oltu.openidconnect;
+
+/**
+ * Class containing all the basic constants of the OpenId
+ * connect specification
+ *
+ */
+public class OpenIdConnect {
+	public static final String ID_TOKEN= "id_token";
+}

Modified: oltu/trunk/openid-connect/client/src/main/java/org/apache/oltu/openidconnect/client/response/OpenIdConnectResponse.java
URL: http://svn.apache.org/viewvc/oltu/trunk/openid-connect/client/src/main/java/org/apache/oltu/openidconnect/client/response/OpenIdConnectResponse.java?rev=1480644&r1=1480643&r2=1480644&view=diff
==============================================================================
--- oltu/trunk/openid-connect/client/src/main/java/org/apache/oltu/openidconnect/client/response/OpenIdConnectResponse.java
(original)
+++ oltu/trunk/openid-connect/client/src/main/java/org/apache/oltu/openidconnect/client/response/OpenIdConnectResponse.java
Thu May  9 14:08:12 2013
@@ -15,17 +15,33 @@
  * limitations under the License.
  */
 package org.apache.oltu.openidconnect.client.response;
-
+ 
 import org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse;
-import org.apache.oltu.openidconnect.common.OpenIdConnect;
-
+import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
+import org.apache.oltu.openidconnect.OpenIdConnect;
+ 
 /**
  * 
  *
  */
-public class OpenIdConnectResponse extends OAuthJSONAccessTokenResponse{
+public class OpenIdConnectResponse extends OAuthJSONAccessTokenResponse {
+
+	protected String idToken;
+ 
+	@Override
+	protected void init(String body, String contentType, int responseCode)
+	throws OAuthProblemException {
+		super.init(body, contentType, responseCode);
+		setIdToken(getParam(OpenIdConnect.ID_TOKEN));
+	}
+
+	public void setIdToken(String idToken) throws OAuthProblemException {
+		this.idToken = idToken;
+	}
+	
+	public String getIdToken(){
+		return idToken;
+	}
 	
-    public String getIdToken() {
-        return getParam(OpenIdConnect.ID_TOKEN);
-    }
+ 
 }



Mime
View raw message