public class OAuth2TokenUtil extends Object
token生成工具
在oauth2的情况下,根据spring security的认证信息生成tokenConstructor and Description |
---|
OAuth2TokenUtil(org.springframework.security.oauth2.provider.ClientDetailsService clientDetailsService,
org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices authorizationServerTokenServices,
org.springframework.security.oauth2.provider.token.ConsumerTokenServices consumerTokenServices,
org.springframework.security.core.userdetails.UserDetailsService userDetailsService,
org.springframework.security.crypto.password.PasswordEncoder passwordEncoder,
org.springframework.security.oauth2.provider.authentication.TokenExtractor tokenExtractor) |
Modifier and Type | Method and Description |
---|---|
org.springframework.security.oauth2.common.OAuth2AccessToken |
createToken(org.springframework.security.core.Authentication authentication,
org.springframework.security.oauth2.provider.ClientDetails clientDetails,
String grantType)
根据认证信息生成token
|
org.springframework.security.oauth2.common.OAuth2AccessToken |
createToken(org.springframework.security.core.Authentication authentication,
String clientId,
String grantType)
根据认证信息和客户端id信息生成token
|
org.springframework.security.oauth2.common.OAuth2AccessToken |
createToken(org.springframework.security.core.Authentication authentication,
String clientId,
String clientSecret,
String grantType)
根据认证信息和客户端信息生成token
|
org.springframework.security.oauth2.common.OAuth2AccessToken |
createToken(javax.servlet.http.HttpServletRequest request,
org.springframework.security.core.Authentication authentication,
String grantType)
根据认证信息生成token 【请求头中必须包含basic信息】
|
org.springframework.security.oauth2.common.OAuth2AccessToken |
createToken(javax.servlet.http.HttpServletRequest request,
String username,
org.springframework.security.oauth2.provider.ClientDetails clientDetails,
String grantType)
根据认证信息生成token
|
org.springframework.security.oauth2.common.OAuth2AccessToken |
createToken(javax.servlet.http.HttpServletRequest request,
String username,
String clientId,
String grantType)
根据认证信息生成token
|
org.springframework.security.oauth2.common.OAuth2AccessToken |
createToken(javax.servlet.http.HttpServletRequest request,
String username,
String clientId,
String clientSecret,
String grantType)
根据认证信息生成token
|
boolean |
removeToken(javax.servlet.http.HttpServletRequest request)
根据请求里token信息移除存储的登录token
|
boolean |
removeToken(String tokenValue)
根据token的值移除存储的登录token
|
public OAuth2TokenUtil(org.springframework.security.oauth2.provider.ClientDetailsService clientDetailsService, org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices authorizationServerTokenServices, org.springframework.security.oauth2.provider.token.ConsumerTokenServices consumerTokenServices, org.springframework.security.core.userdetails.UserDetailsService userDetailsService, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder, org.springframework.security.oauth2.provider.authentication.TokenExtractor tokenExtractor)
public boolean removeToken(String tokenValue)
tokenValue
- token的public boolean removeToken(javax.servlet.http.HttpServletRequest request)
根据请求里token信息移除存储的登录token
token 的提取方式参见 TokenExtractorrequest
- HttpServletRequestpublic org.springframework.security.oauth2.common.OAuth2AccessToken createToken(javax.servlet.http.HttpServletRequest request, String username, String clientId, String clientSecret, String grantType)
request
- HttpServletRequestusername
- 用户名clientId
- clientIdclientSecret
- 原始终端密码grantType
- 授权类型,默认为 customepublic org.springframework.security.oauth2.common.OAuth2AccessToken createToken(javax.servlet.http.HttpServletRequest request, String username, String clientId, String grantType)
request
- HttpServletRequestusername
- 用户名clientId
- clientIdgrantType
- 授权类型,默认为 customepublic org.springframework.security.oauth2.common.OAuth2AccessToken createToken(javax.servlet.http.HttpServletRequest request, String username, org.springframework.security.oauth2.provider.ClientDetails clientDetails, String grantType)
request
- HttpServletRequestusername
- 用户名clientDetails
- 终端信息grantType
- 授权类型,默认为 customepublic org.springframework.security.oauth2.common.OAuth2AccessToken createToken(javax.servlet.http.HttpServletRequest request, org.springframework.security.core.Authentication authentication, String grantType) throws IOException
request
- HttpServletRequestauthentication
- spring security登陆成功后的认证信息grantType
- 授权类型IOException
- 处理时发生问题public org.springframework.security.oauth2.common.OAuth2AccessToken createToken(org.springframework.security.core.Authentication authentication, String clientId, String clientSecret, String grantType)
authentication
- spring security登陆成功后的认证信息clientId
- clientIdclientSecret
- 原始终端密码grantType
- 授权类型,默认为customepublic org.springframework.security.oauth2.common.OAuth2AccessToken createToken(org.springframework.security.core.Authentication authentication, String clientId, String grantType)
根据认证信息和客户端id信息生成token
注意此方法不会校验终端密码,一定要在可信环境下使用authentication
- spring security登陆成功后的认证信息clientId
- clientIdgrantType
- 授权类型,默认为customepublic org.springframework.security.oauth2.common.OAuth2AccessToken createToken(org.springframework.security.core.Authentication authentication, org.springframework.security.oauth2.provider.ClientDetails clientDetails, String grantType)
authentication
- spring security登陆成功后的认证信息clientDetails
- 终端登录成功后的认证信息grantType
- 授权类型,默认为customeCopyright © 2021. All rights reserved.