oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asa...@apache.org
Subject svn commit: r1468937 - in /oltu/trunk/demos/client-demo/src/main: java/org/apache/oltu/oauth2/client/demo/controller/MainController.java java/org/apache/oltu/oauth2/client/demo/model/OAuthParams.java webapp/WEB-INF/views/index.jsp
Date Wed, 17 Apr 2013 14:37:28 GMT
Author: asanso
Date: Wed Apr 17 14:37:27 2013
New Revision: 1468937

URL: http://svn.apache.org/r1468937
Log:
OLTU-99 - Add a decode JWT  to the demo :

* added simple decoder application in the index page

Modified:
    oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/controller/MainController.java
    oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/model/OAuthParams.java
    oltu/trunk/demos/client-demo/src/main/webapp/WEB-INF/views/index.jsp

Modified: oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/controller/MainController.java
URL: http://svn.apache.org/viewvc/oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/controller/MainController.java?rev=1468937&r1=1468936&r2=1468937&view=diff
==============================================================================
--- oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/controller/MainController.java
(original)
+++ oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/controller/MainController.java
Wed Apr 17 14:37:27 2013
@@ -30,6 +30,7 @@ import org.apache.oltu.oauth2.client.dem
 import org.apache.oltu.oauth2.client.demo.model.OAuthParams;
 import org.apache.oltu.oauth2.client.demo.model.OAuthRegParams;
 import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
+import org.apache.oltu.oauth2.jwt.JWTUtil;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -98,4 +99,23 @@ public class MainController {
 
         return new ModelAndView("index");
     }
+    
+    @RequestMapping("/decode")
+    public ModelAndView decode(@ModelAttribute("oauthParams") OAuthParams oauthParams){
+    	
+    	try{
+    	
+    		String jwt = oauthParams.getJwt();
+     	
+    		oauthParams.setHeader(JWTUtil.getHeader(jwt));
+    		oauthParams.setClaimsSet(JWTUtil.getClaimsSet(jwt));
+    	} catch (Exception e){
+    		oauthParams.setErrorMessage(
+                    "Error while decoding the token: " + e);
+    	}
+    	
+    	return new ModelAndView("index");
+	}
+    
+    
 }

Modified: oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/model/OAuthParams.java
URL: http://svn.apache.org/viewvc/oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/model/OAuthParams.java?rev=1468937&r1=1468936&r2=1468937&view=diff
==============================================================================
--- oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/model/OAuthParams.java
(original)
+++ oltu/trunk/demos/client-demo/src/main/java/org/apache/oltu/oauth2/client/demo/model/OAuthParams.java
Wed Apr 17 14:37:27 2013
@@ -47,6 +47,7 @@ public class OAuthParams {
     private String idToken;
     private String header;
     private String claimsSet;
+    private String jwt;
 
     private String errorMessage;
 
@@ -205,4 +206,12 @@ public class OAuthParams {
 	public void setClaimsSet(String claimsSet) {
 		this.claimsSet = claimsSet;
 	}
+
+	public String getJwt() {
+		return jwt;
+	}
+
+	public void setJwt(String jwt) {
+		this.jwt = jwt;
+	}
 }

Modified: oltu/trunk/demos/client-demo/src/main/webapp/WEB-INF/views/index.jsp
URL: http://svn.apache.org/viewvc/oltu/trunk/demos/client-demo/src/main/webapp/WEB-INF/views/index.jsp?rev=1468937&r1=1468936&r2=1468937&view=diff
==============================================================================
--- oltu/trunk/demos/client-demo/src/main/webapp/WEB-INF/views/index.jsp (original)
+++ oltu/trunk/demos/client-demo/src/main/webapp/WEB-INF/views/index.jsp Wed Apr 17 14:37:27
2013
@@ -45,5 +45,37 @@
 <a href="/main/github">Github</a>
 <a href="/main/gowalla">Gowalla</a>
 
+
+<h2>JWT decoder</h2>
+
+<c:if test="${!empty oauthParams.errorMessage}">
+    <p><font color="red">${oauthParams.errorMessage}</font></p>
+</c:if>
+
+<form:form commandName="oauthParams" action="/decode">
+	<table>
+		
+		<tr>
+            <td>JWT</td>
+            <td><form:input size="170" path="jwt" /></td>
+        </tr>
+        <tr>
+            <td colspan="2">
+                <form:hidden path="application"/>
+                <input type="submit" value="Decode"/>
+            </td>
+        </tr>
+        <tr>
+            <td>Header:</td>
+            <td><textarea rows="15" cols="80" disabled="true">${oauthParams.header}</textarea></td>
+        </tr>
+        <tr>
+            <td>Claims Set:</td>
+            <td><textarea rows="15" cols="80" disabled="true">${oauthParams.claimsSet}</textarea></td>
+        </tr>
+  	</table>
+</form:form>
+
+
 </body>
 </html>



Mime
View raw message