Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-demo-single
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gic_demo
gic-demo-single
Commits
c0c18634
Commit
c0c18634
authored
Jun 19, 2019
by
朱瑞泽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
暂定
parent
3624097a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
AuthcenterTestController.java
.../demo/single/web/controller/AuthcenterTestController.java
+23
-4
GicAuthcenterTest.java
...o-single-web/src/test/java/com/gic/GicAuthcenterTest.java
+1
-2
No files found.
gic-demo-single-web/src/main/java/com/gic/demo/single/web/controller/AuthcenterTestController.java
View file @
c0c18634
...
...
@@ -3,10 +3,15 @@ package com.gic.demo.single.web.controller;
import
com.alibaba.fastjson.JSON
;
import
com.gic.authcenter.sdk.GicAuthcenterManager
;
import
com.gic.authcenter.sdk.exception.NoTokenCacheException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
/**
* GIC 认证中心 SDK 测试
*
...
...
@@ -15,15 +20,29 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public
class
AuthcenterTestController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Autowired
private
GicAuthcenterManager
gicAuthcenterManager
;
/**
* @return 获取认证 url 用于前端访问
* @return 获取 oauth2 登录 url
*/
@RequestMapping
(
"/get-oauth2-login-url"
)
public
String
getOAuth2LoginUrl
()
{
return
gicAuthcenterManager
.
getAuthorizeUrl
();
}
/**
* oauth2 登录
*/
@RequestMapping
(
"/get-authcenter-url"
)
public
String
getAuthcenterUrl
()
{
return
JSON
.
toJSONString
(
gicAuthcenterManager
.
getAuthorizeUrl
());
@RequestMapping
(
"/oauth2-login"
)
public
void
oauth2Login
(
HttpServletResponse
response
)
{
try
{
response
.
sendRedirect
(
gicAuthcenterManager
.
getAuthorizeUrl
());
}
catch
(
IOException
e
)
{
logger
.
warn
(
e
.
getMessage
());
}
}
/**
...
...
gic-demo-single-web/src/test/java/com/gic/GicAuthcenterTest.java
View file @
c0c18634
...
...
@@ -14,10 +14,9 @@ public class GicAuthcenterTest {
GicAuthcenter
gicAuthcenter
=
GicAuthcenter
.
build
(
GicAuthcenterConfig
.
build
(
"gicplatformid"
,
"gicplatformsecret"
,
"http://127.0.0.1:9002/gic-demo-single-web/demo/get-access-token"
,
"https://www.gicdev.com/gic-authcenter"
));
System
.
out
.
println
(
gicAuthcenter
.
getAuthorizeUrl
());
System
.
out
.
println
(
gicAuthcenter
.
getAuthorizeUrl
(
"http://127.0.0.1:9002/gic-demo-single-web/demo/get-access-token"
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment