use of com.diboot.iam.jwt.BaseJwtAuthToken in project diboot by dibo-software.
the class SSOAuthServiceImpl 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());
}
}
Aggregations