Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
187d78ad
o2oa
项目概览
weixin_42566577
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
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,发现更多精彩内容 >>
提交
187d78ad
编写于
8月 17, 2022
作者:
U
unknown
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into develop
上级
e195685f
0385248a
变更
37
隐藏空白更改
内联
并排
Showing
37 changed file
with
397 addition
and
388 deletion
+397
-388
o2server/x_attendance_assemble_control/src/main/java/com/x/attendance/assemble/control/jaxrs/attachment/ActionImportFileUpload.java
...mble/control/jaxrs/attachment/ActionImportFileUpload.java
+35
-43
o2server/x_attendance_assemble_control/src/main/java/com/x/attendance/assemble/control/jaxrs/attachment/ExceptionErrorExtension.java
...ble/control/jaxrs/attachment/ExceptionErrorExtension.java
+12
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/ApplicationServer.java
...ava/com/x/base/core/project/config/ApplicationServer.java
+9
-35
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/CenterServer.java
...ain/java/com/x/base/core/project/config/CenterServer.java
+9
-35
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Config.java
.../src/main/java/com/x/base/core/project/config/Config.java
+6
-121
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/General.java
...src/main/java/com/x/base/core/project/config/General.java
+49
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Node.java
...ct/src/main/java/com/x/base/core/project/config/Node.java
+5
-5
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/TernaryManagement.java
...ava/com/x/base/core/project/config/TernaryManagement.java
+9
-3
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Token.java
...t/src/main/java/com/x/base/core/project/config/Token.java
+3
-3
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/WebServer.java
...c/main/java/com/x/base/core/project/config/WebServer.java
+7
-25
o2server/x_base_core_project/src/main/java/com/x/base/core/project/connection/CipherConnectionAction.java
.../base/core/project/connection/CipherConnectionAction.java
+20
-20
o2server/x_base_core_project/src/main/java/com/x/base/core/project/http/FilterTools.java
...c/main/java/com/x/base/core/project/http/FilterTools.java
+19
-17
o2server/x_base_core_project/src/main/java/com/x/base/core/project/http/HttpToken.java
...src/main/java/com/x/base/core/project/http/HttpToken.java
+33
-30
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/AbstractJaxrsAction.java
...va/com/x/base/core/project/jaxrs/AbstractJaxrsAction.java
+1
-1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/AnonymousCipherManagerUserJaxrsFilter.java
.../project/jaxrs/AnonymousCipherManagerUserJaxrsFilter.java
+5
-1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/AnonymousJaxrsFilter.java
...a/com/x/base/core/project/jaxrs/AnonymousJaxrsFilter.java
+1
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/CipherJaxrsFilter.java
...java/com/x/base/core/project/jaxrs/CipherJaxrsFilter.java
+12
-9
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/CipherManagerJaxrsFilter.java
...m/x/base/core/project/jaxrs/CipherManagerJaxrsFilter.java
+1
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/CipherManagerUserJaxrsFilter.java
...base/core/project/jaxrs/CipherManagerUserJaxrsFilter.java
+1
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/ManagerUserJaxrsFilter.java
...com/x/base/core/project/jaxrs/ManagerUserJaxrsFilter.java
+1
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/TokenFilter.java
.../main/java/com/x/base/core/project/jaxrs/TokenFilter.java
+37
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/UserJaxrsFilter.java
...n/java/com/x/base/core/project/jaxrs/UserJaxrsFilter.java
+1
-0
o2server/x_console/src/main/java/com/x/server/console/server/application/ApplicationServerTools.java
...er/console/server/application/ApplicationServerTools.java
+5
-6
o2server/x_console/src/main/java/com/x/server/console/server/center/CenterServerTools.java
...com/x/server/console/server/center/CenterServerTools.java
+5
-5
o2server/x_console/src/main/java/com/x/server/console/server/web/WebServerTools.java
.../java/com/x/server/console/server/web/WebServerTools.java
+3
-3
o2server/x_message_assemble_communicate/src/main/java/com/x/message/assemble/communicate/ws/collaboration/ActionCollaboration.java
...ble/communicate/ws/collaboration/ActionCollaboration.java
+2
-2
o2server/x_message_assemble_communicate/src/main/java/com/x/message/assemble/communicate/ws/collaboration/WsConfigurator.java
...assemble/communicate/ws/collaboration/WsConfigurator.java
+1
-1
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/authentication/ActionWho.java
...semble/authentication/jaxrs/authentication/ActionWho.java
+3
-3
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/oauth/ActionInfo.java
...ation/assemble/authentication/jaxrs/oauth/ActionInfo.java
+1
-1
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionChangeOrderNumber.java
...ble/surface/jaxrs/attachment/ActionChangeOrderNumber.java
+1
-1
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWithUrl.java
...ssemble/surface/jaxrs/attachment/ActionUploadWithUrl.java
+3
-3
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWithWorkCompleted.java
...rface/jaxrs/attachment/ActionUploadWithWorkCompleted.java
+1
-4
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWorkInfo.java
...semble/surface/jaxrs/attachment/ActionUploadWorkInfo.java
+2
-2
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/BaseAction.java
...latform/assemble/surface/jaxrs/attachment/BaseAction.java
+7
-7
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/serialnumber/ActionCreate.java
...orm/assemble/surface/jaxrs/serialnumber/ActionCreate.java
+66
-0
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/serialnumber/SerialNumberAction.java
...semble/surface/jaxrs/serialnumber/SerialNumberAction.java
+17
-0
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/ActionRollback.java
...ervice/processing/jaxrs/workcompleted/ActionRollback.java
+4
-2
未找到文件。
o2server/x_attendance_assemble_control/src/main/java/com/x/attendance/assemble/control/jaxrs/attachment/ActionImportFileUpload.java
浏览文件 @
187d78ad
...
...
@@ -3,7 +3,10 @@ package com.x.attendance.assemble.control.jaxrs.attachment;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.OutputStream
;
import
java.lang.reflect.Array
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -27,51 +30,40 @@ import com.x.base.core.project.logger.Logger;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.DefaultCharset
;
public
class
ActionImportFileUpload
{
/**
* @author sword
*/
public
class
ActionImportFileUpload
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionImportFileUpload
.
class
);
private
static
final
List
<
String
>
EXCEL_EXTENSIONS
=
Arrays
.
asList
(
"xls"
,
"xlsx"
);
public
static
class
Wo
extends
WoId
{
}
protected
ActionResult
<
WrapOutId
>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
byte
[]
bytes
,
FormDataContentDisposition
disposition
)
{
protected
ActionResult
<
WrapOutId
>
execute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
,
byte
[]
bytes
,
FormDataContentDisposition
disposition
)
throws
Exception
{
ActionResult
<
WrapOutId
>
result
=
new
ActionResult
<>();
AttendanceImportFileInfo
importFile
=
null
;
String
fileName
=
null
;
String
fileName
=
this
.
fileName
(
disposition
);
Boolean
check
=
true
;
try
{
fileName
=
FilenameUtils
.
getName
(
new
String
(
disposition
.
getFileName
().
getBytes
(
DefaultCharset
.
name_iso_8859_1
),
DefaultCharset
.
name
));
}
catch
(
Exception
e
)
{
check
=
false
;
Exception
exception
=
new
ExceptionGetFileName
(
e
);
result
.
error
(
exception
);
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
if
(
StringUtils
.
isEmpty
(
fileName
)
||
StringUtils
.
isEmpty
(
FilenameUtils
.
getExtension
(
fileName
)))
{
throw
new
ExceptionEmptyExtension
(
fileName
);
}
if
(
check
)
{
/** 禁止不带扩展名的文件上传 */
if
(
StringUtils
.
isEmpty
(
fileName
))
{
check
=
false
;
Exception
exception
=
new
ExceptionEmptyExtension
(
fileName
);
result
.
error
(
exception
);
logger
.
error
(
exception
,
effectivePerson
,
request
,
null
);
}
}
if
(
check
)
{
importFile
=
new
AttendanceImportFileInfo
();
importFile
.
setId
(
AttendanceImportFileInfo
.
createId
()
);
importFile
.
setExtension
(
FilenameUtils
.
getExtension
(
fileName
)
);
importFile
.
setFileBody
(
bytes
);
importFile
.
setFileName
(
fileName
);
importFile
.
setName
(
fileName
);
importFile
.
setCreatorUid
(
effectivePerson
.
getDistinguishedName
()
);
importFile
.
setCreateTime
(
new
Date
()
);
importFile
.
setLastUpdateTime
(
new
Date
()
);
importFile
.
setLength
(
Long
.
parseLong
(
bytes
.
length
+
""
)
);
if
(!
EXCEL_EXTENSIONS
.
contains
(
FilenameUtils
.
getExtension
(
fileName
).
toLowerCase
())){
throw
new
ExceptionErrorExtension
(
fileName
);
}
AttendanceImportFileInfo
importFile
=
new
AttendanceImportFileInfo
();
importFile
.
setId
(
AttendanceImportFileInfo
.
createId
()
);
importFile
.
setExtension
(
FilenameUtils
.
getExtension
(
fileName
)
);
importFile
.
setFileBody
(
bytes
);
importFile
.
setFileName
(
fileName
);
importFile
.
setName
(
fileName
);
importFile
.
setCreatorUid
(
effectivePerson
.
getDistinguishedName
()
);
importFile
.
setCreateTime
(
new
Date
()
);
importFile
.
setLastUpdateTime
(
new
Date
()
);
importFile
.
setLength
(
Long
.
parseLong
(
bytes
.
length
+
""
)
);
if
(
check
)
{
try
{
checkDataInFile
(
importFile
.
getId
(),
fileName
,
bytes
,
effectivePerson
);
...
...
@@ -93,11 +85,11 @@ public class ActionImportFileUpload {
result
.
error
(
exception
);
logger
.
error
(
exception
,
effectivePerson
,
request
,
null
);
}
}
}
return
result
;
}
private
void
saveFile
(
AttendanceImportFileInfo
importFile
)
throws
Exception
{
private
void
saveFile
(
AttendanceImportFileInfo
importFile
)
throws
Exception
{
// 将所有的附件信息存储到数据库里
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
emc
.
beginTransaction
(
AttendanceImportFileInfo
.
class
);
...
...
@@ -107,7 +99,7 @@ public class ActionImportFileUpload {
throw
ex
;
}
}
private
void
checkDataInFile
(
String
id
,
String
fileName
,
byte
[]
content
,
EffectivePerson
effectivePerson
)
throws
ExceptionFileImportProcess
{
// 将文件到应用服务器形成本地文件
String
importFilePath
=
"./servers/applicationServer/work/x_attendance_assemble_control/temp/"
;
...
...
@@ -123,8 +115,8 @@ public class ActionImportFileUpload {
file
.
delete
();
}
file
.
createNewFile
();
try
{
output
=
new
FileOutputStream
(
importFilePath
+
importFileName
);
//output = new FileOutputStream(file);
...
...
@@ -140,10 +132,10 @@ public class ActionImportFileUpload {
logger
.
warn
(
"将文件写入到本地文件时发生异常."
);
logger
.
error
(
e
);
}
StatusSystemImportOpt
.
getInstance
().
cleanCacheImportFileStatus
(
id
);
StatusSystemImportOpt
.
getInstance
().
getCacheImportFileStatus
(
id
).
setFilePath
(
importFilePath
+
importFileName
);
// 然后进行数据检查
IRowReader
reader
=
new
ImportExcelReader
();
try
{
...
...
o2server/x_attendance_assemble_control/src/main/java/com/x/attendance/assemble/control/jaxrs/attachment/ExceptionErrorExtension.java
0 → 100644
浏览文件 @
187d78ad
package
com.x.attendance.assemble.control.jaxrs.attachment
;
import
com.x.base.core.project.exception.PromptException
;
class
ExceptionErrorExtension
extends
PromptException
{
private
static
final
long
serialVersionUID
=
-
5943995811411212155L
;
public
ExceptionErrorExtension
(
String
name
)
{
super
(
"错误的文件类型: {}."
,
name
);
}
}
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/ApplicationServer.java
浏览文件 @
187d78ad
...
...
@@ -12,26 +12,18 @@ public class ApplicationServer extends ConfigObject {
private
static
final
long
serialVersionUID
=
4182216855396608843L
;
public
static
ApplicationServer
defaultInstance
()
{
return
new
ApplicationServer
();
ApplicationServer
o
=
new
ApplicationServer
();
o
.
enable
=
true
;
o
.
port
=
DEFAULT_PORT
;
o
.
sslEnable
=
false
;
o
.
proxyHost
=
""
;
o
.
proxyPort
=
DEFAULT_PORT
;
o
.
includes
=
new
CopyOnWriteArrayList
<>();
o
.
excludes
=
new
CopyOnWriteArrayList
<>();
return
o
;
}
private
static
final
Integer
DEFAULT_PORT
=
80
;
private
static
final
Boolean
DEFAULT_STATENABLE
=
true
;
private
static
final
String
DEFAULT_STATEXCLUSIONS
=
"*.js,*.gif,*.jpg,*.png,*.css,*.ico"
;
private
static
final
Boolean
DEFAULT_EXPOSEJEST
=
true
;
public
ApplicationServer
()
{
this
.
enable
=
true
;
this
.
port
=
DEFAULT_PORT
;
this
.
sslEnable
=
false
;
this
.
proxyHost
=
""
;
this
.
proxyPort
=
DEFAULT_PORT
;
this
.
includes
=
new
CopyOnWriteArrayList
<>();
this
.
excludes
=
new
CopyOnWriteArrayList
<>();
this
.
statEnable
=
DEFAULT_STATENABLE
;
this
.
statExclusions
=
DEFAULT_STATEXCLUSIONS
;
this
.
exposeJest
=
DEFAULT_EXPOSEJEST
;
}
@FieldDescribe
(
"是否启用"
)
private
Boolean
enable
;
...
...
@@ -47,24 +39,6 @@ public class ApplicationServer extends ConfigObject {
private
CopyOnWriteArrayList
<
String
>
includes
;
@FieldDescribe
(
"选择不承载的应用,和includes的值配合使用可以选择或者排除承载的应用,可以使用*作为通配符."
)
private
CopyOnWriteArrayList
<
String
>
excludes
;
@FieldDescribe
(
"启用统计,默认启用统计."
)
private
Boolean
statEnable
;
@FieldDescribe
(
"统计忽略路径,默认忽略*.js,*.gif,*.jpg,*.png,*.css,*.ico"
)
private
String
statExclusions
;
@FieldDescribe
(
"暴露jest接口."
)
private
Boolean
exposeJest
;
public
Boolean
getExposeJest
()
{
return
BooleanUtils
.
isNotFalse
(
this
.
exposeJest
);
}
public
String
getStatExclusions
()
{
return
(
StringUtils
.
isEmpty
(
statExclusions
)
?
DEFAULT_STATEXCLUSIONS
:
this
.
statExclusions
)
+
",/druid/*"
;
}
public
Boolean
getStatEnable
()
{
return
BooleanUtils
.
isNotFalse
(
statEnable
);
}
public
Boolean
getEnable
()
{
return
BooleanUtils
.
isTrue
(
this
.
enable
);
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/CenterServer.java
浏览文件 @
187d78ad
...
...
@@ -19,25 +19,17 @@ public class CenterServer extends ConfigObject {
private
static
final
Boolean
DEFAULT_ENABLE
=
true
;
private
static
final
Integer
DEFAULT_PORT
=
80
;
private
static
final
Integer
DEFAULT_ORDER
=
0
;
private
static
final
Boolean
DEFAULT_STATENABLE
=
true
;
private
static
final
String
DEFAULT_STATEXCLUSIONS
=
"*.js,*.gif,*.jpg,*.png,*.css,*.ico"
;
private
static
final
Boolean
DEFAULT_EXPOSEJEST
=
true
;
public
static
CenterServer
defaultInstance
()
{
return
new
CenterServer
();
}
public
CenterServer
()
{
this
.
enable
=
DEFAULT_ENABLE
;
this
.
sslEnable
=
false
;
this
.
order
=
DEFAULT_ORDER
;
this
.
port
=
DEFAULT_PORT
;
this
.
httpProtocol
=
""
;
this
.
proxyHost
=
""
;
this
.
proxyPort
=
DEFAULT_PORT
;
this
.
statEnable
=
DEFAULT_STATENABLE
;
this
.
statExclusions
=
DEFAULT_STATEXCLUSIONS
;
this
.
exposeJest
=
DEFAULT_EXPOSEJEST
;
CenterServer
o
=
new
CenterServer
();
o
.
enable
=
DEFAULT_ENABLE
;
o
.
sslEnable
=
false
;
o
.
order
=
DEFAULT_ORDER
;
o
.
port
=
DEFAULT_PORT
;
o
.
httpProtocol
=
""
;
o
.
proxyHost
=
""
;
o
.
proxyPort
=
DEFAULT_PORT
;
return
o
;
}
@FieldDescribe
(
"是否启用"
)
...
...
@@ -54,24 +46,6 @@ public class CenterServer extends ConfigObject {
private
String
proxyHost
;
@FieldDescribe
(
"代理端口,当服务器是通过apache/nginx等代理服务器映射到公网或者通过路由器做端口映射,在这样的情况下需要设置此地址以标明公网访问端口."
)
private
Integer
proxyPort
;
@FieldDescribe
(
"启用统计,默认启用统计."
)
private
Boolean
statEnable
;
@FieldDescribe
(
"统计忽略路径,默认忽略*.js,*.gif,*.jpg,*.png,*.css,*.ico"
)
private
String
statExclusions
;
@FieldDescribe
(
"暴露jest接口."
)
private
Boolean
exposeJest
;
public
Boolean
getExposeJest
()
{
return
BooleanUtils
.
isNotFalse
(
this
.
exposeJest
);
}
public
String
getStatExclusions
()
{
return
(
StringUtils
.
isEmpty
(
statExclusions
)
?
DEFAULT_STATEXCLUSIONS
:
this
.
statExclusions
)
+
",/druid/*"
;
}
public
Boolean
getStatEnable
()
{
return
BooleanUtils
.
isNotFalse
(
statEnable
);
}
public
Boolean
getEnable
()
{
return
enable
==
null
?
DEFAULT_ENABLE
:
this
.
enable
;
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Config.java
浏览文件 @
187d78ad
...
...
@@ -882,8 +882,8 @@ public class Config {
String
n
=
resource_node_centersPirmaryNode
();
Integer
p
=
resource_node_centersPirmaryPort
();
Boolean
s
=
resource_node_centersPirmarySslEnable
();
StringBu
ffer
buffer
=
new
StringBuff
er
();
if
(
s
)
{
StringBu
ilder
buffer
=
new
StringBuild
er
();
if
(
BooleanUtils
.
isTrue
(
s
)
)
{
buffer
.
append
(
"https://"
).
append
(
n
);
if
(!
NumberTools
.
valueEuqals
(
p
,
443
))
{
buffer
.
append
(
":"
).
append
(
p
);
...
...
@@ -904,12 +904,11 @@ public class Config {
return
buffer
.
toString
();
}
public
static
String
url_x_program_center_jaxrs
(
Entry
<
String
,
CenterServer
>
entry
,
String
...
paths
)
throws
Exception
{
public
static
String
url_x_program_center_jaxrs
(
Entry
<
String
,
CenterServer
>
entry
,
String
...
paths
)
{
String
n
=
entry
.
getKey
();
Integer
p
=
entry
.
getValue
().
getPort
();
B
oolean
s
=
entry
.
getValue
().
getSslEnable
();
StringBu
ffer
buffer
=
new
StringBuff
er
();
b
oolean
s
=
entry
.
getValue
().
getSslEnable
();
StringBu
ilder
buffer
=
new
StringBuild
er
();
if
(
s
)
{
buffer
.
append
(
"https://"
).
append
(
n
);
if
(!
NumberTools
.
valueEuqals
(
p
,
443
))
{
...
...
@@ -925,7 +924,7 @@ public class Config {
buffer
.
append
(
"/jaxrs/"
);
List
<
String
>
os
=
new
ArrayList
<>();
for
(
String
path
:
paths
)
{
os
.
add
(
URLEncoder
.
encode
(
StringUtils
.
strip
(
path
,
"/"
),
DefaultCharset
.
name
));
os
.
add
(
URLEncoder
.
encode
(
StringUtils
.
strip
(
path
,
"/"
),
StandardCharsets
.
UTF_8
));
}
buffer
.
append
(
StringUtils
.
join
(
os
,
"/"
));
return
buffer
.
toString
();
...
...
@@ -941,123 +940,9 @@ public class Config {
}
instance
().
messages
=
obj
;
}
// if (null == instance().messages) {
// Messages obj = Messages.defaultInstance();
// Messages custom = BaseTools.readConfigObject(PATH_CONFIG_MESSAGES, Messages.class);
// if (null != custom) {
// custom.entrySet().stream().forEach(o -> {
// obj.put(o.getKey(), new Message(o.getValue().getConsumers(), o.getValue().getConsumersV2()));
// });
// }
// instance().messages = obj;
// }
return
instance
().
messages
;
}
// private MessageRestful messageRestful;
//
// public static synchronized MessageRestful messageRestful() throws Exception {
// if (null == instance().messageRestful) {
// MessageRestful obj = BaseTools.readConfigObject(PATH_CONFIG_MESSAGERESTFUL, MessageRestful.class);
// if (null == obj) {
// obj = MessageRestful.defaultInstance();
// }
// instance().messageRestful = obj;
// }
// return instance().messageRestful;
// }
//
// private MessageMq messageMq;
//
// public static synchronized MessageMq messageMq() throws Exception {
// if (null == instance().messageMq) {
// MessageMq obj = BaseTools.readConfigObject(PATH_CONFIG_MESSAGEMQ, MessageMq.class);
// if (null == obj) {
// obj = MessageMq.defaultInstance();
// }
// instance().messageMq = obj;
// }
// return instance().messageMq;
// }
//
// private MessageMail messageMail;
//
// public static synchronized MessageMail messageMail() throws Exception {
// if (null == instance().messageMail) {
// MessageMail obj = BaseTools.readConfigObject(PATH_CONFIG_MESSAGEMAIL, MessageMail.class);
// if (null == obj) {
// obj = MessageMail.defaultInstance();
// }
// instance().messageMail = obj;
// }
// return instance().messageMail;
// }
//
// private MessageApi messageApi;
//
// public static synchronized MessageApi messageApi() throws Exception {
// if (null == instance().messageApi) {
// MessageApi obj = BaseTools.readConfigObject(PATH_CONFIG_MESSAGEAPI, MessageApi.class);
// if (null == obj) {
// obj = MessageApi.defaultInstance();
// }
// instance().messageApi = obj;
// }
// return instance().messageApi;
// }
//
// private MessageJdbc messageJdbc;
//
// public static synchronized MessageJdbc messageJdbc() throws Exception {
// if (null == instance().messageJdbc) {
// MessageJdbc obj = BaseTools.readConfigObject(PATH_CONFIG_MESSAGEJDBC, MessageJdbc.class);
// if (null == obj) {
// obj = MessageJdbc.defaultInstance();
// }
// instance().messageJdbc = obj;
// }
// return instance().messageJdbc;
// }
//
// private MessageTable messageTable;
//
// public static synchronized MessageTable messageTable() throws Exception {
// if (null == instance().messageTable) {
// MessageTable obj = BaseTools.readConfigObject(PATH_CONFIG_MESSAGETABLE, MessageTable.class);
// if (null == obj) {
// obj = MessageTable.defaultInstance();
// }
// instance().messageTable = obj;
// }
// return instance().messageTable;
// }
//
// private MessageHadoop messageHadoop;
//
// public static synchronized MessageHadoop messageHadoop() throws Exception {
// if (null == instance().messageHadoop) {
// MessageHadoop obj = BaseTools.readConfigObject(PATH_CONFIG_MESSAGEHADOOP, MessageHadoop.class);
// if (null == obj) {
// obj = MessageHadoop.defaultInstance();
// }
// instance().messageHadoop = obj;
// }
// return instance().messageHadoop;
// }
// private String messageSendRuleScript;
//
// public static synchronized String messageSendRuleScript() throws Exception {
// if (null == instance().messageSendRuleScript) {
// String scriptStr = BaseTools.readString(PATH_CONFIG_MESSAGES_SEND_RULE);
// if (scriptStr == null) {
// scriptStr = "";
// }
// instance().messageSendRuleScript = scriptStr;
// }
// return instance().messageSendRuleScript;
// }
private
JpushConfig
pushConfig
;
public
static
synchronized
JpushConfig
pushConfig
()
throws
Exception
{
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/General.java
浏览文件 @
187d78ad
...
...
@@ -7,6 +7,7 @@ import java.util.List;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.gson.XGsonBuilder
;
...
...
@@ -27,6 +28,12 @@ public class General extends ConfigObject {
private
static
final
Boolean
DEFAULT_DEPLOYRESOURCEENABLE
=
false
;
private
static
final
Boolean
DEFAULT_DEPLOYWARENABLE
=
false
;
private
static
final
Boolean
DEFAULT_STATENABLE
=
true
;
private
static
final
String
DEFAULT_STATEXCLUSIONS
=
"*.js,*.gif,*.jpg,*.png,*.css,*.ico"
;
private
static
final
Boolean
DEFAULT_EXPOSEJEST
=
true
;
private
static
final
String
DEFAULT_REFERERHEADCHECKREGULAR
=
""
;
private
static
final
String
DEFAULT_ACCESSCONTROLALLOWORIGIN
=
""
;
public
static
General
defaultInstance
()
{
General
o
=
new
General
();
o
.
webSocketEnable
=
DEFAULT_WEBSOCKETENABLE
;
...
...
@@ -37,6 +44,11 @@ public class General extends ConfigObject {
o
.
requestLogBodyEnable
=
DEFAULT_REQUESTLOGBODYENABLE
;
o
.
deployResourceEnable
=
DEFAULT_DEPLOYRESOURCEENABLE
;
o
.
deployWarEnable
=
DEFAULT_DEPLOYWARENABLE
;
o
.
statEnable
=
DEFAULT_STATENABLE
;
o
.
statExclusions
=
DEFAULT_STATEXCLUSIONS
;
o
.
exposeJest
=
DEFAULT_EXPOSEJEST
;
o
.
refererHeadCheckRegular
=
DEFAULT_REFERERHEADCHECKREGULAR
;
o
.
accessControlAllowOrigin
=
DEFAULT_ACCESSCONTROLALLOWORIGIN
;
return
o
;
}
...
...
@@ -61,9 +73,46 @@ public class General extends ConfigObject {
@FieldDescribe
(
"是否允许部署静态资源."
)
private
Boolean
deployResourceEnable
;
@FieldDescribe
(
"启用统计,默认启用统计."
)
private
Boolean
statEnable
;
@FieldDescribe
(
"统计忽略路径,默认忽略*.js,*.gif,*.jpg,*.png,*.css,*.ico"
)
private
String
statExclusions
;
@FieldDescribe
(
"暴露jest接口."
)
private
Boolean
exposeJest
;
@FieldDescribe
(
"脚本中禁止用的类名,保持为空则默认禁用Runtime,File,Path."
)
private
List
<
String
>
scriptingBlockedClasses
;
@FieldDescribe
(
"http referer 校验正则表达式,可以对CSRF攻击进行防护校验,样例:(.+?)o2oa.net(.+?)"
)
private
String
refererHeadCheckRegular
=
""
;
@FieldDescribe
(
"跨源资源共享许可,设置http返回的Access-Control-Allow-Origin标识,可以用于CORS攻击防护,样例:https://www.o2oa.net"
)
private
String
accessControlAllowOrigin
=
""
;
public
String
getRefererHeadCheckRegular
()
{
return
(
StringUtils
.
isBlank
(
refererHeadCheckRegular
)
?
DEFAULT_REFERERHEADCHECKREGULAR
:
this
.
refererHeadCheckRegular
);
}
public
String
getAccessControlAllowOrigin
()
{
return
(
StringUtils
.
isBlank
(
accessControlAllowOrigin
)
?
DEFAULT_ACCESSCONTROLALLOWORIGIN
:
this
.
accessControlAllowOrigin
);
}
public
Boolean
getExposeJest
()
{
return
BooleanUtils
.
isNotFalse
(
this
.
exposeJest
);
}
public
String
getStatExclusions
()
{
return
(
StringUtils
.
isEmpty
(
statExclusions
)
?
DEFAULT_STATEXCLUSIONS
:
this
.
statExclusions
)
+
",/druid/*"
;
}
public
Boolean
getStatEnable
()
{
return
BooleanUtils
.
isNotFalse
(
statEnable
);
}
public
Boolean
getRequestLogEnable
()
{
return
BooleanUtils
.
isTrue
(
this
.
requestLogEnable
);
}
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Node.java
浏览文件 @
187d78ad
...
...
@@ -4,7 +4,7 @@ import org.apache.commons.lang3.BooleanUtils;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.tools.
Date
Tools
;
import
com.x.base.core.project.tools.
Cron
Tools
;
import
com.x.base.core.project.tools.NumberTools
;
public
class
Node
extends
ConfigObject
{
...
...
@@ -14,7 +14,7 @@ public class Node extends ConfigObject {
private
static
final
Integer
DEFAULT_NODEAGENTPORT
=
20010
;
private
static
final
String
DEFAULT_BANNER
=
"O2OA"
;
private
static
final
Boolean
DEFAULT_SELFHEALTHCHECKENABLE
=
false
;
//private static final Integer DEFAULT_ORDER = 0;
//
private static final Integer DEFAULT_ORDER = 0;
public
static
Node
defaultInstance
()
{
Node
o
=
new
Node
();
...
...
@@ -31,7 +31,7 @@ public class Node extends ConfigObject {
o
.
nodeAgentPort
=
DEFAULT_NODEAGENTPORT
;
o
.
autoStart
=
true
;
o
.
selfHealthCheckEnable
=
DEFAULT_SELFHEALTHCHECKENABLE
;
//o.order = DEFAULT_ORDER;
//
o.order = DEFAULT_ORDER;
return
o
;
}
...
...
@@ -148,7 +148,7 @@ public class Node extends ConfigObject {
}
public
boolean
available
()
{
return
DateTools
.
cronA
vailable
(
this
.
cron
());
return
CronTools
.
a
vailable
(
this
.
cron
());
}
@FieldDescribe
(
"是否启用,默认禁用."
)
...
...
@@ -190,7 +190,7 @@ public class Node extends ConfigObject {
}
public
boolean
available
()
{
return
DateTools
.
cronA
vailable
(
this
.
cron
)
&&
StringUtils
.
isNotEmpty
(
this
.
path
);
return
CronTools
.
a
vailable
(
this
.
cron
)
&&
StringUtils
.
isNotEmpty
(
this
.
path
);
}
@FieldDescribe
(
"是否启用."
)
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/TernaryManagement.java
浏览文件 @
187d78ad
...
...
@@ -334,7 +334,9 @@ public class TernaryManagement extends ConfigObject {
return
this
.
_systemManagerPassword
;
}
public
void
setSystemManagerPassword
(
String
systemManagerPassword
)
throws
InvalidKeyException
,
NoSuchAlgorithmException
,
InvalidKeySpecException
,
NoSuchPaddingException
,
IllegalBlockSizeException
,
BadPaddingException
,
UnsupportedEncodingException
{
public
void
setSystemManagerPassword
(
String
systemManagerPassword
)
throws
InvalidKeyException
,
NoSuchAlgorithmException
,
InvalidKeySpecException
,
NoSuchPaddingException
,
IllegalBlockSizeException
,
BadPaddingException
,
UnsupportedEncodingException
{
this
.
systemManagerPassword
=
Crypto
.
formattedDefaultEncrypt
(
systemManagerPassword
);
}
...
...
@@ -347,7 +349,9 @@ public class TernaryManagement extends ConfigObject {
return
this
.
_securityManagerPassword
;
}
public
void
setSecurityManagerPassword
(
String
securityManagerPassword
)
throws
InvalidKeyException
,
NoSuchAlgorithmException
,
InvalidKeySpecException
,
NoSuchPaddingException
,
IllegalBlockSizeException
,
BadPaddingException
,
UnsupportedEncodingException
{
public
void
setSecurityManagerPassword
(
String
securityManagerPassword
)
throws
InvalidKeyException
,
NoSuchAlgorithmException
,
InvalidKeySpecException
,
NoSuchPaddingException
,
IllegalBlockSizeException
,
BadPaddingException
,
UnsupportedEncodingException
{
this
.
securityManagerPassword
=
Crypto
.
formattedDefaultEncrypt
(
securityManagerPassword
);
}
...
...
@@ -359,7 +363,9 @@ public class TernaryManagement extends ConfigObject {
return
this
.
_auditManagerPassword
;
}
public
void
setAuditManagerPassword
(
String
auditManagerPassword
)
throws
InvalidKeyException
,
NoSuchAlgorithmException
,
InvalidKeySpecException
,
NoSuchPaddingException
,
IllegalBlockSizeException
,
BadPaddingException
,
UnsupportedEncodingException
{
public
void
setAuditManagerPassword
(
String
auditManagerPassword
)
throws
InvalidKeyException
,
NoSuchAlgorithmException
,
InvalidKeySpecException
,
NoSuchPaddingException
,
IllegalBlockSizeException
,
BadPaddingException
,
UnsupportedEncodingException
{
this
.
auditManagerPassword
=
Crypto
.
formattedDefaultEncrypt
(
auditManagerPassword
);
}
}
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Token.java
浏览文件 @
187d78ad
...
...
@@ -168,14 +168,14 @@ public class Token extends ConfigObject {
public
List
<
Oauth
>
getOauths
()
{
if
(
null
==
this
.
oauths
)
{
return
new
ArrayList
<
Oauth
>();
return
new
ArrayList
<>();
}
return
this
.
oauths
;
}
public
List
<
Sso
>
getSsos
()
{
if
(
null
==
this
.
ssos
)
{
return
new
ArrayList
<
Sso
>();
return
new
ArrayList
<>();
}
return
this
.
ssos
;
}
...
...
@@ -232,7 +232,7 @@ public class Token extends ConfigObject {
o
.
qq
=
""
;
o
.
weibo
=
""
;
o
.
mobile
=
""
;
o
.
roleList
=
new
ArrayList
<
String
>();
o
.
roleList
=
new
ArrayList
<>();
o
.
roleList
.
add
(
OrganizationDefinition
.
toDistinguishedName
(
OrganizationDefinition
.
Manager
));
o
.
roleList
.
add
(
OrganizationDefinition
.
toDistinguishedName
(
OrganizationDefinition
.
OrganizationManager
));
o
.
roleList
.
add
(
OrganizationDefinition
.
toDistinguishedName
(
OrganizationDefinition
.
MeetingManager
));
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/WebServer.java
浏览文件 @
187d78ad
...
...
@@ -10,23 +10,17 @@ public class WebServer extends ConfigObject {
private
static
final
long
serialVersionUID
=
7240874589722986538L
;
public
static
WebServer
defaultInstance
()
{
return
new
WebServer
();
}
public
WebServer
()
{
this
.
enable
=
true
;
this
.
port
=
DEFAULT_HTTP_PORT
;
this
.
sslEnable
=
false
;
this
.
proxyHost
=
""
;
this
.
proxyPort
=
null
;
this
.
statEnable
=
DEFAULT_STATENABLE
;
this
.
statExclusions
=
DEFAULT_STATEXCLUSIONS
;
WebServer
o
=
new
WebServer
();
o
.
enable
=
true
;
o
.
port
=
DEFAULT_HTTP_PORT
;
o
.
sslEnable
=
false
;
o
.
proxyHost
=
""
;
o
.
proxyPort
=
null
;
return
o
;
}
private
static
final
Integer
DEFAULT_HTTP_PORT
=
80
;
private
static
final
Integer
DEFAULT_HTTPS_PORT
=
443
;
private
static
final
Boolean
DEFAULT_STATENABLE
=
false
;
private
static
final
String
DEFAULT_STATEXCLUSIONS
=
"*.gif,*.jpg,*.png,*.ico"
;
private
static
final
Boolean
DEFAULT_PROXYCENTERENABLE
=
true
;
private
static
final
Boolean
DEFAULT_PROXYAPPLICATIONENABLE
=
true
;
private
static
final
Integer
DEFAULT_PROXY_TIMEOUT
=
300
;
...
...
@@ -41,10 +35,6 @@ public class WebServer extends ConfigObject {
private
String
proxyHost
;
@FieldDescribe
(
"代理端口,当服务器是通过apache/nginx等代理服务器映射到公网或者通过路由器做端口映射,在这样的情况下需要设置此地址以标明公网访问端口."
)
private
Integer
proxyPort
;
@FieldDescribe
(
"启用统计,默认启用统计."
)
private
Boolean
statEnable
;
@FieldDescribe
(
"统计忽略路径,默认忽略*.gif,*.jpg,*.png,*.ico"
)
private
String
statExclusions
;
@FieldDescribe
(
"是否启用center服务器代理."
)
private
Boolean
proxyCenterEnable
;
...
...
@@ -63,14 +53,6 @@ public class WebServer extends ConfigObject {
return
proxyApplicationEnable
==
null
?
DEFAULT_PROXYAPPLICATIONENABLE
:
this
.
proxyApplicationEnable
;
}
public
String
getStatExclusions
()
{
return
(
StringUtils
.
isEmpty
(
statExclusions
)
?
DEFAULT_STATEXCLUSIONS
:
this
.
statExclusions
)
+
",/druid/*"
;
}
public
Boolean
getStatEnable
()
{
return
BooleanUtils
.
isNotFalse
(
statEnable
);
}
public
Boolean
getEnable
()
{
return
BooleanUtils
.
isTrue
(
this
.
enable
);
}
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/connection/CipherConnectionAction.java
浏览文件 @
187d78ad
...
...
@@ -22,7 +22,7 @@ public class CipherConnectionAction {
public
static
ActionResponse
get
(
Boolean
xdebugger
,
String
address
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
get
(
address
,
headers
);
}
...
...
@@ -31,7 +31,7 @@ public class CipherConnectionAction {
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
get
(
connectTimeout
,
readTimeout
,
address
,
headers
);
}
...
...
@@ -50,7 +50,7 @@ public class CipherConnectionAction {
public
static
byte
[]
getBinary
(
Boolean
xdebugger
,
String
address
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
getBinary
(
address
,
headers
);
}
...
...
@@ -59,7 +59,7 @@ public class CipherConnectionAction {
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
getBinary
(
connectTimeout
,
readTimeout
,
address
,
headers
);
}
...
...
@@ -78,7 +78,7 @@ public class CipherConnectionAction {
public
static
ActionResponse
delete
(
Boolean
xdebugger
,
String
address
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
delete
(
address
,
headers
);
}
...
...
@@ -87,7 +87,7 @@ public class CipherConnectionAction {
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
delete
(
connectTimeout
,
readTimeout
,
address
,
headers
);
}
...
...
@@ -106,7 +106,7 @@ public class CipherConnectionAction {
public
static
byte
[]
deleteBinary
(
Boolean
xdebugger
,
String
address
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
deleteBinary
(
address
,
headers
);
}
...
...
@@ -115,7 +115,7 @@ public class CipherConnectionAction {
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
deleteBinary
(
connectTimeout
,
readTimeout
,
address
,
headers
);
}
...
...
@@ -134,7 +134,7 @@ public class CipherConnectionAction {
public
static
ActionResponse
post
(
Boolean
xdebugger
,
String
address
,
Object
body
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
post
(
address
,
headers
,
body
);
}
...
...
@@ -143,7 +143,7 @@ public class CipherConnectionAction {
Object
body
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
post
(
connectTimeout
,
readTimeout
,
address
,
headers
,
body
);
}
...
...
@@ -163,7 +163,7 @@ public class CipherConnectionAction {
public
static
byte
[]
postBinary
(
Boolean
xdebugger
,
String
address
,
Object
body
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
postBinary
(
address
,
headers
,
body
);
}
...
...
@@ -172,7 +172,7 @@ public class CipherConnectionAction {
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
postBinary
(
connectTimeout
,
readTimeout
,
address
,
headers
,
body
);
}
...
...
@@ -193,7 +193,7 @@ public class CipherConnectionAction {
Collection
<
FilePart
>
fileParts
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
postMultiPartBinary
(
address
,
headers
,
formFields
,
fileParts
);
}
...
...
@@ -202,7 +202,7 @@ public class CipherConnectionAction {
Collection
<
FormField
>
formFields
,
Collection
<
FilePart
>
fileParts
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
postMultiPartBinary
(
connectTimeout
,
readTimeout
,
address
,
headers
,
formFields
,
fileParts
);
...
...
@@ -224,7 +224,7 @@ public class CipherConnectionAction {
public
static
ActionResponse
put
(
Boolean
xdebugger
,
String
address
,
Object
body
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
put
(
address
,
headers
,
body
);
}
...
...
@@ -233,7 +233,7 @@ public class CipherConnectionAction {
Object
body
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
put
(
connectTimeout
,
readTimeout
,
address
,
headers
,
body
);
}
...
...
@@ -253,7 +253,7 @@ public class CipherConnectionAction {
public
static
byte
[]
putBinary
(
Boolean
xdebugger
,
String
address
,
Object
body
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
putBinary
(
address
,
headers
,
body
);
}
...
...
@@ -262,7 +262,7 @@ public class CipherConnectionAction {
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
putBinary
(
connectTimeout
,
readTimeout
,
address
,
headers
,
body
);
}
...
...
@@ -283,7 +283,7 @@ public class CipherConnectionAction {
Collection
<
FilePart
>
fileParts
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
putMultiPartBinary
(
address
,
headers
,
formFields
,
fileParts
);
}
...
...
@@ -292,7 +292,7 @@ public class CipherConnectionAction {
Collection
<
FormField
>
formFields
,
Collection
<
FilePart
>
fileParts
)
throws
Exception
{
List
<
NameValuePair
>
headers
=
cipher
();
if
(
BooleanUtils
.
isTrue
(
xdebugger
))
{
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
ebugger
,
true
));
headers
.
add
(
new
NameValuePair
(
HttpToken
.
X_D
EBUGGER
,
true
));
}
return
ConnectionAction
.
putMultiPartBinary
(
connectTimeout
,
readTimeout
,
address
,
headers
,
formFields
,
fileParts
);
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/http/FilterTools.java
浏览文件 @
187d78ad
...
...
@@ -5,30 +5,32 @@ import javax.servlet.http.HttpServletResponse;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.common.net.HttpHeaders
;
import
com.x.base.core.project.config.Config
;
public
class
FilterTools
{
public
static
final
String
Access_Control_Allow_Origin
=
"Access-Control-Allow-Origin"
;
public
static
final
String
ORIGIN
=
"Origin"
;
public
static
final
String
Access_Control_Allow_Methods
=
"Access-Control-Allow-Methods"
;
public
static
final
String
Access_Control_Allow_Methods_Value
=
"GET, POST, OPTIONS, PUT, DELETE, HEAD, TRACE"
;
public
static
final
String
Access_Control_Allow_Headers
=
"Access-Control-Allow-Headers"
;
public
static
final
String
Access_Control_Allow_Headers_Value
=
"x-requested-with, x-request, c-token, Content-Type, Content-Length, x-cipher, x-client, x-debugger, Authorization, P-User-Id, P-Request-Id, P-Page-Id"
;
public
static
final
String
Access_Control_Allow_Credentials
=
"Access-Control-Allow-Credentials"
;
public
static
final
String
Access_Control_Expose_Headers
=
"Access-Control-Expose-Headers"
;
public
static
final
String
Access_Control_Max_Age
=
"Access-Control-Max-Age"
;
public
static
final
String
Access_Control_Max_Age_Value
=
"86400"
;
public
static
final
String
ACCESS_CONTROL_ALLOW_METHODS_VALUE
=
"GET, POST, OPTIONS, PUT, DELETE, HEAD, TRACE"
;
public
static
final
String
ACCESS_CONTROL_ALLOW_HEADERS_VALUE
=
"x-requested-with, x-request, c-token, Content-Type, Content-Length, x-cipher, x-client, x-debugger, Authorization, P-User-Id, P-Request-Id, P-Page-Id"
;
public
static
final
String
ACCESS_CONTROL_MAX_AGE_VALUE
=
"86400"
;
public
static
void
allow
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
String
origin
=
request
.
getHeader
(
ORIGIN
);
response
.
addHeader
(
Access_Control_Allow_Origin
,
StringUtils
.
isBlank
(
origin
)
?
"*"
:
origin
);
response
.
addHeader
(
Access_Control_Allow_Methods
,
Access_Control_Allow_Methods_Value
);
response
.
addHeader
(
Access_Control_Allow_Headers
,
Access_Control_Allow_Headers_Value
+
", "
+
Config
.
person
().
getTokenName
());
response
.
addHeader
(
Access_Control_Allow_Credentials
,
"true"
);
response
.
setHeader
(
Access_Control_Expose_Headers
,
"c-token"
+
", "
+
Config
.
person
().
getTokenName
());
response
.
setHeader
(
Access_Control_Max_Age
,
Access_Control_Max_Age_Value
);
if
(
StringUtils
.
isNotBlank
(
Config
.
general
().
getAccessControlAllowOrigin
()))
{
response
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_ORIGIN
,
Config
.
general
().
getAccessControlAllowOrigin
());
}
else
{
String
origin
=
request
.
getHeader
(
HttpHeaders
.
ORIGIN
);
if
(
StringUtils
.
isNotBlank
(
origin
))
{
response
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_ORIGIN
,
origin
);
}
}
response
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_METHODS
,
ACCESS_CONTROL_ALLOW_METHODS_VALUE
);
response
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_HEADERS
,
ACCESS_CONTROL_ALLOW_HEADERS_VALUE
+
", "
+
Config
.
person
().
getTokenName
());
response
.
addHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_CREDENTIALS
,
"true"
);
response
.
setHeader
(
HttpHeaders
.
ACCESS_CONTROL_EXPOSE_HEADERS
,
"c-token"
+
", "
+
Config
.
person
().
getTokenName
());
response
.
setHeader
(
HttpHeaders
.
ACCESS_CONTROL_MAX_AGE
,
ACCESS_CONTROL_MAX_AGE_VALUE
);
}
public
static
final
String
Application_Not_Initialized_Json
=
"{\"type\": \"error\", \"message\": \"application not initialized.\"}"
;
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/http/HttpToken.java
浏览文件 @
187d78ad
...
...
@@ -27,17 +27,20 @@ public class HttpToken {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
HttpToken
.
class
);
public
static
final
String
X_A
uthorization
=
"authorization"
;
public
static
final
String
X_P
erson
=
"x-person"
;
public
static
final
String
X_A
UTHORIZATION
=
"authorization"
;
public
static
final
String
X_P
ERSON
=
"x-person"
;
public
static
final
String
X_DISTINGUISHEDNAME
=
"x-distinguishedName"
;
public
static
final
String
X_REQUESTBODY
=
"x-requestBody"
;
public
static
final
String
X_C
lient
=
"x-client"
;
public
static
final
String
X_D
ebugger
=
"x-debugger"
;
public
static
final
String
X_C
LIENT
=
"x-client"
;
public
static
final
String
X_D
EBUGGER
=
"x-debugger"
;
public
static
final
String
COOKIE_ANONYMOUS_VALUE
=
"anonymous"
;
public
static
final
String
SET_COOKIE
=
"Set-Cookie"
;
private
static
final
String
RegularExpression_IP
=
"([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}"
;
private
static
final
String
RegularExpression_Token
=
"^(anonymous|user|manager|cipher|systemManager|securityManager|auditManager)([2][0][1-9][0-9][0-1][0-9][0-3][0-9][0-5][0-9][0-5][0-9][0-5][0-9])(\\S{1,})$"
;
private
static
final
String
REGULAREXPRESSION_IP
=
"([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}"
;
private
static
final
String
REGULAREXPRESSION_TOKEN
=
"^(anonymous|user|manager|cipher|systemManager|securityManager|auditManager)([2][0][1-9][0-9][0-1][0-9][0-3][0-9][0-5][0-9][0-5][0-9][0-5][0-9])(\\S{1,})$"
;
private
static
final
String
COOKIE_PART_MIDDLE
=
"; path=/; domain="
;
private
static
final
String
COOKIE_PART_HTTPONLY
=
"; HttpOnly"
;
public
EffectivePerson
who
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
key
)
throws
Exception
{
EffectivePerson
effectivePerson
=
this
.
who
(
this
.
getToken
(
request
),
key
,
remoteAddress
(
request
));
...
...
@@ -45,7 +48,7 @@ public class HttpToken {
effectivePerson
.
setUserAgent
(
this
.
userAgent
(
request
));
effectivePerson
.
setUri
(
request
.
getRequestURI
());
// 加入调试标记
Object
debugger
=
request
.
getHeader
(
HttpToken
.
X_D
ebugger
);
Object
debugger
=
request
.
getHeader
(
HttpToken
.
X_D
EBUGGER
);
effectivePerson
.
setDebugger
((
null
!=
debugger
)
&&
BooleanUtils
.
toBoolean
(
Objects
.
toString
(
debugger
)));
// this.setAttribute(request, effectivePerson);
setToken
(
request
,
response
,
effectivePerson
);
...
...
@@ -65,7 +68,7 @@ public class HttpToken {
logger
.
warn
(
"can not decrypt token:{}, {}, remote address:{}."
,
token
,
e
.
getMessage
(),
address
);
return
EffectivePerson
.
anonymous
();
}
Pattern
pattern
=
Pattern
.
compile
(
R
egularExpression_Token
,
Pattern
.
CASE_INSENSITIVE
);
Pattern
pattern
=
Pattern
.
compile
(
R
EGULAREXPRESSION_TOKEN
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
matcher
=
pattern
.
matcher
(
plain
);
if
(!
matcher
.
find
())
{
// 不报错,跳过错误,将用户设置为anonymous
...
...
@@ -113,13 +116,13 @@ public class HttpToken {
try
{
// String cookie = X_Token + "=; path=/; domain=" +
// this.domain(request) + "; max-age=0
String
cookie
=
Config
.
person
().
getTokenName
()
+
"="
+
COOKIE_ANONYMOUS_VALUE
+
"; path=/; domain="
String
cookie
=
Config
.
person
().
getTokenName
()
+
"="
+
COOKIE_ANONYMOUS_VALUE
+
COOKIE_PART_MIDDLE
+
this
.
domain
(
request
)
+
(
BooleanUtils
.
isTrue
(
Config
.
person
().
getTokenCookieHttpOnly
())
?
"; HttpOnly"
:
""
);
+
(
BooleanUtils
.
isTrue
(
Config
.
person
().
getTokenCookieHttpOnly
())
?
COOKIE_PART_HTTPONLY
:
""
);
response
.
setHeader
(
SET_COOKIE
,
cookie
);
response
.
setHeader
(
Config
.
person
().
getTokenName
(),
COOKIE_ANONYMOUS_VALUE
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"delete Token cookie error."
,
e
);
throw
new
IllegalAccessException
(
"delete Token cookie error."
);
}
}
...
...
@@ -156,9 +159,9 @@ public class HttpToken {
private
void
setResponseToken
(
HttpServletRequest
request
,
HttpServletResponse
response
,
EffectivePerson
effectivePerson
)
throws
Exception
{
if
(!
StringUtils
.
isEmpty
(
effectivePerson
.
getToken
()))
{
String
cookie
=
Config
.
person
().
getTokenName
()
+
"="
+
effectivePerson
.
getToken
()
+
"; path=/; domain="
String
cookie
=
Config
.
person
().
getTokenName
()
+
"="
+
effectivePerson
.
getToken
()
+
COOKIE_PART_MIDDLE
+
this
.
domain
(
request
)
+
(
BooleanUtils
.
isTrue
(
Config
.
person
().
getTokenCookieHttpOnly
())
?
"; HttpOnly"
:
""
);
+
(
BooleanUtils
.
isTrue
(
Config
.
person
().
getTokenCookieHttpOnly
())
?
COOKIE_PART_HTTPONLY
:
""
);
response
.
setHeader
(
SET_COOKIE
,
cookie
);
response
.
setHeader
(
Config
.
person
().
getTokenName
(),
effectivePerson
.
getToken
());
}
...
...
@@ -167,8 +170,8 @@ public class HttpToken {
public
void
setResponseToken
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
tokenName
,
String
token
)
throws
Exception
{
if
(!
StringUtils
.
isEmpty
(
token
))
{
String
cookie
=
tokenName
+
"="
+
token
+
"; path=/; domain="
+
this
.
domain
(
request
)
+
(
BooleanUtils
.
isTrue
(
Config
.
person
().
getTokenCookieHttpOnly
())
?
"; HttpOnly"
:
""
);
String
cookie
=
tokenName
+
"="
+
token
+
COOKIE_PART_MIDDLE
+
this
.
domain
(
request
)
+
(
BooleanUtils
.
isTrue
(
Config
.
person
().
getTokenCookieHttpOnly
())
?
COOKIE_PART_HTTPONLY
:
""
);
response
.
setHeader
(
SET_COOKIE
,
cookie
);
response
.
setHeader
(
tokenName
,
token
);
}
...
...
@@ -177,37 +180,37 @@ public class HttpToken {
public
String
getToken
(
HttpServletRequest
request
)
throws
Exception
{
String
token
=
null
;
token
=
URLTools
.
getQueryStringParameter
(
request
.
getQueryString
(),
Config
.
person
().
getTokenName
());
if
(
StringUtils
.
isEmpty
(
token
))
{
if
(
null
!=
request
.
getCookies
())
{
for
(
Cookie
c
:
request
.
getCookies
())
{
if
(
StringUtils
.
equals
(
Config
.
person
().
getTokenName
(),
c
.
getName
()))
{
token
=
c
.
getValue
();
break
;
}
if
(
StringUtils
.
isEmpty
(
token
)
&&
(
null
!=
request
.
getCookies
()))
{
for
(
Cookie
c
:
request
.
getCookies
())
{
if
(
StringUtils
.
equals
(
Config
.
person
().
getTokenName
(),
c
.
getName
()))
{
token
=
c
.
getValue
();
break
;
}
}
}
if
(
StringUtils
.
isEmpty
(
token
)
||
COOKIE_ANONYMOUS_VALUE
.
equals
(
token
))
{
token
=
request
.
getHeader
(
Config
.
person
().
getTokenName
());
}
// if (BooleanUtils.isTrue(Config.token().getCsrfProtectionEnable()) && (!StringUtils
// .equals(Objects.toString(token, ""), Objects.toString(request.getHeader(X_AUTHORIZATION), "")))) {
// throw new IllegalAccessException("CSFT protection denied.");
// }
if
(
StringUtils
.
isEmpty
(
token
))
{
String
value
=
request
.
getHeader
(
X_AUTHORIZATION
);
// 如果使用oauth bearer 通过此传递认证信息.需要进行判断,格式为 Bearer xxxxxxx
String
value
=
request
.
getHeader
(
X_Authorization
);
if
(!
StringUtils
.
contains
(
value
,
" "
))
{
token
=
value
;
}
}
// 此代码将导致input被关闭.
// if (StringUtils.isEmpty(token)) {
// token = request.getParameter(X_Token);
// }
return
token
;
}
private
String
domain
(
HttpServletRequest
request
)
throws
Exception
{
private
String
domain
(
HttpServletRequest
request
)
{
String
str
=
request
.
getServerName
();
if
(
StringUtils
.
contains
(
str
,
"."
))
{
Pattern
pattern
=
Pattern
.
compile
(
R
egularExpression
_IP
);
Pattern
pattern
=
Pattern
.
compile
(
R
EGULAREXPRESSION
_IP
);
Matcher
matcher
=
pattern
.
matcher
(
str
);
if
(!
matcher
.
find
())
{
if
(
StringUtils
.
equalsIgnoreCase
(
DomainTools
.
getMainDomain
(
str
),
str
))
{
...
...
@@ -221,7 +224,7 @@ public class HttpToken {
}
private
void
setAttribute
(
HttpServletRequest
request
,
EffectivePerson
effectivePerson
)
{
request
.
setAttribute
(
X_P
erson
,
effectivePerson
);
request
.
setAttribute
(
X_P
ERSON
,
effectivePerson
);
request
.
setAttribute
(
X_DISTINGUISHEDNAME
,
effectivePerson
.
getDistinguishedName
());
}
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/AbstractJaxrsAction.java
浏览文件 @
187d78ad
...
...
@@ -46,7 +46,7 @@ abstract class AbstractJaxrsAction {
}
protected
EffectivePerson
effectivePerson
(
HttpServletRequest
request
)
{
Object
o
=
request
.
getAttribute
(
HttpToken
.
X_P
erson
);
Object
o
=
request
.
getAttribute
(
HttpToken
.
X_P
ERSON
);
if
(
null
!=
o
)
{
return
(
EffectivePerson
)
o
;
}
else
{
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/AnonymousCipherManagerUserJaxrsFilter.java
浏览文件 @
187d78ad
...
...
@@ -10,6 +10,9 @@ import javax.servlet.ServletResponse;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.common.net.HttpHeaders
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.http.FilterTools
;
import
com.x.base.core.project.http.HttpToken
;
...
...
@@ -24,13 +27,14 @@ public abstract class AnonymousCipherManagerUserJaxrsFilter extends TokenFilter
try
{
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
HttpServletResponse
response
=
(
HttpServletResponse
)
res
;
httpRequestCheck
(
request
);
FilterTools
.
allow
(
request
,
response
);
if
(!
request
.
getMethod
().
equalsIgnoreCase
(
"options"
))
{
HttpToken
httpToken
=
new
HttpToken
();
httpToken
.
who
(
request
,
response
,
Config
.
token
().
getCipher
());
chain
.
doFilter
(
request
,
response
);
}
else
{
options
(
request
,
response
);
options
(
request
,
response
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/AnonymousJaxrsFilter.java
浏览文件 @
187d78ad
...
...
@@ -26,6 +26,7 @@ public abstract class AnonymousJaxrsFilter extends TokenFilter {
try
{
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
HttpServletResponse
response
=
(
HttpServletResponse
)
res
;
httpRequestCheck
(
request
);
FilterTools
.
allow
(
request
,
response
);
if
(!
request
.
getMethod
().
equalsIgnoreCase
(
"options"
))
{
HttpToken
httpToken
=
new
HttpToken
();
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/CipherJaxrsFilter.java
浏览文件 @
187d78ad
...
...
@@ -31,31 +31,34 @@ public abstract class CipherJaxrsFilter extends TokenFilter {
try
{
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
HttpServletResponse
response
=
(
HttpServletResponse
)
res
;
httpRequestCheck
(
request
);
FilterTools
.
allow
(
request
,
response
);
if
(!
request
.
getMethod
().
equalsIgnoreCase
(
"options"
))
{
HttpToken
httpToken
=
new
HttpToken
();
EffectivePerson
effectivePerson
=
httpToken
.
who
(
request
,
response
,
Config
.
token
().
getCipher
());
if
(
TokenType
.
anonymous
.
equals
(
effectivePerson
.
getTokenType
()))
{
/
** 401 Unauthorized 未登录访问被拒绝 */
/
/ 401 Unauthorized 未登录访问被拒绝
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
setHeader
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
ActionResult
result
=
new
ActionResult
();
ActionResult
<?>
result
=
new
ActionResult
<>
();
ExceptionUnauthorized
e
=
new
ExceptionUnauthorized
();
result
.
error
(
e
);
String
message
=
e
.
getFormatMessage
(
result
.
getPrompt
(),
request
.
getHeader
(
ResponseFactory
.
Accept_Language
));
if
(
StringUtils
.
isNotBlank
(
message
))
{
String
message
=
e
.
getFormatMessage
(
result
.
getPrompt
(),
request
.
getHeader
(
ResponseFactory
.
Accept_Language
));
if
(
StringUtils
.
isNotBlank
(
message
))
{
result
.
setMessage
(
message
);
}
response
.
getWriter
().
write
(
result
.
toJson
());
}
else
if
(!
TokenType
.
cipher
.
equals
(
effectivePerson
.
getTokenType
()))
{
/
** 需要自己标志500 */
/
/ 需要自己标志500
response
.
setStatus
(
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
);
response
.
setHeader
(
"Content-Type"
,
"application/json;charset=UTF-8"
);
ActionResult
result
=
new
ActionResult
();
ActionResult
<?>
result
=
new
ActionResult
<>
();
ExceptionAccessDenied
e
=
new
ExceptionAccessDenied
(
effectivePerson
);
result
.
error
(
e
);
String
message
=
e
.
getFormatMessage
(
result
.
getPrompt
(),
request
.
getHeader
(
ResponseFactory
.
Accept_Language
));
if
(
StringUtils
.
isNotBlank
(
message
))
{
String
message
=
e
.
getFormatMessage
(
result
.
getPrompt
(),
request
.
getHeader
(
ResponseFactory
.
Accept_Language
));
if
(
StringUtils
.
isNotBlank
(
message
))
{
result
.
setMessage
(
message
);
}
response
.
getWriter
().
write
(
result
.
toJson
());
...
...
@@ -63,7 +66,7 @@ public abstract class CipherJaxrsFilter extends TokenFilter {
chain
.
doFilter
(
request
,
response
);
}
}
else
{
options
(
request
,
response
);
options
(
request
,
response
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/CipherManagerJaxrsFilter.java
浏览文件 @
187d78ad
...
...
@@ -31,6 +31,7 @@ public abstract class CipherManagerJaxrsFilter extends TokenFilter {
try
{
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
HttpServletResponse
response
=
(
HttpServletResponse
)
res
;
httpRequestCheck
(
request
);
FilterTools
.
allow
(
request
,
response
);
if
(!
request
.
getMethod
().
equalsIgnoreCase
(
"options"
))
{
HttpToken
httpToken
=
new
HttpToken
();
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/CipherManagerUserJaxrsFilter.java
浏览文件 @
187d78ad
...
...
@@ -30,6 +30,7 @@ public abstract class CipherManagerUserJaxrsFilter extends TokenFilter {
try
{
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
HttpServletResponse
response
=
(
HttpServletResponse
)
res
;
httpRequestCheck
(
request
);
FilterTools
.
allow
(
request
,
response
);
if
(!
request
.
getMethod
().
equalsIgnoreCase
(
"options"
))
{
HttpToken
httpToken
=
new
HttpToken
();
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/ManagerUserJaxrsFilter.java
浏览文件 @
187d78ad
...
...
@@ -30,6 +30,7 @@ public abstract class ManagerUserJaxrsFilter extends TokenFilter {
try
{
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
HttpServletResponse
response
=
(
HttpServletResponse
)
res
;
httpRequestCheck
(
request
);
FilterTools
.
allow
(
request
,
response
);
if
(!
request
.
getMethod
().
equalsIgnoreCase
(
"options"
))
{
HttpToken
httpToken
=
new
HttpToken
();
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/TokenFilter.java
浏览文件 @
187d78ad
package
com.x.base.core.project.jaxrs
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.regex.Pattern
;
import
javax.servlet.Filter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.common.net.HttpHeaders
;
import
com.x.base.core.project.config.Config
;
public
abstract
class
TokenFilter
implements
Filter
{
private
static
Optional
<
Pattern
>
refererPattern
;
protected
void
options
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
response
.
setStatus
(
204
);
}
private
static
Optional
<
Pattern
>
getRefererPattern
()
{
try
{
if
(
Objects
.
isNull
(
refererPattern
))
{
synchronized
(
TokenFilter
.
class
)
{
if
(
StringUtils
.
isNotBlank
(
Config
.
general
().
getRefererHeadCheckRegular
()))
{
refererPattern
=
Optional
.
of
(
Pattern
.
compile
(
Config
.
general
().
getRefererHeadCheckRegular
()));
}
else
{
refererPattern
=
Optional
.
empty
();
}
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
refererPattern
;
}
protected
void
httpRequestCheck
(
HttpServletRequest
request
)
throws
IllegalAccessException
{
if
(
getRefererPattern
().
isPresent
())
{
String
referer
=
request
.
getHeader
(
HttpHeaders
.
REFERER
);
if
(
StringUtils
.
isNotBlank
(
referer
)
&&
(!
getRefererPattern
().
get
().
matcher
(
referer
).
find
()))
{
throw
new
IllegalAccessException
(
"illegal http request."
);
}
}
}
}
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/UserJaxrsFilter.java
浏览文件 @
187d78ad
...
...
@@ -31,6 +31,7 @@ public abstract class UserJaxrsFilter extends TokenFilter {
try
{
HttpServletRequest
request
=
(
HttpServletRequest
)
req
;
HttpServletResponse
response
=
(
HttpServletResponse
)
res
;
httpRequestCheck
(
request
);
FilterTools
.
allow
(
request
,
response
);
if
(!
request
.
getMethod
().
equalsIgnoreCase
(
"options"
))
{
HttpToken
httpToken
=
new
HttpToken
();
...
...
o2server/x_console/src/main/java/com/x/server/console/server/application/ApplicationServerTools.java
浏览文件 @
187d78ad
...
...
@@ -30,7 +30,6 @@ import org.apache.commons.io.filefilter.WildcardFileFilter;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
org.apache.commons.vfs2.util.DelegatingFileSystemOptionsBuilder
;
import
org.eclipse.jetty.quickstart.QuickStartWebApp
;
import
org.eclipse.jetty.server.AsyncRequestLogWriter
;
import
org.eclipse.jetty.server.RequestLog
;
...
...
@@ -242,18 +241,18 @@ public class ApplicationServerTools extends JettySeverTools {
});
}
private
static
void
setExposeJest
(
ApplicationServer
applicationServer
,
QuickStartWebApp
webApp
)
{
if
(
BooleanUtils
.
isFalse
(
applicationServer
.
getExposeJest
()))
{
private
static
void
setExposeJest
(
ApplicationServer
applicationServer
,
QuickStartWebApp
webApp
)
throws
Exception
{
if
(
BooleanUtils
.
isFalse
(
Config
.
general
()
.
getExposeJest
()))
{
FilterHolder
denialOfServiceFilterHolder
=
new
FilterHolder
(
new
DenialOfServiceFilter
());
webApp
.
addFilter
(
denialOfServiceFilterHolder
,
"/jest/*"
,
EnumSet
.
of
(
DispatcherType
.
REQUEST
));
webApp
.
addFilter
(
denialOfServiceFilterHolder
,
"/describe/sources/*"
,
EnumSet
.
of
(
DispatcherType
.
REQUEST
));
}
}
private
static
void
setStat
(
ApplicationServer
applicationServer
,
QuickStartWebApp
webApp
)
{
if
(
BooleanUtils
.
isTrue
(
applicationServer
.
getStatEnable
()))
{
private
static
void
setStat
(
ApplicationServer
applicationServer
,
QuickStartWebApp
webApp
)
throws
Exception
{
if
(
BooleanUtils
.
isTrue
(
Config
.
general
()
.
getStatEnable
()))
{
FilterHolder
statFilterHolder
=
new
FilterHolder
(
new
WebStatFilter
());
statFilterHolder
.
setInitParameter
(
"exclusions"
,
applicationServer
.
getStatExclusions
());
statFilterHolder
.
setInitParameter
(
"exclusions"
,
Config
.
general
()
.
getStatExclusions
());
webApp
.
addFilter
(
statFilterHolder
,
"/*"
,
EnumSet
.
of
(
DispatcherType
.
REQUEST
));
ServletHolder
statServletHolder
=
new
ServletHolder
(
StatViewServlet
.
class
);
statServletHolder
.
setInitParameter
(
"sessionStatEnable"
,
BooleanUtils
.
toStringTrueFalse
(
false
));
...
...
o2server/x_console/src/main/java/com/x/server/console/server/center/CenterServerTools.java
浏览文件 @
187d78ad
...
...
@@ -140,10 +140,10 @@ public class CenterServerTools extends JettySeverTools {
return
webApp
;
}
private
static
void
setStat
(
CenterServer
centerServer
,
QuickStartWebApp
webApp
)
{
if
(
BooleanUtils
.
isTrue
(
centerServer
.
getStatEnable
()))
{
private
static
void
setStat
(
CenterServer
centerServer
,
QuickStartWebApp
webApp
)
throws
Exception
{
if
(
BooleanUtils
.
isTrue
(
Config
.
general
()
.
getStatEnable
()))
{
FilterHolder
statFilterHolder
=
new
FilterHolder
(
new
WebStatFilter
());
statFilterHolder
.
setInitParameter
(
"exclusions"
,
centerServer
.
getStatExclusions
());
statFilterHolder
.
setInitParameter
(
"exclusions"
,
Config
.
general
()
.
getStatExclusions
());
webApp
.
addFilter
(
statFilterHolder
,
"/*"
,
EnumSet
.
of
(
DispatcherType
.
REQUEST
));
ServletHolder
statServletHolder
=
new
ServletHolder
(
StatViewServlet
.
class
);
statServletHolder
.
setInitParameter
(
"sessionStatEnable"
,
"false"
);
...
...
@@ -151,8 +151,8 @@ public class CenterServerTools extends JettySeverTools {
}
}
private
static
void
setExposeJest
(
CenterServer
centerServer
,
QuickStartWebApp
webApp
)
{
if
(
BooleanUtils
.
isFalse
(
centerServer
.
getExposeJest
()))
{
private
static
void
setExposeJest
(
CenterServer
centerServer
,
QuickStartWebApp
webApp
)
throws
Exception
{
if
(
BooleanUtils
.
isFalse
(
Config
.
general
()
.
getExposeJest
()))
{
FilterHolder
denialOfServiceFilterHolder
=
new
FilterHolder
(
new
DenialOfServiceFilter
());
webApp
.
addFilter
(
denialOfServiceFilterHolder
,
"/jest/*"
,
EnumSet
.
of
(
DispatcherType
.
REQUEST
));
webApp
.
addFilter
(
denialOfServiceFilterHolder
,
"/describe/sources/*"
,
EnumSet
.
of
(
DispatcherType
.
REQUEST
));
...
...
o2server/x_console/src/main/java/com/x/server/console/server/web/WebServerTools.java
浏览文件 @
187d78ad
...
...
@@ -128,7 +128,7 @@ public class WebServerTools extends JettySeverTools {
return
server
;
}
private
static
WebAppContext
webContext
(
WebServer
webServer
)
throws
IOException
,
URISyntax
Exception
{
private
static
WebAppContext
webContext
(
WebServer
webServer
)
throws
Exception
{
WebAppContext
context
=
new
WebAppContext
();
context
.
setContextPath
(
"/"
);
context
.
setBaseResource
(
Resource
.
newResource
(
new
File
(
Config
.
base
(),
"servers/webServer"
)));
...
...
@@ -143,9 +143,9 @@ public class WebServerTools extends JettySeverTools {
context
.
setGzipHandler
(
new
GzipHandler
());
context
.
setParentLoaderPriority
(
true
);
context
.
getMimeTypes
().
addMimeMapping
(
"wcss"
,
"application/json"
);
if
(
BooleanUtils
.
isTrue
(
webServer
.
getStatEnable
()))
{
if
(
BooleanUtils
.
isTrue
(
Config
.
general
()
.
getStatEnable
()))
{
FilterHolder
statFilterHolder
=
new
FilterHolder
(
new
WebStatFilter
());
statFilterHolder
.
setInitParameter
(
"exclusions"
,
webServer
.
getStatExclusions
());
statFilterHolder
.
setInitParameter
(
"exclusions"
,
Config
.
general
()
.
getStatExclusions
());
context
.
addFilter
(
statFilterHolder
,
"/*"
,
EnumSet
.
of
(
DispatcherType
.
REQUEST
));
ServletHolder
statServletHolder
=
new
ServletHolder
(
StatViewServlet
.
class
);
statServletHolder
.
setInitParameter
(
"sessionStatEnable"
,
"false"
);
...
...
o2server/x_message_assemble_communicate/src/main/java/com/x/message/assemble/communicate/ws/collaboration/ActionCollaboration.java
浏览文件 @
187d78ad
...
...
@@ -42,7 +42,7 @@ public class ActionCollaboration {
@OnOpen
public
void
open
(
Session
session
)
{
EffectivePerson
effectivePerson
=
(
EffectivePerson
)
session
.
getUserProperties
().
get
(
HttpToken
.
X_P
erson
);
EffectivePerson
effectivePerson
=
(
EffectivePerson
)
session
.
getUserProperties
().
get
(
HttpToken
.
X_P
ERSON
);
LOGGER
.
debug
(
"OnOpen: tokenType:{}, distinguishedName:{}."
,
effectivePerson:
:
getTokenType
,
effectivePerson:
:
getDistinguishedName
);
...
...
@@ -79,7 +79,7 @@ public class ActionCollaboration {
@OnMessage
public
void
message
(
String
input
,
Session
session
)
throws
IOException
{
EffectivePerson
effectivePerson
=
(
EffectivePerson
)
session
.
getUserProperties
().
get
(
HttpToken
.
X_P
erson
);
EffectivePerson
effectivePerson
=
(
EffectivePerson
)
session
.
getUserProperties
().
get
(
HttpToken
.
X_P
ERSON
);
LOGGER
.
debug
(
"OnMessage receive: message {}, person:{}, ip:{}, client:{} ."
,
()
->
input
,
effectivePerson:
:
getDistinguishedName
,
effectivePerson:
:
getRemoteAddress
,
effectivePerson:
:
getUserAgent
);
...
...
o2server/x_message_assemble_communicate/src/main/java/com/x/message/assemble/communicate/ws/collaboration/WsConfigurator.java
浏览文件 @
187d78ad
...
...
@@ -19,7 +19,7 @@ public class WsConfigurator extends ServerEndpointConfig.Configurator {
public
void
modifyHandshake
(
ServerEndpointConfig
config
,
HandshakeRequest
request
,
HandshakeResponse
response
)
{
try
{
EffectivePerson
effectivePerson
=
this
.
getEffectivePerson
(
request
);
config
.
getUserProperties
().
put
(
HttpToken
.
X_P
erson
,
effectivePerson
);
config
.
getUserProperties
().
put
(
HttpToken
.
X_P
ERSON
,
effectivePerson
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/authentication/ActionWho.java
浏览文件 @
187d78ad
...
...
@@ -55,7 +55,7 @@ class ActionWho extends BaseAction {
}
else
{
Person
person
=
this
.
getPerson
(
business
,
effectivePerson
);
wo
=
this
.
user
(
null
,
null
,
business
,
person
,
Wo
.
class
);
this
.
recordLogin
(
person
.
getName
(),
request
.
getRemoteAddr
(),
request
.
getHeader
(
HttpToken
.
X_C
lient
));
this
.
recordLogin
(
person
.
getName
(),
request
.
getRemoteAddr
(),
request
.
getHeader
(
HttpToken
.
X_C
LIENT
));
}
wo
.
setTokenType
(
TokenType
.
manager
);
wo
.
setToken
(
effectivePerson
.
getToken
());
...
...
@@ -68,7 +68,7 @@ class ActionWho extends BaseAction {
}
else
{
Person
person
=
this
.
getPerson
(
business
,
effectivePerson
);
wo
=
this
.
user
(
null
,
null
,
business
,
person
,
Wo
.
class
);
this
.
recordLogin
(
person
.
getName
(),
request
.
getRemoteAddr
(),
request
.
getHeader
(
HttpToken
.
X_C
lient
));
this
.
recordLogin
(
person
.
getName
(),
request
.
getRemoteAddr
(),
request
.
getHeader
(
HttpToken
.
X_C
LIENT
));
}
wo
.
setTokenType
(
effectivePerson
.
getTokenType
());
wo
.
setToken
(
effectivePerson
.
getToken
());
...
...
@@ -76,7 +76,7 @@ class ActionWho extends BaseAction {
case
user:
Person
person
=
this
.
getPerson
(
business
,
effectivePerson
);
wo
=
this
.
user
(
null
,
null
,
business
,
person
,
Wo
.
class
);
this
.
recordLogin
(
person
.
getName
(),
request
.
getRemoteAddr
(),
request
.
getHeader
(
HttpToken
.
X_C
lient
));
this
.
recordLogin
(
person
.
getName
(),
request
.
getRemoteAddr
(),
request
.
getHeader
(
HttpToken
.
X_C
LIENT
));
break
;
default
:
break
;
...
...
o2server/x_organization_assemble_authentication/src/main/java/com/x/organization/assemble/authentication/jaxrs/oauth/ActionInfo.java
浏览文件 @
187d78ad
...
...
@@ -50,7 +50,7 @@ class ActionInfo extends BaseAction {
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
if
(
StringUtils
.
isEmpty
(
accessToken
))
{
String
bearer
=
request
.
getHeader
(
HttpToken
.
X_A
uthorization
);
String
bearer
=
request
.
getHeader
(
HttpToken
.
X_A
UTHORIZATION
);
if
(
StringUtils
.
isNotEmpty
(
bearer
))
{
accessToken
=
StringUtils
.
substringAfter
(
bearer
,
" "
);
}
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionChangeOrderNumber.java
浏览文件 @
187d78ad
...
...
@@ -35,7 +35,7 @@ class ActionChangeOrderNumber extends BaseAction {
if
(
null
==
attachment
)
{
throw
new
ExceptionEntityNotExist
(
id
,
Attachment
.
class
);
}
if
(!
business
.
readableWithWorkOrWorkCompleted
(
effectivePerson
,
workId
))
{
if
(!
business
.
editable
(
effectivePerson
,
attachment
.
getJob
()
))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
);
}
List
<
String
>
identities
=
business
.
organization
().
identity
().
listWithPerson
(
effectivePerson
);
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWithUrl.java
浏览文件 @
187d78ad
...
...
@@ -56,9 +56,6 @@ class ActionUploadWithUrl extends BaseAction {
if
(
StringUtils
.
isEmpty
(
wi
.
getSite
()))
{
throw
new
ExceptionEntityFieldEmpty
(
Attachment
.
class
,
wi
.
getSite
());
}
if
(!
business
.
readableWithWorkOrWorkCompleted
(
effectivePerson
,
wi
.
getWorkId
()))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
,
wi
.
getWorkId
());
}
String
person
=
effectivePerson
.
getDistinguishedName
();
if
(
StringUtils
.
isNotEmpty
(
wi
.
getPerson
())
&&
business
.
canManageApplication
(
effectivePerson
,
null
))
{
Person
p
=
business
.
organization
().
person
().
getObject
(
wi
.
getPerson
());
...
...
@@ -89,6 +86,9 @@ class ActionUploadWithUrl extends BaseAction {
if
(
attachment
==
null
)
{
throw
new
ExceptionEntityNotExist
(
wi
.
getWorkId
());
}
if
(!
business
.
editable
(
effectivePerson
,
attachment
.
getJob
()))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
,
wi
.
getWorkId
());
}
byte
[]
bytes
=
CipherConnectionAction
.
getBinary
(
false
,
wi
.
getFileUrl
());
if
(
bytes
==
null
||
bytes
.
length
==
0
)
{
throw
new
IllegalStateException
(
"can not down file from url."
);
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWithWorkCompleted.java
浏览文件 @
187d78ad
...
...
@@ -51,10 +51,7 @@ class ActionUploadWithWorkCompleted extends BaseAction {
if
(
ends
.
isEmpty
())
{
throw
new
ExceptionEndNotExist
(
process
.
getId
());
}
if
((
effectivePerson
.
isNotManager
())
&&
(!
business
.
organization
().
person
().
hasRole
(
effectivePerson
,
OrganizationDefinition
.
ProcessPlatformManager
,
OrganizationDefinition
.
Manager
))
&&
effectivePerson
.
isNotPerson
(
application
.
getControllerList
()))
{
if
(!
business
.
canManageApplicationOrProcess
(
effectivePerson
,
application
,
process
))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
);
}
if
(
StringUtils
.
isEmpty
(
fileName
))
{
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/ActionUploadWorkInfo.java
浏览文件 @
187d78ad
...
...
@@ -75,7 +75,7 @@ class ActionUploadWorkInfo extends BaseAction {
workHtml
=
"<html><head></head><body>"
+
workHtml
+
"</body></html>"
;
}
}
String
id
=
saveHtml
(
workId
,
flag
,
workHtml
,
effectivePerson
.
getDistinguishedName
(),
title
,
String
id
=
saveHtml
(
flag
,
workHtml
,
effectivePerson
.
getDistinguishedName
(),
title
,
wi
.
getPageWidth
(),
business
);
Wo
wo
=
new
Wo
();
wo
.
setId
(
id
);
...
...
@@ -87,7 +87,7 @@ class ActionUploadWorkInfo extends BaseAction {
public
static
class
Wo
extends
WoId
{
}
private
String
saveHtml
(
String
workId
,
String
flag
,
String
workHtml
,
String
person
,
String
title
,
Float
pageWidth
,
private
String
saveHtml
(
String
flag
,
String
workHtml
,
String
person
,
String
title
,
Float
pageWidth
,
Business
business
)
{
try
{
String
name
=
""
;
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/attachment/BaseAction.java
浏览文件 @
187d78ad
...
...
@@ -10,6 +10,8 @@ import javax.persistence.criteria.CriteriaQuery;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
com.x.processplatform.core.entity.element.Application
;
import
com.x.processplatform.core.entity.element.Process
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.lang3.BooleanUtils
;
...
...
@@ -258,18 +260,16 @@ abstract class BaseAction extends StandardJaxrsAction {
public
boolean
control
(
Attachment
attachment
,
EffectivePerson
effectivePerson
,
List
<
String
>
identities
,
List
<
String
>
units
,
Business
business
)
throws
Exception
{
boolean
value
=
false
;
if
(
BooleanUtils
.
isTrue
(
business
.
canManageApplication
(
effectivePerson
,
null
)))
{
value
=
true
;
}
else
if
(
effectivePerson
.
isPerson
(
attachment
.
getPerson
()))
{
if
(
effectivePerson
.
isPerson
(
attachment
.
getPerson
()))
{
value
=
true
;
}
else
if
(
ListTools
.
isEmpty
(
attachment
.
getControllerUnitList
())
&&
ListTools
.
isEmpty
(
attachment
.
getControllerIdentityList
()))
{
value
=
true
;
}
else
{
if
(
ListTools
.
containsAny
(
identities
,
attachment
.
getControllerIdentityList
())
}
else
if
(
ListTools
.
containsAny
(
identities
,
attachment
.
getControllerIdentityList
())
||
ListTools
.
containsAny
(
units
,
attachment
.
getControllerUnitList
()))
{
value
=
true
;
}
}
else
if
(
BooleanUtils
.
isTrue
(
business
.
canManageApplicationOrProcess
(
effectivePerson
,
attachment
.
getApplication
(),
attachment
.
getProcess
())))
{
value
=
true
;
}
return
value
;
}
...
...
@@ -302,7 +302,7 @@ abstract class BaseAction extends StandardJaxrsAction {
/**
* 判断附件是否符合大小、文件类型的约束
*
*
* @param size
* @param fileName
* @param callback
...
...
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/serialnumber/ActionCreate.java
0 → 100644
浏览文件 @
187d78ad
package
com.x.processplatform.assemble.surface.jaxrs.serialnumber
;
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.entity.JpaObject
;
import
com.x.base.core.entity.annotation.CheckPersistType
;
import
com.x.base.core.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.exception.ExceptionFieldEmpty
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WoId
;
import
com.x.processplatform.assemble.surface.Business
;
import
com.x.processplatform.core.entity.content.SerialNumber
;
import
com.x.processplatform.core.entity.element.Application
;
import
com.x.processplatform.core.entity.element.Process
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
org.eclipse.jetty.util.StringUtil
;
class
ActionCreate
extends
BaseAction
{
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
JsonElement
jsonElement
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
if
(
StringUtil
.
isBlank
(
wi
.
getProcess
())){
throw
new
ExceptionFieldEmpty
(
SerialNumber
.
process_FIELDNAME
);
}
if
(
wi
.
getSerial
()
==
null
){
throw
new
ExceptionFieldEmpty
(
SerialNumber
.
serial_FIELDNAME
);
}
Process
process
=
business
.
process
().
pick
(
wi
.
getProcess
());
if
(
null
==
process
)
{
throw
new
ExceptionEntityNotExist
(
wi
.
getProcess
());
}
Application
application
=
business
.
application
().
pick
(
process
.
getApplication
());
if
(!
business
.
canManageApplicationOrProcess
(
effectivePerson
,
application
,
process
))
{
throw
new
ExceptionAccessDenied
(
effectivePerson
);
}
SerialNumber
serialNumber
=
Wi
.
copier
.
copy
(
wi
);
serialNumber
.
setApplication
(
process
.
getApplication
());
emc
.
beginTransaction
(
SerialNumber
.
class
);
emc
.
persist
(
serialNumber
,
CheckPersistType
.
all
);
emc
.
commit
();
Wo
wo
=
new
Wo
();
wo
.
setId
(
serialNumber
.
getId
());
result
.
setData
(
wo
);
}
return
result
;
}
@Schema
(
name
=
"com.x.processplatform.assemble.surface.jaxrs.serialnumber.ActionCreate$Wi"
)
public
static
class
Wi
extends
SerialNumber
{
private
static
final
long
serialVersionUID
=
4466662676168979509L
;
static
WrapCopier
<
Wi
,
SerialNumber
>
copier
=
WrapCopierFactory
.
wi
(
Wi
.
class
,
SerialNumber
.
class
,
null
,
JpaObject
.
FieldsUnmodify
);
}
@Schema
(
name
=
"com.x.processplatform.assemble.surface.jaxrs.serialnumber.ActionCreate$Wo"
)
public
static
class
Wo
extends
WoId
{
}
}
o2server/x_processplatform_assemble_surface/src/main/java/com/x/processplatform/assemble/surface/jaxrs/serialnumber/SerialNumberAction.java
浏览文件 @
187d78ad
...
...
@@ -72,6 +72,23 @@ public class SerialNumberAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"创建SerialNumber内容."
,
action
=
ActionCreate
.
class
)
@POST
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
create
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
JsonElement
jsonElement
)
{
ActionResult
<
ActionCreate
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionCreate
().
execute
(
effectivePerson
,
jsonElement
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
,
jsonElement
));
}
@JaxrsMethodDescribe
(
value
=
"更新SerialNumber内容."
,
action
=
ActionUpdate
.
class
)
@PUT
@Path
(
"{id}"
)
...
...
o2server/x_processplatform_service_processing/src/main/java/com/x/processplatform/service/processing/jaxrs/workcompleted/ActionRollback.java
浏览文件 @
187d78ad
...
...
@@ -66,6 +66,7 @@ class ActionRollback extends BaseAction {
}
Callable
<
String
>
callable
=
new
Callable
<
String
>()
{
@Override
public
String
call
()
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
...
...
@@ -116,7 +117,7 @@ class ActionRollback extends BaseAction {
emc
.
beginTransaction
(
ReadCompleted
.
class
);
emc
.
beginTransaction
(
Review
.
class
);
Work
work
=
createWork
(
workCompleted
,
workLog
);
Work
work
=
createWork
(
business
,
workCompleted
,
workLog
);
emc
.
persist
(
work
,
CheckPersistType
.
all
);
disconnectWorkLog
(
work
,
workLog
);
...
...
@@ -157,7 +158,7 @@ class ActionRollback extends BaseAction {
return
result
;
}
private
Work
createWork
(
WorkCompleted
workCompleted
,
WorkLog
workLog
)
throws
Exception
{
private
Work
createWork
(
Business
business
,
WorkCompleted
workCompleted
,
WorkLog
workLog
)
throws
Exception
{
Work
work
=
new
Work
(
workCompleted
);
work
.
setSplitting
(
false
);
work
.
setActivityName
(
workLog
.
getFromActivityName
());
...
...
@@ -167,6 +168,7 @@ class ActionRollback extends BaseAction {
work
.
setActivityDescription
(
""
);
work
.
setActivityToken
(
workLog
.
getFromActivityToken
());
work
.
setActivityType
(
workLog
.
getFromActivityType
());
work
.
setForm
(
business
.
element
().
lookupSuitableForm
(
work
.
getProcess
(),
work
.
getActivity
()));
// work.setErrorRetry(0);
work
.
setWorkStatus
(
WorkStatus
.
processing
);
// 因为workCompleted没有workCreateType属性,回溯到任何环节都必须要有待办,默认置为assign
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录