com.quhaodian.user.plugs.github.GitHubOauthPlugin Maven / Gradle / Ivy
package com.quhaodian.user.plugs.github;
import com.quhaodian.user.data.entity.UserInfo;
import com.quhaodian.user.data.entity.UserOauthToken;
import com.quhaodian.user.data.service.UserOauthTokenService;
import com.quhaodian.user.oauth.domain.OauthResponse;
import com.quhaodian.user.oauth.domain.TokenResponse;
import com.quhaodian.user.oauth.impl.GitHubHander;
import com.quhaodian.user.plugs.base.OauthPlugin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component("gitHubOauthPlugin")
public class GitHubOauthPlugin extends OauthPlugin {
@Autowired
private UserOauthTokenService tokenService;
@Override
public UserInfo login(String code) {
GitHubHander hubHander = new GitHubHander();
TokenResponse tokenResponse = hubHander.getToken(code);
OauthResponse oauthResponse = hubHander.login(tokenResponse.getAccessToken(), null);
UserOauthToken userOauthToken = tokenService.login(oauthResponse);
UserInfo user = userOauthToken.getUser();
return user;
}
@Override
public String getName() {
return "Github登陆插件";
}
@Override
public String getVersion() {
return "1.0.1";
}
@Override
public String getAuthor() {
return "ada.young";
}
@Override
public String getSiteUrl() {
return "http://www.yichisancun.com/";
}
@Override
public String getInstallUrl() {
return "admin/oauth_plugin/github/install.htm";
}
@Override
public String getUninstallUrl() {
return "admin/oauth_plugin/github/uninstall.htm";
}
@Override
public String getSettingUrl() {
return "admin/oauth_plugin/github/setting.htm";
}
}