Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fuyue82
o2oa
提交
fe7583f1
o2oa
项目概览
fuyue82
/
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,发现更多精彩内容 >>
提交
fe7583f1
编写于
10月 22, 2021
作者:
O
o2null
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复腾讯企业邮无法回调的bug
上级
62d30e4d
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
205 addition
and
77 deletion
+205
-77
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/ExmailJaxrsFilter.java
...ganization/assemble/personal/jaxrs/ExmailJaxrsFilter.java
+2
-2
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ActionCallback.java
...zation/assemble/personal/jaxrs/exmail/ActionCallback.java
+11
-7
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ActionGet.java
...rganization/assemble/personal/jaxrs/exmail/ActionGet.java
+4
-6
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ActionListTitlePassive.java
...ssemble/personal/jaxrs/exmail/ActionListTitlePassive.java
+22
-9
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ActionNewCount.java
...zation/assemble/personal/jaxrs/exmail/ActionNewCount.java
+45
-9
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ActionNewCountPassive.java
...assemble/personal/jaxrs/exmail/ActionNewCountPassive.java
+19
-9
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ActionSso.java
...rganization/assemble/personal/jaxrs/exmail/ActionSso.java
+19
-9
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/AesException.java
...nization/assemble/personal/jaxrs/exmail/AesException.java
+5
-0
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/BaseAction.java
...ganization/assemble/personal/jaxrs/exmail/BaseAction.java
+13
-0
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ByteGroup.java
...rganization/assemble/personal/jaxrs/exmail/ByteGroup.java
+5
-0
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ExceptionExmailDisable.java
...ssemble/personal/jaxrs/exmail/ExceptionExmailDisable.java
+5
-0
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ExceptionNewCount.java
...ion/assemble/personal/jaxrs/exmail/ExceptionNewCount.java
+5
-0
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ExmailAction.java
...nization/assemble/personal/jaxrs/exmail/ExmailAction.java
+19
-4
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/PKCS7Encoder.java
...nization/assemble/personal/jaxrs/exmail/PKCS7Encoder.java
+1
-1
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/QueueUpdateExmail.java
...ion/assemble/personal/jaxrs/exmail/QueueUpdateExmail.java
+5
-0
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/SHA1.java
...m/x/organization/assemble/personal/jaxrs/exmail/SHA1.java
+1
-0
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/WXBizMsgCrypt.java
...ization/assemble/personal/jaxrs/exmail/WXBizMsgCrypt.java
+22
-19
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/XMLParse.java
...organization/assemble/personal/jaxrs/exmail/XMLParse.java
+2
-2
未找到文件。
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/ExmailJaxrsFilter.java
浏览文件 @
fe7583f1
...
...
@@ -2,9 +2,9 @@ package com.x.organization.assemble.personal.jaxrs;
import
javax.servlet.annotation.WebFilter
;
import
com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter
;
import
com.x.base.core.project.jaxrs.
Anonymous
CipherManagerUserJaxrsFilter
;
@WebFilter
(
urlPatterns
=
"/jaxrs/exmail/*"
,
asyncSupported
=
true
)
public
class
ExmailJaxrsFilter
extends
CipherManagerUserJaxrsFilter
{
public
class
ExmailJaxrsFilter
extends
Anonymous
CipherManagerUserJaxrsFilter
{
}
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/Action
Post
.java
→
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/Action
Callback
.java
浏览文件 @
fe7583f1
...
...
@@ -10,19 +10,23 @@ import com.x.base.core.project.logger.Logger;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.organization.assemble.personal.ThisApplication
;
class
ActionPost
extends
BaseAction
{
/**
*
* @author ray
*
*/
class
ActionCallback
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
Action
Post
.
class
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
Action
Callback
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
msgSignature
,
String
timestamp
,
String
nonce
,
String
body
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
if
(
BooleanUtils
.
isNotTrue
(
Config
.
exmail
().
getEnable
()))
{
throw
new
ExceptionExmailDisable
();
}
String
msg
=
decrypt
(
msgSignature
,
timestamp
,
nonce
,
body
);
ThisApplication
.
queueUpdateExmail
.
send
(
msg
);
if
(
BooleanUtils
.
isTrue
(
Config
.
exmail
().
getEnable
()))
{
String
msg
=
decrypt
(
msgSignature
,
timestamp
,
nonce
,
body
);
ThisApplication
.
queueUpdateExmail
.
send
(
msg
);
}
Wo
wo
=
new
Wo
();
wo
.
setValue
(
true
);
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ActionGet.java
浏览文件 @
fe7583f1
...
...
@@ -8,10 +8,9 @@ import com.x.base.core.project.logger.Logger;
import
com.x.base.core.project.logger.LoggerFactory
;
/**
* 专门用于腾讯企业邮第一次开通API接口时用于认证.
* 开通的认证端口必须是80,443或者8080,腾讯不会访问其他端口.
* 专门用于腾讯企业邮第一次开通API接口时用于认证. 开通的认证端口必须是80,443或者8080,腾讯不会访问其他端口.
*
* @author
zhour
* @author
ray
*
*/
class
ActionGet
extends
BaseAction
{
...
...
@@ -20,11 +19,10 @@ class ActionGet extends BaseAction {
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
msg_signature
,
String
timestamp
,
String
nonce
,
String
echostr
)
throws
Exception
{
logger
.
debug
(
"腾讯企业邮收到,msg_signature:{}, timestamp:{}, nonce:{}, echostr:{}."
,
msg_signature
,
timestamp
,
nonce
,
echostr
);
if
(!
Config
.
exmail
().
getEnable
())
{
throw
new
ExceptionExmailDisable
();
}
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
new
Wo
();
WXBizMsgCrypt
crypt
=
new
WXBizMsgCrypt
(
Config
.
exmail
().
getToken
(),
Config
.
exmail
().
getEncodingAesKey
(),
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ActionListTitlePassive.java
浏览文件 @
fe7583f1
...
...
@@ -13,19 +13,29 @@ import com.x.organization.assemble.personal.Business;
import
com.x.organization.core.entity.Person
;
import
com.x.organization.core.entity.PersonAttribute
;
/**
*
* @author ray
*
*/
class
ActionListTitlePassive
extends
BaseAction
{
ActionResult
<
List
<
Wo
>>
execute
(
EffectivePerson
effectivePerson
)
throws
Exception
{
if
(!
Config
.
exmail
().
getEnable
())
{
throw
new
ExceptionExmailDisable
();
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
List
<
Wo
>
wos
=
this
.
list
(
business
,
effectivePerson
);
result
.
setData
(
wos
);
return
result
;
checkEnable
();
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>();
List
<
Wo
>
wos
=
new
ArrayList
<>();
if
((!
effectivePerson
.
isAnonymous
())
&&
(!
effectivePerson
.
isCipher
()))
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
wos
=
this
.
list
(
business
,
effectivePerson
);
}
}
result
.
setData
(
wos
);
return
result
;
}
private
List
<
Wo
>
list
(
Business
business
,
EffectivePerson
effectivePerson
)
throws
Exception
{
...
...
@@ -45,6 +55,9 @@ class ActionListTitlePassive extends BaseAction {
}
public
static
class
Wo
extends
WrapString
{
private
static
final
long
serialVersionUID
=
1L
;
}
}
\ No newline at end of file
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ActionNewCount.java
浏览文件 @
fe7583f1
...
...
@@ -10,19 +10,29 @@ import com.x.base.core.project.jaxrs.WrapCount;
import
com.x.organization.assemble.personal.Business
;
import
com.x.organization.core.entity.Person
;
/**
*
* @author ray
*
*/
class
ActionNewCount
extends
BaseAction
{
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
)
throws
Exception
{
if
(!
Config
.
exmail
().
getEnable
())
{
throw
new
ExceptionExmailDisable
();
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
Wo
wo
=
this
.
get
(
business
,
effectivePerson
);
result
.
setData
(
wo
);
return
result
;
checkEnable
();
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
new
Wo
();
if
((!
effectivePerson
.
isAnonymous
())
&&
(!
effectivePerson
.
isCipher
()))
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
wo
=
this
.
get
(
business
,
effectivePerson
);
}
}
result
.
setData
(
wo
);
return
result
;
}
private
Wo
get
(
Business
business
,
EffectivePerson
effectivePerson
)
throws
Exception
{
...
...
@@ -46,9 +56,35 @@ class ActionNewCount extends BaseAction {
private
String
errmsg
;
private
Long
count
;
public
Integer
getErrcode
()
{
return
errcode
;
}
public
void
setErrcode
(
Integer
errcode
)
{
this
.
errcode
=
errcode
;
}
public
String
getErrmsg
()
{
return
errmsg
;
}
public
void
setErrmsg
(
String
errmsg
)
{
this
.
errmsg
=
errmsg
;
}
public
Long
getCount
()
{
return
count
;
}
public
void
setCount
(
Long
count
)
{
this
.
count
=
count
;
}
}
public
static
class
Wo
extends
WrapCount
{
private
static
final
long
serialVersionUID
=
1L
;
}
}
\ No newline at end of file
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ActionNewCountPassive.java
浏览文件 @
fe7583f1
...
...
@@ -15,19 +15,29 @@ import com.x.organization.assemble.personal.Business;
import
com.x.organization.core.entity.Person
;
import
com.x.organization.core.entity.PersonAttribute
;
/**
*
* @author ray
*
*/
class
ActionNewCountPassive
extends
BaseAction
{
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
)
throws
Exception
{
if
(!
Config
.
exmail
().
getEnable
())
{
throw
new
ExceptionExmailDisable
();
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
Wo
wo
=
this
.
get
(
business
,
effectivePerson
);
result
.
setData
(
wo
);
return
result
;
checkEnable
();
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
new
Wo
();
if
((!
effectivePerson
.
isAnonymous
())
&&
(!
effectivePerson
.
isCipher
()))
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
wo
=
this
.
get
(
business
,
effectivePerson
);
}
}
result
.
setData
(
wo
);
return
result
;
}
private
Wo
get
(
Business
business
,
EffectivePerson
effectivePerson
)
throws
Exception
{
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ActionSso.java
浏览文件 @
fe7583f1
...
...
@@ -10,19 +10,29 @@ import com.x.base.core.project.http.EffectivePerson;
import
com.x.organization.assemble.personal.Business
;
import
com.x.organization.core.entity.Person
;
/**
*
* @author ray
*
*/
class
ActionSso
extends
BaseAction
{
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
)
throws
Exception
{
if
(!
Config
.
exmail
().
getEnable
())
{
throw
new
ExceptionExmailDisable
();
}
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Business
business
=
new
Business
(
emc
);
Wo
wo
=
this
.
get
(
business
,
effectivePerson
);
result
.
setData
(
wo
);
return
result
;
checkEnable
();
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
new
Wo
();
if
((!
effectivePerson
.
isAnonymous
())
&&
(!
effectivePerson
.
isCipher
()))
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
wo
=
this
.
get
(
business
,
effectivePerson
);
}
}
result
.
setData
(
wo
);
return
result
;
}
private
Wo
get
(
Business
business
,
EffectivePerson
effectivePerson
)
throws
Exception
{
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/AesException.java
浏览文件 @
fe7583f1
package
com.x.organization.assemble.personal.jaxrs.exmail
;
/**
*
* @author ray
*
*/
public
class
AesException
extends
Exception
{
public
final
static
int
OK
=
0
;
public
final
static
int
ValidateSignatureError
=
-
40001
;
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/BaseAction.java
浏览文件 @
fe7583f1
package
com.x.organization.assemble.personal.jaxrs.exmail
;
import
org.apache.commons.lang3.BooleanUtils
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.jaxrs.StandardJaxrsAction
;
/**
*
* @author ray
*
*/
abstract
class
BaseAction
extends
StandardJaxrsAction
{
protected
void
checkEnable
()
throws
Exception
{
if
(
BooleanUtils
.
isNotTrue
(
Config
.
exmail
().
getEnable
()))
{
throw
new
ExceptionExmailDisable
();
}
}
}
\ No newline at end of file
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ByteGroup.java
浏览文件 @
fe7583f1
...
...
@@ -2,6 +2,11 @@ package com.x.organization.assemble.personal.jaxrs.exmail;
import
java.util.ArrayList
;
/**
*
* @author ray
*
*/
class
ByteGroup
{
ArrayList
<
Byte
>
byteContainer
=
new
ArrayList
<
Byte
>();
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ExceptionExmailDisable.java
浏览文件 @
fe7583f1
...
...
@@ -2,6 +2,11 @@ package com.x.organization.assemble.personal.jaxrs.exmail;
import
com.x.base.core.project.exception.LanguagePromptException
;
/**
*
* @author ray
*
*/
class
ExceptionExmailDisable
extends
LanguagePromptException
{
private
static
final
long
serialVersionUID
=
-
3439770681867963457L
;
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ExceptionNewCount.java
浏览文件 @
fe7583f1
...
...
@@ -2,6 +2,11 @@ package com.x.organization.assemble.personal.jaxrs.exmail;
import
com.x.base.core.project.exception.LanguagePromptException
;
/**
*
* @author ray
*
*/
class
ExceptionNewCount
extends
LanguagePromptException
{
private
static
final
long
serialVersionUID
=
-
3885997486474873786L
;
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/ExmailAction.java
浏览文件 @
fe7583f1
...
...
@@ -24,6 +24,11 @@ import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
/**
*
* @author ray
*
*/
@Path
(
"exmail"
)
@JaxrsDescribe
(
"腾讯企业邮"
)
public
class
ExmailAction
extends
StandardJaxrsAction
{
...
...
@@ -114,15 +119,25 @@ public class ExmailAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"接收腾讯企业邮回调Post方法."
,
action
=
ActionPost
.
class
)
/**
* 接收腾讯企业邮回调Post方法 单独申明了fitler避免权限过滤
*
* @param asyncResponse
* @param request
* @param msg_signature
* @param timestamp
* @param nonce
* @param body
*/
@JaxrsMethodDescribe
(
value
=
"接收腾讯企业邮回调Post方法."
,
action
=
ActionCallback
.
class
)
@POST
public
void
post
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
public
void
callback
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
,
@QueryParam
(
"msg_signature"
)
String
msg_signature
,
@QueryParam
(
"timestamp"
)
String
timestamp
,
@QueryParam
(
"nonce"
)
String
nonce
,
String
body
)
{
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
ActionResult
<
Action
Post
.
Wo
>
result
=
new
ActionResult
<>();
ActionResult
<
Action
Callback
.
Wo
>
result
=
new
ActionResult
<>();
try
{
result
=
new
Action
Post
().
execute
(
effectivePerson
,
msg_signature
,
timestamp
,
nonce
,
body
);
result
=
new
Action
Callback
().
execute
(
effectivePerson
,
msg_signature
,
timestamp
,
nonce
,
body
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/PKCS7Encoder.java
浏览文件 @
fe7583f1
...
...
@@ -12,7 +12,7 @@ import java.nio.charset.Charset;
import
java.util.Arrays
;
/**
* 提供基于PKCS7算法的加解密接口.
*
@author ray
提供基于PKCS7算法的加解密接口.
*/
class
PKCS7Encoder
{
static
Charset
CHARSET
=
Charset
.
forName
(
"utf-8"
);
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/QueueUpdateExmail.java
浏览文件 @
fe7583f1
...
...
@@ -32,6 +32,11 @@ import com.x.base.core.project.tools.StringTools;
import
com.x.organization.core.entity.Person
;
import
com.x.organization.core.entity.PersonAttribute
;
/**
*
* @author ray
*
*/
public
class
QueueUpdateExmail
extends
AbstractQueue
<
String
>
{
private
static
final
String
MSGTYPE_UNREAD
=
"UnRead"
;
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/SHA1.java
浏览文件 @
fe7583f1
...
...
@@ -12,6 +12,7 @@ import java.security.MessageDigest;
import
java.util.Arrays
;
/**
* @author ray
* SHA1 class
*
* 计算公众平台的消息签名接口.
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/WXBizMsgCrypt.java
浏览文件 @
fe7583f1
...
...
@@ -14,6 +14,8 @@
package
com.x.organization.assemble.personal.jaxrs.exmail
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.security.SecureRandom
;
import
java.util.Arrays
;
import
java.util.Random
;
...
...
@@ -22,24 +24,26 @@ import javax.crypto.spec.IvParameterSpec;
import
javax.crypto.spec.SecretKeySpec
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang3.StringUtils
;
/**
* 提供接收和推送给公众平台消息的加解密接口(UTF8编码的字符串).
* <ol>
* <li>第三方回复加密消息给公众平台</li>
* <li>第三方收到公众平台发送的消息,验证消息的安全性,并对消息进行解密。</li>
* </ol>
* 说明:异常java.security.InvalidKeyException:illegal Key Size的解决方案
* <ol>
* <li>在官方网站下载JCE无限制权限策略文件(JDK7的下载地址:
* http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html</li>
* <li>下载后解压,可以看到local_policy.jar和US_export_policy.jar以及readme.txt</li>
* <li>如果安装了JRE,将两个jar文件放到%JRE_HOME%\lib\security目录下覆盖原来的文件</li>
* <li>如果安装了JDK,将两个jar文件放到%JDK_HOME%\jre\lib\security目录下覆盖原来文件</li>
* </ol>
*
@author ray
提供接收和推送给公众平台消息的加解密接口(UTF8编码的字符串).
*
<ol>
*
<li>第三方回复加密消息给公众平台</li>
*
<li>第三方收到公众平台发送的消息,验证消息的安全性,并对消息进行解密。</li>
*
</ol>
*
说明:异常java.security.InvalidKeyException:illegal Key Size的解决方案
*
<ol>
*
<li>在官方网站下载JCE无限制权限策略文件(JDK7的下载地址:
*
http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html</li>
*
<li>下载后解压,可以看到local_policy.jar和US_export_policy.jar以及readme.txt</li>
*
<li>如果安装了JRE,将两个jar文件放到%JRE_HOME%\lib\security目录下覆盖原来的文件</li>
*
<li>如果安装了JDK,将两个jar文件放到%JDK_HOME%\jre\lib\security目录下覆盖原来文件</li>
*
</ol>
*/
public
class
WXBizMsgCrypt
{
static
Charset
CHARSET
=
Charset
.
forName
(
"utf-8"
);
static
final
Charset
CHARSET
=
StandardCharsets
.
UTF_8
;
static
final
Random
random
=
new
SecureRandom
();
Base64
base64
=
new
Base64
();
byte
[]
aesKey
;
String
token
;
...
...
@@ -63,8 +67,7 @@ public class WXBizMsgCrypt {
this
.
corpId
=
corpId
;
// aesKey = Base64.decodeBase64(encodingAesKey + "=");
/**
* 默认的方法 aesKey = Base64.decodeBase64(encodingAesKey + "=");
* 实际运行有报错
* 默认的方法 aesKey = Base64.decodeBase64(encodingAesKey + "="); 实际运行有报错
*/
java
.
util
.
Base64
.
Decoder
decoder
=
java
.
util
.
Base64
.
getDecoder
();
aesKey
=
decoder
.
decode
(
encodingAesKey
);
...
...
@@ -93,8 +96,8 @@ public class WXBizMsgCrypt {
// 随机生成16位字符串
String
getRandomStr
()
{
String
base
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
;
Random
random
=
new
Random
();
StringBu
ffer
sb
=
new
StringBuff
er
();
//
Random random = new Random();
StringBu
ilder
sb
=
new
StringBuild
er
();
for
(
int
i
=
0
;
i
<
16
;
i
++)
{
int
number
=
random
.
nextInt
(
base
.
length
());
sb
.
append
(
base
.
charAt
(
number
));
...
...
@@ -220,7 +223,7 @@ public class WXBizMsgCrypt {
String
encrypt
=
encrypt
(
getRandomStr
(),
replyMsg
);
// 生成安全签名
if
(
timeStamp
==
""
)
{
if
(
StringUtils
.
isEmpty
(
timeStamp
)
)
{
timeStamp
=
Long
.
toString
(
System
.
currentTimeMillis
());
}
...
...
o2server/x_organization_assemble_personal/src/main/java/com/x/organization/assemble/personal/jaxrs/exmail/XMLParse.java
浏览文件 @
fe7583f1
...
...
@@ -19,9 +19,9 @@ import org.w3c.dom.NodeList;
import
org.xml.sax.InputSource
;
/**
* XMLParse class
*
@author ray
XMLParse class
*
* 提供提取消息格式中的密文及生成回复消息格式的接口.
*
提供提取消息格式中的密文及生成回复消息格式的接口.
*/
class
XMLParse
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录