Skip to content

Commit

Permalink
add ch06
Browse files Browse the repository at this point in the history
  • Loading branch information
xindongbook committed Jun 14, 2020
1 parent 9f6ca71 commit 2f0e35d
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 215 deletions.
43 changes: 0 additions & 43 deletions src/com/my/app/AppServlet.java

This file was deleted.

126 changes: 0 additions & 126 deletions src/com/my/oauth/OauthServlet.java

This file was deleted.

32 changes: 0 additions & 32 deletions src/com/my/oauth/Servlet.java

This file was deleted.

4 changes: 2 additions & 2 deletions src/com/oauth/ch03/AppIndexServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

/**
* **
* 使用此类来模拟第三方软件的首页
* http://localhost:8080/AppIndexServlet-ch03
* 使用此类来模拟【第三方软件的首页】
* 浏览器输入 http://localhost:8080/AppIndexServlet-ch03
*/
@WebServlet("/AppIndexServlet-ch03")
public class AppIndexServlet extends HttpServlet {
Expand Down
8 changes: 6 additions & 2 deletions src/com/oauth/ch03/AppServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
import java.util.HashMap;
import java.util.Map;


/**
* **
* 使用此类来模拟【第三方软件的Server端】
*
*/
@WebServlet("/AppServlet-ch03")
public class AppServlet extends HttpServlet {



String oauthURl="http://localhost:8081/OauthServlet-ch03";
String protectedURl="http://localhost:8081/ProtectedServlet-ch03";

Expand Down
5 changes: 5 additions & 0 deletions src/com/oauth/ch03/OauthServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
import java.util.Random;
import java.util.UUID;

/**
* **
* 使用此类来模拟【授权服务】
*/

@WebServlet("/OauthServlet-ch03")
public class OauthServlet extends HttpServlet {

Expand Down
9 changes: 5 additions & 4 deletions src/com/oauth/ch03/ProtectedServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
import java.util.HashMap;
import java.util.Map;


/**
* **
* 使用此类来模拟【受保护资源服务】
*/
@WebServlet("/ProtectedServlet-ch03")
public class ProtectedServlet extends HttpServlet {





protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

//省略验证代码
Expand Down
4 changes: 3 additions & 1 deletion src/com/oauth/ch04/JWTTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public static void main(String[] args) {
headerMap.put("alg", "HS256");

Map<String, Object> payloadMap = new HashMap<>();
payloadMap.put("sub", "USERTEST");
payloadMap.put("iss", "http://localhost:8081/");
payloadMap.put("sub", "XIAOMINGTEST");
payloadMap.put("aud", "APPID_RABBIT");
payloadMap.put("exp", 1584105790703L);
payloadMap.put("iat", 1584105948372L);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.oauth.ch02;
package com.oauth.ch06;

import com.my.util.URLParamsUtil;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.oauth.ch02;
package com.oauth.ch06;

import com.my.util.HttpURLClient;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.oauth.ch02;
package com.oauth.ch06;

import com.my.util.URLParamsUtil;

Expand Down
4 changes: 2 additions & 2 deletions src/com/oauth/ch09/OauthServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
tokenScopeMap.put(accessToken,codeScopeMap.get(code));//授权范围与访问令牌绑定

//GENATE ID TOKEN
String id_token=genrateIdToken(appId,"XIAOMINGTEST");
String id_token=genrateIdToken(appId,"XIAOMINGTEST");//模拟用户小明登录

response.getWriter().write(accessToken+"|"+id_token);

Expand All @@ -123,7 +123,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)


/**
* genrate id_token
* genrate
* @param appId
* @param user
* @return
Expand Down

0 comments on commit 2f0e35d

Please sign in to comment.