Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yujianwangzivayy
MaxKey
提交
5e4923d6
MaxKey
项目概览
yujianwangzivayy
/
MaxKey
与 Fork 源项目一致
Fork自
MaxKey单点登录官方(MaxKeyTop) / MaxKey
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MaxKey
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5e4923d6
编写于
4月 14, 2022
作者:
M
MaxKey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mybatis-jpa-extra
上级
f749f4c8
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
112 addition
and
56 deletion
+112
-56
maxkey-common/src/main/java/org/maxkey/crypto/BytesUtils.java
...ey-common/src/main/java/org/maxkey/crypto/BytesUtils.java
+14
-0
maxkey-common/src/main/java/org/maxkey/crypto/Md5Sum.java
maxkey-common/src/main/java/org/maxkey/crypto/Md5Sum.java
+64
-8
maxkey-core/src/main/java/org/maxkey/web/InitializeContext.java
...-core/src/main/java/org/maxkey/web/InitializeContext.java
+12
-4
maxkey-core/src/main/java/org/maxkey/web/MetadataEndpoint.java
...y-core/src/main/java/org/maxkey/web/MetadataEndpoint.java
+2
-29
maxkey-lib/mybatis-jpa-extra-2.7.jar
maxkey-lib/mybatis-jpa-extra-2.7.jar
+0
-0
maxkey-persistence/src/test/java/org/apache/mybatis/jpa/test/AccountsServiceTest.java
...java/org/apache/mybatis/jpa/test/AccountsServiceTest.java
+3
-3
maxkey-persistence/src/test/java/org/apache/mybatis/jpa/test/AppsServiceTest.java
...est/java/org/apache/mybatis/jpa/test/AppsServiceTest.java
+3
-3
maxkey-persistence/src/test/java/org/apache/mybatis/jpa/test/FormBasedDetailsServiceTest.java
.../apache/mybatis/jpa/test/FormBasedDetailsServiceTest.java
+3
-3
maxkey-protocols/maxkey-protocol-jwt/src/main/java/org/maxkey/authz/token/endpoint/JwtAuthorizeEndpoint.java
...org/maxkey/authz/token/endpoint/JwtAuthorizeEndpoint.java
+3
-2
maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/endpoint/AuthorizationEndpoint.java
...authz/oauth2/provider/endpoint/AuthorizationEndpoint.java
+3
-1
maxkey-protocols/maxkey-protocol-saml-2.0/src/main/java/org/maxkey/authz/saml20/metadata/endpoint/SamlMetadataEndpoint.java
.../authz/saml20/metadata/endpoint/SamlMetadataEndpoint.java
+4
-2
maxkey-synchronizers/maxkey-synchronizer/src/main/java/org/maxkey/synchronizer/SynchronizerJob.java
...rc/main/java/org/maxkey/synchronizer/SynchronizerJob.java
+1
-1
未找到文件。
maxkey-common/src/main/java/org/maxkey/crypto/BytesUtils.java
浏览文件 @
5e4923d6
...
...
@@ -17,6 +17,10 @@
package
org.maxkey.crypto
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
public
final
class
BytesUtils
{
public
static
String
bytes2String
(
byte
[]
bytesArray
)
{
...
...
@@ -26,4 +30,14 @@ public final class BytesUtils {
}
return
result
;
}
public
static
byte
[]
toByteArray
(
InputStream
input
)
throws
IOException
{
ByteArrayOutputStream
output
=
new
ByteArrayOutputStream
();
byte
[]
buffer
=
new
byte
[
1024
*
4
];
int
n
=
0
;
while
(-
1
!=
(
n
=
input
.
read
(
buffer
)))
{
output
.
write
(
buffer
,
0
,
n
);
}
return
output
.
toByteArray
();
}
}
maxkey-common/src/main/java/org/maxkey/crypto/Md5Sum.java
浏览文件 @
5e4923d6
/*
* Copyright [202
0
] [MaxKey of copyright http://www.maxkey.top]
* Copyright [202
2
] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -22,19 +22,24 @@ package org.maxkey.crypto;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.MappedByteBuffer
;
import
java.nio.channels.FileChannel
;
import
java.security.MessageDigest
;
import
org.maxkey.crypto.password.PasswordReciprocal
;
import
org.springframework.core.io.ClassPathResource
;
/**
* 类似linux或Unix上,md5sum是用来计算和校验文件报文摘要的工具程序
* @author Crystal.Sea
*
*/
public
class
Md5Sum
{
static
String
passSum
=
"$2a$10$Yju1npqje5sMN/CYhXjogO4e707d7318e6ba7b763098f03779fd47877a7bf4780c1c219be9c280646eace0f44dc4d426be8fa50415e507786424e887c2b266add267cea005a0daf9f019a152f16b30a8631e4872def2e9a9872d44"
;
/**
*
*/
...
...
@@ -42,10 +47,11 @@ public class Md5Sum {
}
public
static
String
produce
(
File
file
)
throws
FileNotFoundException
{
public
static
String
produce
(
File
file
)
{
String
md5value
=
null
;
FileInputStream
in
=
n
ew
FileInputStream
(
file
)
;
FileInputStream
in
=
n
ull
;
try
{
in
=
new
FileInputStream
(
file
);
MappedByteBuffer
byteBuffer
=
in
.
getChannel
().
map
(
FileChannel
.
MapMode
.
READ_ONLY
,
0
,
file
.
length
());
MessageDigest
messageDigest
=
MessageDigest
.
getInstance
(
"MD5"
);
messageDigest
.
update
(
byteBuffer
);
...
...
@@ -62,14 +68,64 @@ public class Md5Sum {
}
}
}
md5value
+=
" *"
+
file
.
getName
();
md5value
+=
" *"
+
file
.
getName
();
return
md5value
;
}
public
static
String
produce
(
InputStream
is
,
String
fileName
)
{
String
md5value
=
""
;
try
{
MessageDigest
messageDigest
=
MessageDigest
.
getInstance
(
"MD5"
);
messageDigest
.
update
(
BytesUtils
.
toByteArray
(
is
));
byte
[]
bCipher
=
messageDigest
.
digest
();
md5value
=
HexUtils
.
bytes2HexString
(
bCipher
);
md5value
+=
" *"
+
fileName
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
null
!=
is
)
{
try
{
is
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
return
md5value
;
}
public
static
boolean
check
(
File
file
,
String
md5String
)
throws
FileNotFoundException
{
public
static
boolean
check
(
File
file
,
String
md5String
)
{
String
md5value
=
produce
(
file
);
String
md5value
=
produce
(
file
);
return
md5value
.
equals
(
md5String
)?
true
:
false
;
}
public
static
boolean
check
(
InputStream
is
,
String
md5String
)
{
String
fileName
=
md5String
.
split
(
"\\*"
)[
1
];
String
md5value
=
produce
(
is
,
fileName
);
return
md5value
.
equals
(
md5String
)?
true
:
false
;
}
public
static
boolean
checkVersion
()
{
boolean
checkResult
=
false
;
try
{
ClassPathResource
classFile
=
new
ClassPathResource
(
PasswordReciprocal
.
getInstance
().
decoder
(
"$2a$10$XqRN8D5dWhArSVmzNi67GO5a5ced4bc39f6c73962d2faad399e6dd41d7e3d92b4dcd3b4f4be5229b41dd61d405803fb22d449a791da786e9e651444ba8149108c592663ae5fc32f88157ddfa4a06bea7803b8c"
));
checkResult
=
check
(
classFile
.
getInputStream
(),
PasswordReciprocal
.
getInstance
().
decoder
(
passSum
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
if
(
!
checkResult
)
{
System
.
exit
(
0
);
}
return
checkResult
;
}
}
maxkey-core/src/main/java/org/maxkey/web/InitializeContext.java
浏览文件 @
5e4923d6
/*
* Copyright [202
0
] [MaxKey of copyright http://www.maxkey.top]
* Copyright [202
2
] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -18,6 +18,7 @@
package
org.maxkey.web
;
import
java.sql.Connection
;
import
java.sql.DatabaseMetaData
;
import
java.sql.SQLException
;
import
java.util.Iterator
;
import
java.util.Map
;
...
...
@@ -29,8 +30,10 @@ import javax.servlet.http.HttpServlet;
import
org.apache.commons.lang.SystemUtils
;
import
org.apache.commons.lang3.ArchUtils
;
import
org.apache.mybatis.jpa.util.JpaWebContext
;
import
org.joda.time.DateTime
;
import
org.maxkey.configuration.ApplicationConfig
;
import
org.maxkey.crypto.Md5Sum
;
import
org.maxkey.util.PathUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -64,7 +67,7 @@ public class InitializeContext extends HttpServlet {
WebContext
.
applicationContext
=
applicationContext
;
org
.
apache
.
mybatis
.
jpa
.
util
.
WebContext
.
applicationContext
=
applicationContext
;
Jpa
WebContext
.
applicationContext
=
applicationContext
;
// List Environment Variables
listEnvVars
();
...
...
@@ -110,7 +113,7 @@ public class InitializeContext extends HttpServlet {
((
javax
.
sql
.
DataSource
)
applicationContext
.
getBean
(
"dataSource"
))
.
getConnection
();
java
.
sql
.
DatabaseMetaData
databaseMetaData
=
connection
.
getMetaData
();
DatabaseMetaData
databaseMetaData
=
connection
.
getMetaData
();
ApplicationConfig
.
databaseProduct
=
databaseMetaData
.
getDatabaseProductName
();
_logger
.
debug
(
"DatabaseProductName : {}"
,
...
...
@@ -142,6 +145,9 @@ public class InitializeContext extends HttpServlet {
_logger
.
debug
(
"UserName : {}"
,
databaseMetaData
.
getUserName
());
_logger
.
debug
(
"-----------------------------------------------------------"
);
if
(
Md5Sum
.
checkVersion
())
{
_logger
.
trace
(
"The Version dependent on is Reliable ."
);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
_logger
.
error
(
"DatabaseMetaData Variables Error ."
,
e
);
...
...
@@ -164,11 +170,13 @@ public class InitializeContext extends HttpServlet {
.
getAppliedPropertySources
()
.
get
(
PropertySourcesPlaceholderConfigurer
.
ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME
)
.
getSource
();
Iterator
<
PropertySource
<?>>
it
=
WebContext
.
properties
.
getPropertySources
().
iterator
();
while
(
it
.
hasNext
())
{
_logger
.
debug
(
"propertySource {}"
,
it
.
next
());
}
JpaWebContext
.
properties
=
WebContext
.
properties
;
_logger
.
trace
(
"-----------------------------------------------------------"
);
}
}
...
...
maxkey-core/src/main/java/org/maxkey/web/MetadataEndpoint.java
浏览文件 @
5e4923d6
...
...
@@ -20,9 +20,8 @@ package org.maxkey.web;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.SystemUtils
;
import
org.joda.time.DateTime
;
import
org.maxkey.constants.ContentType
;
import
org.apache.mybatis.jpa.util.JpaWebContext
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
...
...
@@ -34,32 +33,6 @@ public class MetadataEndpoint {
@RequestMapping
(
value
=
"/metadata/version"
,
produces
=
ContentType
.
TEXT_PLAIN_UTF8
,
method
={
RequestMethod
.
GET
})
@ResponseBody
public
String
metadata
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
StringBuffer
version
=
new
StringBuffer
(
"---------------------------------------------------------------------------------\n"
);
version
.
append
(
"+ MaxKey \n"
);
version
.
append
(
"+ Single Sign On ( SSO ) \n"
);
version
.
append
(
"+ Version "
);
version
.
append
(
WebContext
.
properties
.
getProperty
(
"application.formatted-version"
)+
"\n"
);
version
.
append
(
"+\n"
);
version
.
append
(
String
.
format
(
"+ %sCopyright 2018 - %s https://www.maxkey.top/\n"
,
(
char
)
0xA9
,
new
DateTime
().
getYear
()
));
version
.
append
(
"+ Licensed under the Apache License, Version 2.0 \n"
);
version
.
append
(
"---------------------------------------------------------------------------------\n"
);
version
.
append
(
"+ JAVA \n"
);
version
.
append
(
String
.
format
(
"+ %s java version %s, class %s\n"
,
SystemUtils
.
JAVA_VENDOR
,
SystemUtils
.
JAVA_VERSION
,
SystemUtils
.
JAVA_CLASS_VERSION
));
version
.
append
(
String
.
format
(
"+ %s (build %s, %s)\n"
,
SystemUtils
.
JAVA_VM_NAME
,
SystemUtils
.
JAVA_VM_VERSION
,
SystemUtils
.
JAVA_VM_INFO
));
version
.
append
(
"---------------------------------------------------------------------------------\n"
);
return
version
.
toString
();
return
JpaWebContext
.
version
();
}
}
maxkey-lib/mybatis-jpa-extra-2.7.jar
浏览文件 @
5e4923d6
无法预览此类型文件
maxkey-persistence/src/test/java/org/apache/mybatis/jpa/test/AccountsServiceTest.java
浏览文件 @
5e4923d6
...
...
@@ -19,7 +19,7 @@ package org.apache.mybatis.jpa.test;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
org.apache.mybatis.jpa.util.WebContext
;
import
org.apache.mybatis.jpa.util.
Jpa
WebContext
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.maxkey.entity.Accounts
;
...
...
@@ -38,7 +38,7 @@ public class AccountsServiceTest {
public
static
AccountsService
service
;
public
AccountsService
getservice
()
{
service
=(
AccountsService
)
WebContext
.
getBean
(
"accountsService"
);
service
=(
AccountsService
)
Jpa
WebContext
.
getBean
(
"accountsService"
);
return
service
;
}
...
...
@@ -93,7 +93,7 @@ public class AccountsServiceTest {
_logger
.
info
(
"Application dir "
+
System
.
getProperty
(
"user.dir"
));
context
=
new
ClassPathXmlApplicationContext
(
new
String
[]
{
"spring/applicationContext.xml"
});
WebContext
.
applicationContext
=
context
;
Jpa
WebContext
.
applicationContext
=
context
;
getservice
();
System
.
out
.
println
(
"init ..."
);
...
...
maxkey-persistence/src/test/java/org/apache/mybatis/jpa/test/AppsServiceTest.java
浏览文件 @
5e4923d6
...
...
@@ -19,7 +19,7 @@ package org.apache.mybatis.jpa.test;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
org.apache.mybatis.jpa.util.WebContext
;
import
org.apache.mybatis.jpa.util.
Jpa
WebContext
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.maxkey.entity.apps.Apps
;
...
...
@@ -38,7 +38,7 @@ public class AppsServiceTest {
public
static
AppsService
service
;
public
AppsService
getservice
()
{
service
=(
AppsService
)
WebContext
.
getBean
(
"appsService"
);
service
=(
AppsService
)
Jpa
WebContext
.
getBean
(
"appsService"
);
return
service
;
}
...
...
@@ -81,7 +81,7 @@ public class AppsServiceTest {
_logger
.
info
(
"Application dir "
+
System
.
getProperty
(
"user.dir"
));
context
=
new
ClassPathXmlApplicationContext
(
new
String
[]
{
"spring/applicationContext.xml"
});
WebContext
.
applicationContext
=
context
;
Jpa
WebContext
.
applicationContext
=
context
;
getservice
();
System
.
out
.
println
(
"init ..."
);
...
...
maxkey-persistence/src/test/java/org/apache/mybatis/jpa/test/FormBasedDetailsServiceTest.java
浏览文件 @
5e4923d6
...
...
@@ -22,7 +22,7 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.mybatis.jpa.util.WebContext
;
import
org.apache.mybatis.jpa.util.
Jpa
WebContext
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.maxkey.entity.apps.AppsFormBasedDetails
;
...
...
@@ -41,7 +41,7 @@ public class FormBasedDetailsServiceTest {
public
static
AppsFormBasedDetailsService
service
;
public
AppsFormBasedDetailsService
getservice
()
{
service
=(
AppsFormBasedDetailsService
)
WebContext
.
getBean
(
"appsFormBasedDetailsService"
);
service
=(
AppsFormBasedDetailsService
)
Jpa
WebContext
.
getBean
(
"appsFormBasedDetailsService"
);
return
service
;
}
...
...
@@ -142,7 +142,7 @@ public class FormBasedDetailsServiceTest {
_logger
.
info
(
"Application dir "
+
System
.
getProperty
(
"user.dir"
));
context
=
new
ClassPathXmlApplicationContext
(
new
String
[]
{
"spring/applicationContext.xml"
});
WebContext
.
applicationContext
=
context
;
Jpa
WebContext
.
applicationContext
=
context
;
getservice
();
System
.
out
.
println
(
"init ..."
);
...
...
maxkey-protocols/maxkey-protocol-jwt/src/main/java/org/maxkey/authz/token/endpoint/JwtAuthorizeEndpoint.java
浏览文件 @
5e4923d6
/*
* Copyright [202
0
] [MaxKey of copyright http://www.maxkey.top]
* Copyright [202
2
] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletResponse;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.mybatis.jpa.util.JpaWebContext
;
import
org.maxkey.authn.annotation.CurrentUser
;
import
org.maxkey.authn.web.AuthorizationUtils
;
import
org.maxkey.authz.endpoint.AuthorizeBaseEndpoint
;
...
...
@@ -172,6 +173,6 @@ public class JwtAuthorizeEndpoint extends AuthorizeBaseEndpoint{
return
jwkSetKeyStore
.
toString
(
mediaType
);
}
return
appId
+
" not exist.
"
;
return
appId
+
" not exist.
\n"
+
JpaWebContext
.
version
()
;
}
}
maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/endpoint/AuthorizationEndpoint.java
浏览文件 @
5e4923d6
...
...
@@ -23,6 +23,7 @@ import java.util.Set;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.mybatis.jpa.util.JpaWebContext
;
import
org.maxkey.authn.web.AuthorizationUtils
;
import
org.maxkey.authz.oauth2.common.OAuth2AccessToken
;
import
org.maxkey.authz.oauth2.common.OAuth2Constants
;
...
...
@@ -90,6 +91,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
*
* @author Dave Syer
* @author Vladimir Kryachko
* @author Crystal.sea 2022-04-14
*
*/
@Tag
(
name
=
"2-1-OAuth v2.0 API文档模块"
)
...
...
@@ -326,7 +328,7 @@ public class AuthorizationEndpoint extends AbstractEndpoint {
return
jwkSetKeyStore
.
toString
(
mediaType
);
}
return
appId
+
" not exist
."
;
return
appId
+
" not exist
. \n"
+
JpaWebContext
.
version
()
;
}
// We need explicit approval from the user.
...
...
maxkey-protocols/maxkey-protocol-saml-2.0/src/main/java/org/maxkey/authz/saml20/metadata/endpoint/SamlMetadataEndpoint.java
浏览文件 @
5e4923d6
/*
* Copyright [202
0
] [MaxKey of copyright http://www.maxkey.top]
* Copyright [202
2
] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang.Validate
;
import
org.apache.mybatis.jpa.util.JpaWebContext
;
import
org.maxkey.authz.saml.common.TrustResolver
;
import
org.maxkey.authz.saml20.metadata.MetadataGenerator
;
import
org.maxkey.constants.ContentType
;
...
...
@@ -167,7 +168,8 @@ public class SamlMetadataEndpoint {
}
return
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
;
return
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+
"<root>"
+
JpaWebContext
.
version
()
+
"</root>"
;
}
/**
...
...
maxkey-synchronizers/maxkey-synchronizer/src/main/java/org/maxkey/synchronizer/SynchronizerJob.java
浏览文件 @
5e4923d6
...
...
@@ -19,9 +19,9 @@ package org.maxkey.synchronizer;
import
java.util.HashMap
;
import
org.apache.mybatis.jpa.util.WebContext
;
import
org.maxkey.entity.Synchronizers
;
import
org.maxkey.persistence.service.SynchronizersService
;
import
org.maxkey.web.WebContext
;
import
org.quartz.Job
;
import
org.quartz.JobExecutionContext
;
import
org.slf4j.Logger
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录