Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yujianwangzivayy
MaxKey
提交
ed8a351a
MaxKey
项目概览
yujianwangzivayy
/
MaxKey
与 Fork 源项目一致
Fork自
MaxKey单点登录官方(MaxKeyTop) / MaxKey
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MaxKey
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ed8a351a
编写于
9月 09, 2020
作者:
MaxKey单点登录官方
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TicketGrantingTicketServices
上级
2a43b999
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
201 addition
and
16 deletion
+201
-16
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/CasBaseAuthorizeEndpoint.java
...g/maxkey/authz/cas/endpoint/CasBaseAuthorizeEndpoint.java
+5
-0
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/CasRestV1Endpoint.java
...java/org/maxkey/authz/cas/endpoint/CasRestV1Endpoint.java
+5
-5
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/InMemoryTicketGrantingTicketServices.java
.../ticket/service/InMemoryTicketGrantingTicketServices.java
+54
-0
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/InMemoryTicketServices.java
...z/cas/endpoint/ticket/service/InMemoryTicketServices.java
+7
-1
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/JdbcTicketServices.java
...authz/cas/endpoint/ticket/service/JdbcTicketServices.java
+7
-1
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/RandomServiceTicketServices.java
.../endpoint/ticket/service/RandomServiceTicketServices.java
+0
-5
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/RedisTicketGrantingTicketServices.java
...int/ticket/service/RedisTicketGrantingTicketServices.java
+76
-0
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/RedisTicketServices.java
...uthz/cas/endpoint/ticket/service/RedisTicketServices.java
+11
-2
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/TicketServices.java
...key/authz/cas/endpoint/ticket/service/TicketServices.java
+6
-0
maxkey-protocols/maxkey-protocol-cas/src/test/java/org/maxkey/web/authorize/endpoint/RestTestClient.java
...ava/org/maxkey/web/authorize/endpoint/RestTestClient.java
+1
-1
maxkey-web-maxkey/src/main/java/org/maxkey/autoconfigure/CasAutoConfiguration.java
...n/java/org/maxkey/autoconfigure/CasAutoConfiguration.java
+29
-1
未找到文件。
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/CasBaseAuthorizeEndpoint.java
浏览文件 @
ed8a351a
...
...
@@ -46,6 +46,11 @@ public class CasBaseAuthorizeEndpoint extends AuthorizeBaseEndpoint{
@Qualifier
(
"casTicketServices"
)
protected
TicketServices
ticketServices
;
@Autowired
@Qualifier
(
"casTicketGrantingTicketServices"
)
protected
TicketServices
casTicketGrantingTicketServices
;
public
void
setContentType
(
HttpServletRequest
request
,
HttpServletResponse
response
,
...
...
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/CasRestV1Endpoint.java
浏览文件 @
ed8a351a
...
...
@@ -81,7 +81,7 @@ public class CasRestV1Endpoint extends CasBaseAuthorizeEndpoint{
TicketGrantingTicketImpl
ticketGrantingTicket
=
new
TicketGrantingTicketImpl
(
"Random"
,
WebContext
.
getAuthentication
(),
null
);
String
ticket
=
t
icketServices
.
createTicket
(
ticketGrantingTicket
);
String
ticket
=
casTicketGrantingT
icketServices
.
createTicket
(
ticketGrantingTicket
);
String
location
=
applicationConfig
.
getServerPrefix
()+
"/authz/cas/v1/tickets/"
+
ticket
;
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"location"
,
location
);
...
...
@@ -110,7 +110,7 @@ public class CasRestV1Endpoint extends CasBaseAuthorizeEndpoint{
@RequestParam
(
value
=
CasConstants
.
PARAMETER
.
REST_PASSWORD
,
required
=
false
)
String
password
){
try
{
TicketGrantingTicketImpl
ticketGrantingTicketImpl
=
(
TicketGrantingTicketImpl
)
ticketServices
.
consumeTick
et
(
ticketGrantingTicket
);
(
TicketGrantingTicketImpl
)
casTicketGrantingTicketServices
.
g
et
(
ticketGrantingTicket
);
AppsCasDetails
casDetails
=
casDetailsService
.
getAppDetails
(
casService
);
...
...
@@ -133,7 +133,7 @@ public class CasRestV1Endpoint extends CasBaseAuthorizeEndpoint{
HttpServletResponse
response
){
try
{
TicketGrantingTicketImpl
ticketGrantingTicketImpl
=
(
TicketGrantingTicketImpl
)
ticketServices
.
consumeTick
et
(
ticketGrantingTicket
);
(
TicketGrantingTicketImpl
)
casTicketGrantingTicketServices
.
g
et
(
ticketGrantingTicket
);
if
(
ticketGrantingTicketImpl
!=
null
)
{
return
new
ResponseEntity
<>(
""
,
HttpStatus
.
OK
);
}
...
...
@@ -152,7 +152,7 @@ public class CasRestV1Endpoint extends CasBaseAuthorizeEndpoint{
HttpServletResponse
response
){
try
{
TicketGrantingTicketImpl
ticketGrantingTicketImpl
=
(
TicketGrantingTicketImpl
)
ticketServices
.
consumeTicket
(
ticketGrantingTicket
);
(
TicketGrantingTicketImpl
)
casTicketGrantingTicketServices
.
remove
(
ticketGrantingTicket
);
if
(
ticketGrantingTicketImpl
!=
null
)
{
return
new
ResponseEntity
<>(
""
,
HttpStatus
.
OK
);
}
...
...
@@ -184,7 +184,7 @@ public class CasRestV1Endpoint extends CasBaseAuthorizeEndpoint{
UserInfo
userInfo
=
WebContext
.
getUserInfo
();
TicketGrantingTicketImpl
ticketGrantingTicket
=
new
TicketGrantingTicketImpl
(
"Random"
,
WebContext
.
getAuthentication
(),
null
);
String
ticket
=
t
icketServices
.
createTicket
(
ticketGrantingTicket
);
String
ticket
=
casTicketGrantingT
icketServices
.
createTicket
(
ticketGrantingTicket
);
String
location
=
applicationConfig
.
getServerPrefix
()+
"/authz/cas/v1/tickets/"
+
ticket
;
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"location"
,
location
);
...
...
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/InMemoryTicketGrantingTicketServices.java
0 → 100644
浏览文件 @
ed8a351a
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed 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.maxkey.authz.cas.endpoint.ticket.service
;
import
java.time.Duration
;
import
org.ehcache.UserManagedCache
;
import
org.ehcache.config.builders.ExpiryPolicyBuilder
;
import
org.ehcache.config.builders.UserManagedCacheBuilder
;
import
org.maxkey.authz.cas.endpoint.ticket.Ticket
;
public
class
InMemoryTicketGrantingTicketServices
extends
RandomServiceTicketServices
{
protected
final
static
UserManagedCache
<
String
,
Ticket
>
casTicketGrantingTicketStore
=
UserManagedCacheBuilder
.
newUserManagedCacheBuilder
(
String
.
class
,
Ticket
.
class
)
.
withExpiry
(
ExpiryPolicyBuilder
.
timeToLiveExpiration
(
Duration
.
ofDays
(
2
)))
.
build
(
true
);
@Override
public
void
store
(
String
ticketId
,
Ticket
ticket
)
{
casTicketGrantingTicketStore
.
put
(
ticketId
,
ticket
);
}
@Override
public
Ticket
remove
(
String
ticketId
)
{
Ticket
ticket
=
casTicketGrantingTicketStore
.
get
(
ticketId
);
casTicketGrantingTicketStore
.
remove
(
ticketId
);
return
ticket
;
}
@Override
public
Ticket
get
(
String
ticketId
)
{
Ticket
ticket
=
casTicketGrantingTicketStore
.
get
(
ticketId
);
return
ticket
;
}
}
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/InMemoryTicketServices.java
浏览文件 @
ed8a351a
...
...
@@ -34,7 +34,7 @@ public class InMemoryTicketServices extends RandomServiceTicketServices {
@Override
p
rotected
void
store
(
String
ticketId
,
Ticket
ticket
)
{
p
ublic
void
store
(
String
ticketId
,
Ticket
ticket
)
{
casTicketStore
.
put
(
ticketId
,
ticket
);
}
...
...
@@ -45,4 +45,10 @@ public class InMemoryTicketServices extends RandomServiceTicketServices {
return
ticket
;
}
@Override
public
Ticket
get
(
String
ticket
)
{
// TODO Auto-generated method stub
return
null
;
}
}
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/JdbcTicketServices.java
浏览文件 @
ed8a351a
...
...
@@ -47,7 +47,7 @@ public class JdbcTicketServices extends RandomServiceTicketServices {
}
@Override
p
rotected
void
store
(
String
ticketId
,
Ticket
ticket
)
{
p
ublic
void
store
(
String
ticketId
,
Ticket
ticket
)
{
jdbcTemplate
.
update
(
insertAuthenticationSql
,
new
Object
[]
{
ticket
,
new
SqlLobValue
(
SerializationUtils
.
serialize
(
ticket
))
},
new
int
[]
{
Types
.
VARCHAR
,
Types
.
BLOB
});
...
...
@@ -86,4 +86,10 @@ public class JdbcTicketServices extends RandomServiceTicketServices {
public
void
setDeleteAuthenticationSql
(
String
deleteAuthenticationSql
)
{
this
.
deleteAuthenticationSql
=
deleteAuthenticationSql
;
}
@Override
public
Ticket
get
(
String
ticketId
)
{
// TODO Auto-generated method stub
return
null
;
}
}
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/RandomServiceTicketServices.java
浏览文件 @
ed8a351a
...
...
@@ -28,11 +28,6 @@ public abstract class RandomServiceTicketServices implements TicketServices {
//private RandomValueStringGenerator generator = new RandomValueStringGenerator();
private
DefaultUniqueTicketIdGenerator
generator
=
new
DefaultUniqueTicketIdGenerator
();
protected
abstract
void
store
(
String
ticketId
,
Ticket
ticket
);
protected
abstract
Ticket
remove
(
String
ticket
);
public
String
createTicket
(
Ticket
ticket
)
{
//String code = generator.generate();
...
...
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/RedisTicketGrantingTicketServices.java
0 → 100644
浏览文件 @
ed8a351a
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed 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.maxkey.authz.cas.endpoint.ticket.service
;
import
org.maxkey.authz.cas.endpoint.ticket.Ticket
;
import
org.maxkey.persistence.redis.RedisConnection
;
import
org.maxkey.persistence.redis.RedisConnectionFactory
;
public
class
RedisTicketGrantingTicketServices
extends
RandomServiceTicketServices
{
protected
int
serviceTicketValiditySeconds
=
60
*
60
*
24
*
2
;
//default 2 day.
RedisConnectionFactory
connectionFactory
;
public
static
String
PREFIX
=
"REDIS_CAS_TICKET_TGT_"
;
/**
* @param connectionFactory
*/
public
RedisTicketGrantingTicketServices
(
RedisConnectionFactory
connectionFactory
)
{
super
();
this
.
connectionFactory
=
connectionFactory
;
}
/**
*
*/
public
RedisTicketGrantingTicketServices
()
{
}
public
void
setConnectionFactory
(
RedisConnectionFactory
connectionFactory
)
{
this
.
connectionFactory
=
connectionFactory
;
}
@Override
public
void
store
(
String
ticketId
,
Ticket
ticket
)
{
RedisConnection
conn
=
connectionFactory
.
getConnection
();
conn
.
setexObject
(
PREFIX
+
ticketId
,
serviceTicketValiditySeconds
,
ticket
);
conn
.
close
();
}
@Override
public
Ticket
remove
(
String
ticketId
)
{
RedisConnection
conn
=
connectionFactory
.
getConnection
();
Ticket
ticket
=
conn
.
getObject
(
PREFIX
+
ticketId
);
conn
.
delete
(
PREFIX
+
ticketId
);
conn
.
close
();
return
ticket
;
}
@Override
public
Ticket
get
(
String
ticketId
)
{
RedisConnection
conn
=
connectionFactory
.
getConnection
();
Ticket
ticket
=
conn
.
getObject
(
PREFIX
+
ticketId
);
conn
.
close
();
return
ticket
;
}
}
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/RedisTicketServices.java
浏览文件 @
ed8a351a
...
...
@@ -24,11 +24,12 @@ import org.maxkey.persistence.redis.RedisConnectionFactory;
public
class
RedisTicketServices
extends
RandomServiceTicketServices
{
protected
int
serviceTicketValiditySeconds
=
60
*
10
;
//default 10 minutes.
RedisConnectionFactory
connectionFactory
;
public
static
String
PREFIX
=
"REDIS_CAS_TICKET_"
;
public
static
String
PREFIX
=
"REDIS_CAS_TICKET_
ST_
"
;
/**
* @param connectionFactory
*/
...
...
@@ -49,7 +50,7 @@ public class RedisTicketServices extends RandomServiceTicketServices {
}
@Override
p
rotected
void
store
(
String
ticketId
,
Ticket
ticket
)
{
p
ublic
void
store
(
String
ticketId
,
Ticket
ticket
)
{
RedisConnection
conn
=
connectionFactory
.
getConnection
();
conn
.
setexObject
(
PREFIX
+
ticketId
,
serviceTicketValiditySeconds
,
ticket
);
conn
.
close
();
...
...
@@ -64,5 +65,13 @@ public class RedisTicketServices extends RandomServiceTicketServices {
return
ticket
;
}
@Override
public
Ticket
get
(
String
ticketId
)
{
RedisConnection
conn
=
connectionFactory
.
getConnection
();
Ticket
ticket
=
conn
.
getObject
(
PREFIX
+
ticketId
);
conn
.
close
();
return
ticket
;
}
}
maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/ticket/service/TicketServices.java
浏览文件 @
ed8a351a
...
...
@@ -38,5 +38,11 @@ public interface TicketServices {
*/
Ticket
consumeTicket
(
String
ticketId
)
throws
Exception
;
public
void
store
(
String
ticketId
,
Ticket
ticket
);
public
Ticket
remove
(
String
ticket
);
public
Ticket
get
(
String
ticketId
);
}
maxkey-protocols/maxkey-protocol-cas/src/test/java/org/maxkey/web/authorize/endpoint/RestTestClient.java
浏览文件 @
ed8a351a
...
...
@@ -47,6 +47,6 @@ public class RestTestClient {
for
(
Map
.
Entry
entry
:
mapEntries
)
{
System
.
out
.
println
(
entry
.
getKey
()
+
":"
+
entry
.
getValue
());
}
//
client.destroyTicketGrantingTicket(profile,webContext);
client
.
destroyTicketGrantingTicket
(
profile
,
webContext
);
}
}
maxkey-web-maxkey/src/main/java/org/maxkey/autoconfigure/CasAutoConfiguration.java
浏览文件 @
ed8a351a
...
...
@@ -17,8 +17,10 @@
package
org.maxkey.autoconfigure
;
import
org.maxkey.authz.cas.endpoint.ticket.service.InMemoryTicketGrantingTicketServices
;
import
org.maxkey.authz.cas.endpoint.ticket.service.InMemoryTicketServices
;
import
org.maxkey.authz.cas.endpoint.ticket.service.JdbcTicketServices
;
import
org.maxkey.authz.cas.endpoint.ticket.service.RedisTicketGrantingTicketServices
;
import
org.maxkey.authz.cas.endpoint.ticket.service.RedisTicketServices
;
import
org.maxkey.authz.cas.endpoint.ticket.service.TicketServices
;
import
org.maxkey.constants.ConstantsProperties
;
...
...
@@ -67,7 +69,33 @@ public class CasAutoConfiguration implements InitializingBean {
return
casTicketServices
;
}
/**
* TicketServices.
* @param persistence int
* @param validity int
* @return casTicketServices
*/
@Bean
(
name
=
"casTicketGrantingTicketServices"
)
public
TicketServices
casTicketGrantingTicketServices
(
@Value
(
"${config.server.persistence}"
)
int
persistence
,
@Value
(
"${config.login.remeberme.validity}"
)
int
validity
,
JdbcTemplate
jdbcTemplate
,
RedisConnectionFactory
jedisConnectionFactory
)
{
TicketServices
casTicketServices
=
null
;
if
(
persistence
==
0
)
{
casTicketServices
=
new
InMemoryTicketGrantingTicketServices
();
_logger
.
debug
(
"InMemoryTicketServices"
);
}
else
if
(
persistence
==
1
)
{
//
//casTicketServices = new JdbcTicketServices(jdbcTemplate);
_logger
.
debug
(
"JdbcTicketServices not support "
);
}
else
if
(
persistence
==
2
)
{
casTicketServices
=
new
RedisTicketGrantingTicketServices
(
jedisConnectionFactory
);
_logger
.
debug
(
"RedisTicketServices"
);
}
return
casTicketServices
;
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
// TODO Auto-generated method stub
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录