use of com.diboot.iam.jwt.BaseJwtAuthToken in project diboot by dibo-software.
the class PwdAuthServiceImpl method applyToken.
@Override
public String applyToken(AuthCredential credential) {
BaseJwtAuthToken authToken = initBaseJwtAuthToken(credential);
try {
Subject subject = SecurityUtils.getSubject();
subject.login(authToken);
if (subject.isAuthenticated()) {
log.debug("申请token成功!authtoken={}", authToken.getCredentials());
saveLoginTrace(authToken, true);
// 跳转到首页
return (String) authToken.getCredentials();
} else {
log.error("认证失败");
saveLoginTrace(authToken, false);
throw new BusinessException(Status.FAIL_OPERATION, "认证失败");
}
} catch (Exception e) {
log.error("登录异常", e);
saveLoginTrace(authToken, false);
throw new BusinessException(Status.FAIL_OPERATION, e.getMessage());
}
}
use of com.diboot.iam.jwt.BaseJwtAuthToken in project diboot by dibo-software.
the class SSOAuthServiceImpl method initBaseJwtAuthToken.
/**
* 初始化JwtAuthToken实例
* @param credential
* @return
*/
private BaseJwtAuthToken initBaseJwtAuthToken(AuthCredential credential) {
// 通过CAS得到账号
SSOCredential ssoCredential = (SSOCredential) credential;
BaseJwtAuthToken token = new BaseJwtAuthToken(getAuthType(), ssoCredential.getUserTypeClass());
String username = parseCasTicket(ssoCredential);
ssoCredential.setAuthAccount(username);
// 设置账号密码
token.setAuthAccount(ssoCredential.getAuthAccount());
token.setTenantId(credential.getTenantId());
token.setRememberMe(ssoCredential.isRememberMe());
// 生成token
return token.generateAuthtoken(getExpiresInMinutes());
}
use of com.diboot.iam.jwt.BaseJwtAuthToken in project diboot by dibo-software.
the class WxAuthServiceImpl method initBaseJwtAuthToken.
/**
* 初始化JwtAuthToken实例
* @param credential
* @return
*/
private BaseJwtAuthToken initBaseJwtAuthToken(AuthCredential credential) {
MobileCredential wxMpCredential = (MobileCredential) credential;
BaseJwtAuthToken token = new BaseJwtAuthToken(getAuthType(), wxMpCredential.getUserTypeClass());
// 设置登陆的
token.setAuthAccount(wxMpCredential.getAuthAccount());
token.setRememberMe(wxMpCredential.isRememberMe());
// 生成token
return token.generateAuthtoken(getExpiresInMinutes());
}
use of com.diboot.iam.jwt.BaseJwtAuthToken in project diboot by dibo-software.
the class WxAuthServiceImpl method applyToken.
@Override
public String applyToken(AuthCredential credential) {
BaseJwtAuthToken authToken = initBaseJwtAuthToken(credential);
try {
Subject subject = SecurityUtils.getSubject();
subject.login(authToken);
if (subject.isAuthenticated()) {
log.debug("申请token成功!authtoken={}", authToken.getCredentials());
saveLoginTrace(authToken, true);
// 跳转到首页
return (String) authToken.getCredentials();
} else {
log.error("认证失败");
saveLoginTrace(authToken, false);
throw new BusinessException(Status.FAIL_OPERATION, "认证失败");
}
} catch (Exception e) {
log.error("登录异常", e);
saveLoginTrace(authToken, false);
throw new BusinessException(Status.FAIL_OPERATION, e.getMessage());
}
}
use of com.diboot.iam.jwt.BaseJwtAuthToken in project diboot by dibo-software.
the class PwdAuthServiceImpl method initBaseJwtAuthToken.
/**
* 初始化JwtAuthToken实例
* @param credential
* @return
*/
private BaseJwtAuthToken initBaseJwtAuthToken(AuthCredential credential) {
BaseJwtAuthToken token = new BaseJwtAuthToken(getAuthType(), credential.getUserTypeClass());
// 设置账号密码
token.setAuthAccount(credential.getAuthAccount());
token.setAuthSecret(credential.getAuthSecret());
token.setRememberMe(credential.isRememberMe());
token.setTenantId(credential.getTenantId());
token.setExtObj(credential.getExtObj());
// 生成token
return token.generateAuthtoken(getExpiresInMinutes());
}
Aggregations