Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
dcf9fed7
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dcf9fed7
编写于
7月 25, 2022
作者:
Z
zhourui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
restore login
上级
db7c2460
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
146 addition
and
130 deletion
+146
-130
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/authentication/ActionCaptchaLogin.java
...thentication/jaxrs/authentication/ActionCaptchaLogin.java
+1
-1
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/authentication/ActionLogin.java
...mble/authentication/jaxrs/authentication/ActionLogin.java
+88
-107
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/authentication/AuthenticationAction.java
...entication/jaxrs/authentication/AuthenticationAction.java
+18
-18
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/authentication/BaseAction.java
...emble/authentication/jaxrs/authentication/BaseAction.java
+3
-4
o2server/x_organization_core_express/src/main/java/com/x/organization/core/express/assemble/authentication/jaxrs/authentication/ActionLoginWi.java
...le/authentication/jaxrs/authentication/ActionLoginWi.java
+36
-0
未找到文件。
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/authentication/ActionCaptchaLogin.java
浏览文件 @
dcf9fed7
...
...
@@ -38,7 +38,7 @@ class ActionCaptchaLogin extends BaseAction {
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
Wo
wo
=
null
;
String
password
=
password
(
wi
);
String
password
=
password
(
wi
.
getPassword
()
);
if
(
BooleanUtils
.
isTrue
(
Config
.
person
().
getCaptchaLogin
())
&&
(
BooleanUtils
.
isFalse
(
business
.
instrument
().
captcha
().
validate
(
wi
.
getCaptcha
(),
wi
.
getCaptchaAnswer
()))))
{
throw
new
ExceptionInvalidCaptcha
();
...
...
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/authentication/ActionLogin.java
浏览文件 @
dcf9fed7
//package com.x.organization.assemble.authentication.jaxrs.authentication;
//
//import java.util.List;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.apache.commons.lang3.StringUtils;
//
//import com.google.gson.JsonElement;
//import com.x.base.core.container.EntityManagerContainer;
//import com.x.base.core.container.factory.EntityManagerContainerFactory;
//import com.x.base.core.project.annotation.FieldDescribe;
//import com.x.base.core.project.config.Config;
//import com.x.base.core.project.gson.GsonPropertyObject;
//import com.x.base.core.project.http.ActionResult;
//import com.x.base.core.project.http.EffectivePerson;
//import com.x.base.core.project.logger.Logger;
//import com.x.base.core.project.logger.LoggerFactory;
//import com.x.organization.assemble.authentication.Business;
//import com.x.organization.core.entity.Person;
//
//@Deprecated(forRemoval = true)
//class ActionLogin extends BaseAction {
//
// private static final Logger LOGGER = LoggerFactory.getLogger(ActionLogin.class);
//
// ActionResult<Wo> execute(HttpServletRequest request, HttpServletResponse response, EffectivePerson effectivePerson,
// JsonElement jsonElement) throws Exception {
// try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
// ActionResult<Wo> result = new ActionResult<>();
// Business business = new Business(emc);
// Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
// Wo wo = new Wo();
// check(wi);
// LOGGER.debug("user:{}, try to login.", wi.getCredential());
// String password = wi.getPassword();
// if (Config.token().isInitialManager(wi.getCredential())) {
// if (!Config.token().verifyPassword(wi.getCredential(), password)) {
// throw new ExceptionPersonNotExistOrInvalidPassword();
// }
// wo = this.manager(request, response, wi.getCredential(), Wo.class);
// } else {
// // 普通用户登录,也有可能拥有管理员角色.增加相同标识(name允许重复)的认证
// List<String> people = this.listWithCredential(business, wi.getCredential());
// Person person = null;
// if (people.isEmpty()) {
// throw new ExceptionPersonNotExistOrInvalidPassword();
// } else if (people.size() == 1) {
// person = this.personLogin(business, people.get(0), password);
// } else {
// person = this.peopleLogin(business, people, password);
// }
// if (null == person) {
// throw new ExceptionPersonNotExistOrInvalidPassword();
// } else {
// wo = this.user(request, response, business, person, Wo.class);
// }
// }
// result.setData(wo);
// return result;
// }
// }
//
// private void check(Wi wi) throws ExceptionCredentialEmpty, ExceptionPasswordEmpty {
// if (StringUtils.isEmpty(wi.getCredential())) {
// throw new ExceptionCredentialEmpty();
// }
// if (StringUtils.isEmpty(wi.getPassword())) {
// throw new ExceptionPasswordEmpty();
// }
// }
//
// public static class Wi extends GsonPropertyObject {
//
// private static final long serialVersionUID = -6099815091986193292L;
//
// @FieldDescribe("凭证")
// private String credential;
//
// @FieldDescribe("密码")
// private String password;
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getCredential() {
// return credential;
// }
//
// public void setCredential(String credential) {
// this.credential = credential;
// }
//
// }
//
// public static class Wo extends AbstractWoAuthentication {
//
// private static final long serialVersionUID = -5397186305200946501L;
//
// }
//}
package
com.x.organization.assemble.authentication.jaxrs.authentication
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.organization.assemble.authentication.Business
;
import
com.x.organization.core.entity.Person
;
import
com.x.organization.core.express.assemble.authentication.jaxrs.authentication.ActionLoginWi
;
import
io.swagger.v3.oas.annotations.media.Schema
;
class
ActionLogin
extends
BaseAction
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ActionLogin
.
class
);
ActionResult
<
Wo
>
execute
(
HttpServletRequest
request
,
HttpServletResponse
response
,
EffectivePerson
effectivePerson
,
JsonElement
jsonElement
)
throws
Exception
{
LOGGER
.
debug
(
"execute:{}."
,
effectivePerson:
:
getDistinguishedName
);
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
Wo
wo
=
new
Wo
();
check
(
wi
);
String
password
=
this
.
password
(
wi
.
getPassword
());
if
(
Config
.
token
().
isInitialManager
(
wi
.
getCredential
()))
{
if
(!
Config
.
token
().
verifyPassword
(
wi
.
getCredential
(),
password
))
{
throw
new
ExceptionPersonNotExistOrInvalidPassword
();
}
wo
=
this
.
manager
(
request
,
response
,
wi
.
getCredential
(),
Wo
.
class
);
}
else
{
// 普通用户登录,也有可能拥有管理员角色.增加相同标识(name允许重复)的认证
List
<
String
>
people
=
this
.
listWithCredential
(
business
,
wi
.
getCredential
());
Person
person
=
null
;
if
(
people
.
isEmpty
())
{
throw
new
ExceptionPersonNotExistOrInvalidPassword
();
}
else
if
(
people
.
size
()
==
1
)
{
person
=
this
.
personLogin
(
business
,
people
.
get
(
0
),
password
);
}
else
{
person
=
this
.
peopleLogin
(
business
,
people
,
password
);
}
if
(
null
==
person
)
{
throw
new
ExceptionPersonNotExistOrInvalidPassword
();
}
else
{
wo
=
this
.
user
(
request
,
response
,
business
,
person
,
Wo
.
class
);
}
}
result
.
setData
(
wo
);
return
result
;
}
}
private
void
check
(
Wi
wi
)
throws
ExceptionCredentialEmpty
,
ExceptionPasswordEmpty
{
if
(
StringUtils
.
isEmpty
(
wi
.
getCredential
()))
{
throw
new
ExceptionCredentialEmpty
();
}
if
(
StringUtils
.
isEmpty
(
wi
.
getPassword
()))
{
throw
new
ExceptionPasswordEmpty
();
}
}
@Schema
(
name
=
"com.x.organization.assemble.authentication.jaxrs.authentication.ActionLogin$Wi"
)
public
static
class
Wi
extends
ActionLoginWi
{
private
static
final
long
serialVersionUID
=
-
3566349910283010822L
;
}
public
static
class
Wo
extends
AbstractWoAuthentication
{
private
static
final
long
serialVersionUID
=
-
5397186305200946501L
;
}
}
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/authentication/AuthenticationAction.java
浏览文件 @
dcf9fed7
...
...
@@ -72,24 +72,24 @@ public class AuthenticationAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
//
@JaxrsMethodDescribe(value = "用户登录.credential=xxxx,password=xxxx", action = ActionLogin.class)
//
@POST
//
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
//
@Consumes(MediaType.APPLICATION_JSON)
//
public void login(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
//
@Context HttpServletResponse response, JsonElement jsonElement) {
//
ActionResult<ActionLogin.Wo> result = new ActionResult<>();
//
EffectivePerson effectivePerson = this.effectivePerson(request);
//
try {
//
result = new ActionLogin().execute(request, response, effectivePerson, jsonElement);
//
} catch (Exception e) {
// logger
.error(e, effectivePerson, request, null);
//
result.error(e);
//
}
//
// 擦除密码
//
erasePassword(jsonElement);
//
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result, jsonElement));
//
}
@JaxrsMethodDescribe
(
value
=
"用户登录.credential=xxxx,password=xxxx"
,
action
=
ActionLogin
.
class
)
@POST
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
login
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@Context
HttpServletResponse
response
,
JsonElement
jsonElement
)
{
ActionResult
<
ActionLogin
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionLogin
().
execute
(
request
,
response
,
effectivePerson
,
jsonElement
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
// 擦除密码
erasePassword
(
jsonElement
);
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
,
jsonElement
));
}
@JaxrsMethodDescribe
(
value
=
"用户注销."
,
action
=
ActionLogout
.
class
)
@DELETE
...
...
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/authentication/BaseAction.java
浏览文件 @
dcf9fed7
...
...
@@ -159,10 +159,9 @@ abstract class BaseAction extends StandardJaxrsAction {
return
em
.
createQuery
(
cq
).
getResultList
().
stream
().
distinct
().
collect
(
Collectors
.
toList
());
}
protected
String
password
(
Wi
wi
)
throws
Exception
{
return
BooleanUtils
.
isTrue
(
Config
.
token
().
getRsaEnable
())
?
Crypto
.
rsaDecrypt
(
wi
.
getPassword
(),
Config
.
privateKey
())
:
wi
.
getPassword
();
protected
String
password
(
String
password
)
throws
Exception
{
return
BooleanUtils
.
isTrue
(
Config
.
token
().
getRsaEnable
())
?
Crypto
.
rsaDecrypt
(
password
,
Config
.
privateKey
())
:
password
;
}
protected
Person
personLogin
(
Business
business
,
String
id
,
String
password
)
throws
Exception
{
...
...
o2server/x_organization_core_express/src/main/java/com/x/organization/core/express/assemble/authentication/jaxrs/authentication/ActionLoginWi.java
0 → 100644
浏览文件 @
dcf9fed7
package
com.x.organization.core.express.assemble.authentication.jaxrs.authentication
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
io.swagger.v3.oas.annotations.media.Schema
;
public
class
ActionLoginWi
extends
GsonPropertyObject
{
private
static
final
long
serialVersionUID
=
633273224231633398L
;
@FieldDescribe
(
"用户标识."
)
@Schema
(
description
=
"用户标识."
)
private
String
credential
;
@FieldDescribe
(
"密码."
)
@Schema
(
description
=
"密码."
)
private
String
password
;
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getCredential
()
{
return
credential
;
}
public
void
setCredential
(
String
credential
)
{
this
.
credential
=
credential
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录