You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.3 KiB
37 lines
1.3 KiB
package com.eco.plugin.xxxx.bssso.oauthservice; |
|
|
|
import com.eco.plugin.xxxx.bssso.config.PluginSimpleConfig; |
|
import com.eco.plugin.xxxx.bssso.utils.FRUtils; |
|
import com.yum.secure.builder.OAuthServiceBuilder; |
|
import com.yum.secure.model.OAuth20Config; |
|
import com.yum.secure.model.Token; |
|
import com.yum.secure.oauth.IOAuth20Service; |
|
|
|
public class OAuthService { |
|
IOAuth20Service oAuth20Service; |
|
|
|
|
|
public OAuthService(String clientId, String clientSerect, String redirectUri) { |
|
String authorizeUrl = PluginSimpleConfig.getInstance().getSsoprefix()+"/oauth/authorize"; |
|
String accessTokenUrl = PluginSimpleConfig.getInstance().getSsoprefix()+"/oauth/token"; |
|
OAuth20Config oAuth20Config = new OAuth20Config(clientId, clientSerect, redirectUri, authorizeUrl, accessTokenUrl); |
|
this.oAuth20Service = (new OAuthServiceBuilder(oAuth20Config)).build20Service(); |
|
} |
|
|
|
public String getAuthorizationUrl() { |
|
return this.oAuth20Service.getAuthorizationUrl(); |
|
} |
|
|
|
public Token getAccessToken(String code) { |
|
FRUtils.FRLogInfo("code:"+code); |
|
Token accessToken = this.oAuth20Service.getAccessToken(code); |
|
if(accessToken != null){ |
|
FRUtils.FRLogInfo("token:"+accessToken.getToken()); |
|
}else{ |
|
FRUtils.FRLogInfo("token为空"); |
|
|
|
} |
|
return accessToken; |
|
} |
|
} |
|
|
|
|