Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
程序猿小郑
microservices-platform
提交
f0371199
microservices-platform
项目概览
程序猿小郑
/
microservices-platform
与 Fork 源项目一致
Fork自
zlt2000 / microservices-platform
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
microservices-platform
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f0371199
编写于
7月 15, 2019
作者:
zlt2000
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
token移去common包中
上级
74a57ae2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
166 addition
and
165 deletion
+166
-165
zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/token/MobileAuthenticationToken.java
...entral/oauth2/common/token/MobileAuthenticationToken.java
+84
-84
zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/token/OpenIdAuthenticationToken.java
...entral/oauth2/common/token/OpenIdAuthenticationToken.java
+78
-78
zlt-uaa/src/main/java/com/central/oauth/controller/OAuth2Controller.java
...n/java/com/central/oauth/controller/OAuth2Controller.java
+2
-2
zlt-uaa/src/main/java/com/central/oauth/mobile/MobileAuthenticationProvider.java
...om/central/oauth/mobile/MobileAuthenticationProvider.java
+1
-0
zlt-uaa/src/main/java/com/central/oauth/openid/OpenIdAuthenticationProvider.java
...om/central/oauth/openid/OpenIdAuthenticationProvider.java
+1
-1
未找到文件。
zlt-
uaa/src/main/java/com/central/oauth/mobile
/MobileAuthenticationToken.java
→
zlt-
commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/token
/MobileAuthenticationToken.java
浏览文件 @
f0371199
/**
*
*/
package
com.central.oauth
.mobile
;
import
org.springframework.security.authentication.AbstractAuthenticationToken
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.SpringSecurityCoreVersion
;
import
java.util.Collection
;
/**
* @author zlt
*/
public
class
MobileAuthenticationToken
extends
AbstractAuthenticationToken
{
private
static
final
long
serialVersionUID
=
SpringSecurityCoreVersion
.
SERIAL_VERSION_UID
;
// ~ Instance fields
// ================================================================================================
private
final
Object
principal
;
private
Object
credentials
;
// ~ Constructors
// ===================================================================================================
/**
* This constructor can be safely used by any code that wishes to create a
* <code>UsernamePasswordAuthenticationToken</code>, as the {@link #isAuthenticated()}
* will return <code>false</code>.
*
*/
public
MobileAuthenticationToken
(
String
mobile
,
String
password
)
{
super
(
null
);
this
.
principal
=
mobile
;
this
.
credentials
=
password
;
setAuthenticated
(
false
);
}
/**
* This constructor should only be used by <code>AuthenticationManager</code> or
* <code>AuthenticationProvider</code> implementations that are satisfied with
* producing a trusted (i.e. {@link #isAuthenticated()} = <code>true</code>)
* authentication token.
*
* @param principal
* @param authorities
*/
public
MobileAuthenticationToken
(
Object
principal
,
Object
credentials
,
Collection
<?
extends
GrantedAuthority
>
authorities
)
{
super
(
authorities
);
this
.
principal
=
principal
;
this
.
credentials
=
credentials
;
super
.
setAuthenticated
(
true
);
}
// ~ Methods
// ========================================================================================================
@Override
public
Object
getCredentials
()
{
return
this
.
credentials
;
}
@Override
public
Object
getPrincipal
()
{
return
this
.
principal
;
}
@Override
public
void
setAuthenticated
(
boolean
isAuthenticated
)
{
if
(
isAuthenticated
)
{
throw
new
IllegalArgumentException
(
"Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"
);
}
super
.
setAuthenticated
(
false
);
}
@Override
public
void
eraseCredentials
()
{
super
.
eraseCredentials
();
}
}
/**
*
*/
package
com.central.oauth
2.common.token
;
import
org.springframework.security.authentication.AbstractAuthenticationToken
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.SpringSecurityCoreVersion
;
import
java.util.Collection
;
/**
* @author zlt
*/
public
class
MobileAuthenticationToken
extends
AbstractAuthenticationToken
{
private
static
final
long
serialVersionUID
=
SpringSecurityCoreVersion
.
SERIAL_VERSION_UID
;
// ~ Instance fields
// ================================================================================================
private
final
Object
principal
;
private
Object
credentials
;
// ~ Constructors
// ===================================================================================================
/**
* This constructor can be safely used by any code that wishes to create a
* <code>UsernamePasswordAuthenticationToken</code>, as the {@link #isAuthenticated()}
* will return <code>false</code>.
*
*/
public
MobileAuthenticationToken
(
String
mobile
,
String
password
)
{
super
(
null
);
this
.
principal
=
mobile
;
this
.
credentials
=
password
;
setAuthenticated
(
false
);
}
/**
* This constructor should only be used by <code>AuthenticationManager</code> or
* <code>AuthenticationProvider</code> implementations that are satisfied with
* producing a trusted (i.e. {@link #isAuthenticated()} = <code>true</code>)
* authentication token.
*
* @param principal
* @param authorities
*/
public
MobileAuthenticationToken
(
Object
principal
,
Object
credentials
,
Collection
<?
extends
GrantedAuthority
>
authorities
)
{
super
(
authorities
);
this
.
principal
=
principal
;
this
.
credentials
=
credentials
;
super
.
setAuthenticated
(
true
);
}
// ~ Methods
// ========================================================================================================
@Override
public
Object
getCredentials
()
{
return
this
.
credentials
;
}
@Override
public
Object
getPrincipal
()
{
return
this
.
principal
;
}
@Override
public
void
setAuthenticated
(
boolean
isAuthenticated
)
{
if
(
isAuthenticated
)
{
throw
new
IllegalArgumentException
(
"Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"
);
}
super
.
setAuthenticated
(
false
);
}
@Override
public
void
eraseCredentials
()
{
super
.
eraseCredentials
();
}
}
zlt-
uaa/src/main/java/com/central/oauth/openid
/OpenIdAuthenticationToken.java
→
zlt-
commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/token
/OpenIdAuthenticationToken.java
浏览文件 @
f0371199
package
com.central.oauth
.openid
;
import
org.springframework.security.authentication.AbstractAuthenticationToken
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.SpringSecurityCoreVersion
;
import
java.util.Collection
;
/**
* @author zlt
*/
public
class
OpenIdAuthenticationToken
extends
AbstractAuthenticationToken
{
private
static
final
long
serialVersionUID
=
SpringSecurityCoreVersion
.
SERIAL_VERSION_UID
;
// ~ Instance fields
// ================================================================================================
private
final
Object
principal
;
// ~ Constructors
// ===================================================================================================
/**
* This constructor can be safely used by any code that wishes to create a
* <code>UsernamePasswordAuthenticationToken</code>, as the {@link #isAuthenticated()}
* will return <code>false</code>.
*
*/
public
OpenIdAuthenticationToken
(
String
openId
)
{
super
(
null
);
this
.
principal
=
openId
;
setAuthenticated
(
false
);
}
/**
* This constructor should only be used by <code>AuthenticationManager</code> or
* <code>AuthenticationProvider</code> implementations that are satisfied with
* producing a trusted (i.e. {@link #isAuthenticated()} = <code>true</code>)
* authentication token.
*
* @param principal
* @param authorities
*/
public
OpenIdAuthenticationToken
(
Object
principal
,
Collection
<?
extends
GrantedAuthority
>
authorities
)
{
super
(
authorities
);
this
.
principal
=
principal
;
super
.
setAuthenticated
(
true
);
}
// ~ Methods
// ========================================================================================================
@Override
public
Object
getCredentials
()
{
return
null
;
}
@Override
public
Object
getPrincipal
()
{
return
this
.
principal
;
}
@Override
public
void
setAuthenticated
(
boolean
isAuthenticated
)
{
if
(
isAuthenticated
)
{
throw
new
IllegalArgumentException
(
"Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"
);
}
super
.
setAuthenticated
(
false
);
}
@Override
public
void
eraseCredentials
()
{
super
.
eraseCredentials
();
}
}
package
com.central.oauth
2.common.token
;
import
org.springframework.security.authentication.AbstractAuthenticationToken
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.SpringSecurityCoreVersion
;
import
java.util.Collection
;
/**
* @author zlt
*/
public
class
OpenIdAuthenticationToken
extends
AbstractAuthenticationToken
{
private
static
final
long
serialVersionUID
=
SpringSecurityCoreVersion
.
SERIAL_VERSION_UID
;
// ~ Instance fields
// ================================================================================================
private
final
Object
principal
;
// ~ Constructors
// ===================================================================================================
/**
* This constructor can be safely used by any code that wishes to create a
* <code>UsernamePasswordAuthenticationToken</code>, as the {@link #isAuthenticated()}
* will return <code>false</code>.
*
*/
public
OpenIdAuthenticationToken
(
String
openId
)
{
super
(
null
);
this
.
principal
=
openId
;
setAuthenticated
(
false
);
}
/**
* This constructor should only be used by <code>AuthenticationManager</code> or
* <code>AuthenticationProvider</code> implementations that are satisfied with
* producing a trusted (i.e. {@link #isAuthenticated()} = <code>true</code>)
* authentication token.
*
* @param principal
* @param authorities
*/
public
OpenIdAuthenticationToken
(
Object
principal
,
Collection
<?
extends
GrantedAuthority
>
authorities
)
{
super
(
authorities
);
this
.
principal
=
principal
;
super
.
setAuthenticated
(
true
);
}
// ~ Methods
// ========================================================================================================
@Override
public
Object
getCredentials
()
{
return
null
;
}
@Override
public
Object
getPrincipal
()
{
return
this
.
principal
;
}
@Override
public
void
setAuthenticated
(
boolean
isAuthenticated
)
{
if
(
isAuthenticated
)
{
throw
new
IllegalArgumentException
(
"Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"
);
}
super
.
setAuthenticated
(
false
);
}
@Override
public
void
eraseCredentials
()
{
super
.
eraseCredentials
();
}
}
zlt-uaa/src/main/java/com/central/oauth/controller/OAuth2Controller.java
浏览文件 @
f0371199
...
...
@@ -2,8 +2,8 @@ package com.central.oauth.controller;
import
com.central.common.constant.SecurityConstants
;
import
com.central.common.model.Result
;
import
com.central.oauth
.mobile
.MobileAuthenticationToken
;
import
com.central.oauth
.openid
.OpenIdAuthenticationToken
;
import
com.central.oauth
2.common.token
.MobileAuthenticationToken
;
import
com.central.oauth
2.common.token
.OpenIdAuthenticationToken
;
import
com.central.oauth2.common.util.AuthUtils
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
io.swagger.annotations.Api
;
...
...
zlt-uaa/src/main/java/com/central/oauth/mobile/MobileAuthenticationProvider.java
浏览文件 @
f0371199
package
com.central.oauth.mobile
;
import
com.central.oauth.service.ZltUserDetailsService
;
import
com.central.oauth2.common.token.MobileAuthenticationToken
;
import
lombok.Setter
;
import
org.springframework.security.authentication.AuthenticationProvider
;
import
org.springframework.security.authentication.BadCredentialsException
;
...
...
zlt-uaa/src/main/java/com/central/oauth/openid/OpenIdAuthenticationProvider.java
浏览文件 @
f0371199
package
com.central.oauth.openid
;
import
com.central.oauth2.common.token.OpenIdAuthenticationToken
;
import
org.springframework.security.authentication.AuthenticationProvider
;
import
org.springframework.security.authentication.InternalAuthenticationServiceException
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.social.security.SocialUserDetailsService
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录