Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
baf17927
提交
baf17927
authored
9月 16, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
If the user name and password are not set or empty, then the password is not hashed.
上级
6d243eec
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
34 行增加
和
9 行删除
+34
-9
changelog.html
h2/src/docsrc/html/changelog.html
+4
-1
CreateUser.java
h2/src/main/org/h2/command/ddl/CreateUser.java
+8
-2
SysProperties.java
h2/src/main/org/h2/constant/SysProperties.java
+6
-0
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+3
-0
User.java
h2/src/main/org/h2/engine/User.java
+11
-4
TcpServer.java
h2/src/main/org/h2/server/TcpServer.java
+2
-2
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
baf17927
...
...
@@ -18,7 +18,10 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Cluster: auto-commit was disabled after opening a connection.
<ul><li>
If the user name and password are not set or empty, then the password is not hashed.
To disable this behavior, set the system property h2.emptyPassword to false.
TCP server: the default user name for the management database is now an empty string.
</li><li>
Cluster: auto-commit was disabled after opening a connection.
</li><li>
Connection.getAutoCommit() is now much faster, specially when using the server mode.
</li><li>
Statement.cancel() had no effect when using the server mode.
</li><li>
SCRIPT: the SQL script no longer contains settings that match the default value.
...
...
h2/src/main/org/h2/command/ddl/CreateUser.java
浏览文件 @
baf17927
...
...
@@ -7,6 +7,7 @@
package
org
.
h2
.
command
.
ddl
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.engine.Database
;
import
org.h2.engine.Session
;
import
org.h2.engine.User
;
...
...
@@ -73,9 +74,14 @@ public class CreateUser extends DefineCommand {
if
(
hash
!=
null
&&
salt
!=
null
)
{
user
.
setSaltAndHash
(
getByteArray
(
salt
),
getByteArray
(
hash
));
}
else
if
(
password
!=
null
)
{
SHA256
sha
=
new
SHA256
();
char
[]
passwordChars
=
getCharArray
(
password
);
byte
[]
userPasswordHash
=
sha
.
getKeyPasswordHash
(
userName
,
passwordChars
);
byte
[]
userPasswordHash
;
if
(
userName
.
length
()
==
0
&&
passwordChars
.
length
==
0
&&
SysProperties
.
EMPTY_PASSWORD
)
{
userPasswordHash
=
new
byte
[
0
];
}
else
{
SHA256
sha
=
new
SHA256
();
userPasswordHash
=
sha
.
getKeyPasswordHash
(
userName
,
passwordChars
);
}
user
.
setUserPasswordHash
(
userPasswordHash
);
}
else
{
throw
DbException
.
throwInternalError
();
...
...
h2/src/main/org/h2/constant/SysProperties.java
浏览文件 @
baf17927
...
...
@@ -296,6 +296,12 @@ public class SysProperties {
*/
public
static
final
int
ESTIMATED_FUNCTION_TABLE_ROWS
=
getIntSetting
(
"h2.estimatedFunctionTableRows"
,
1000
);
/**
* System property <code>h2.emptyPassword</code> (default: true).<br />
* Don't use a secure hash if the user name and password are empty or not set.
*/
public
static
final
boolean
EMPTY_PASSWORD
=
getBooleanSetting
(
"h2.emptyPassword"
,
true
);
/**
* System property <code>h2.functionsInSchema</code> (default:
* false).<br />
...
...
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
baf17927
...
...
@@ -274,6 +274,9 @@ public class ConnectionInfo implements Cloneable {
if
(
passwordHash
)
{
return
StringUtils
.
convertStringToBytes
(
new
String
(
password
));
}
else
{
if
(
userName
.
length
()
==
0
&&
password
.
length
==
0
&&
SysProperties
.
EMPTY_PASSWORD
)
{
return
new
byte
[
0
];
}
SHA256
sha
=
new
SHA256
();
return
sha
.
getKeyPasswordHash
(
userName
,
password
);
}
...
...
h2/src/main/org/h2/engine/User.java
浏览文件 @
baf17927
...
...
@@ -64,10 +64,14 @@ public class User extends RightOwner {
*/
public
void
setUserPasswordHash
(
byte
[]
userPasswordHash
)
{
if
(
userPasswordHash
!=
null
)
{
salt
=
new
byte
[
Constants
.
SALT_LEN
];
MathUtils
.
randomBytes
(
salt
);
SHA256
sha
=
new
SHA256
();
this
.
passwordHash
=
sha
.
getHashWithSalt
(
userPasswordHash
,
salt
);
if
(
userPasswordHash
.
length
==
0
)
{
salt
=
passwordHash
=
userPasswordHash
;
}
else
{
salt
=
new
byte
[
Constants
.
SALT_LEN
];
MathUtils
.
randomBytes
(
salt
);
SHA256
sha
=
new
SHA256
();
passwordHash
=
sha
.
getHashWithSalt
(
userPasswordHash
,
salt
);
}
}
}
...
...
@@ -179,6 +183,9 @@ public class User extends RightOwner {
* @return true if the user password hash is correct
*/
public
boolean
validateUserPasswordHash
(
byte
[]
userPasswordHash
)
{
if
(
userPasswordHash
.
length
==
0
&&
passwordHash
.
length
==
0
)
{
return
true
;
}
SHA256
sha
=
new
SHA256
();
byte
[]
hash
=
sha
.
getHashWithSalt
(
userPasswordHash
,
salt
);
return
Utils
.
compareSecure
(
hash
,
passwordHash
);
...
...
h2/src/main/org/h2/server/TcpServer.java
浏览文件 @
baf17927
...
...
@@ -82,7 +82,7 @@ public class TcpServer implements Service {
private
void
initManagementDb
()
throws
SQLException
{
Properties
prop
=
new
Properties
();
prop
.
setProperty
(
"user"
,
"
sa
"
);
prop
.
setProperty
(
"user"
,
""
);
prop
.
setProperty
(
"password"
,
managementPassword
);
// avoid using the driver manager
Connection
conn
=
Driver
.
load
().
connect
(
"jdbc:h2:"
+
getManagementDbName
(
port
),
prop
);
...
...
@@ -407,7 +407,7 @@ public class TcpServer implements Service {
Connection
conn
=
null
;
PreparedStatement
prep
=
null
;
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:"
+
url
+
"/"
+
db
,
"
sa
"
,
password
);
conn
=
DriverManager
.
getConnection
(
"jdbc:h2:"
+
url
+
"/"
+
db
,
""
,
password
);
prep
=
conn
.
prepareStatement
(
"CALL STOP_SERVER(?, ?, ?)"
);
prep
.
setInt
(
1
,
all
?
0
:
port
);
prep
.
setString
(
2
,
password
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论