Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d3c47d30
提交
d3c47d30
authored
10月 22, 2013
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FilePathCrypt > FilePathEncrypt
上级
64fcf884
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
16 行增加
和
16 行删除
+16
-16
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+2
-2
FilePathEncrypt.java
h2/src/main/org/h2/store/fs/FilePathEncrypt.java
+9
-9
ChangeFileEncryption.java
h2/src/main/org/h2/tools/ChangeFileEncryption.java
+5
-5
没有找到文件。
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
d3c47d30
...
@@ -19,7 +19,7 @@ import org.h2.constant.ErrorCode;
...
@@ -19,7 +19,7 @@ import org.h2.constant.ErrorCode;
import
org.h2.constant.SysProperties
;
import
org.h2.constant.SysProperties
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.security.SHA256
;
import
org.h2.security.SHA256
;
import
org.h2.store.fs.FilePath
C
rypt
;
import
org.h2.store.fs.FilePath
Enc
rypt
;
import
org.h2.store.fs.FilePathRec
;
import
org.h2.store.fs.FilePathRec
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.util.New
;
import
org.h2.util.New
;
...
@@ -314,7 +314,7 @@ public class ConnectionInfo implements Cloneable {
...
@@ -314,7 +314,7 @@ public class ConnectionInfo implements Cloneable {
System
.
arraycopy
(
password
,
0
,
filePassword
,
0
,
space
);
System
.
arraycopy
(
password
,
0
,
filePassword
,
0
,
space
);
Arrays
.
fill
(
password
,
(
char
)
0
);
Arrays
.
fill
(
password
,
(
char
)
0
);
password
=
np
;
password
=
np
;
fileEncryptionKey
=
FilePath
C
rypt
.
getPasswordBytes
(
filePassword
);
fileEncryptionKey
=
FilePath
Enc
rypt
.
getPasswordBytes
(
filePassword
);
filePasswordHash
=
hashPassword
(
passwordHash
,
"file"
,
filePassword
);
filePasswordHash
=
hashPassword
(
passwordHash
,
"file"
,
filePassword
);
}
}
userPasswordHash
=
hashPassword
(
passwordHash
,
user
,
password
);
userPasswordHash
=
hashPassword
(
passwordHash
,
user
,
password
);
...
...
h2/src/main/org/h2/store/fs/FilePath
C
rypt.java
→
h2/src/main/org/h2/store/fs/FilePath
Enc
rypt.java
浏览文件 @
d3c47d30
...
@@ -25,15 +25,15 @@ import org.h2.util.MathUtils;
...
@@ -25,15 +25,15 @@ import org.h2.util.MathUtils;
/**
/**
* An encrypted file.
* An encrypted file.
*/
*/
public
class
FilePath
C
rypt
extends
FilePathWrapper
{
public
class
FilePath
Enc
rypt
extends
FilePathWrapper
{
private
static
final
String
SCHEME
=
"crypt"
;
private
static
final
String
SCHEME
=
"
en
crypt"
;
/**
/**
* Register this file system.
* Register this file system.
*/
*/
public
static
void
register
()
{
public
static
void
register
()
{
FilePath
.
register
(
new
FilePath
C
rypt
());
FilePath
.
register
(
new
FilePath
Enc
rypt
());
}
}
@Override
@Override
...
@@ -41,7 +41,7 @@ public class FilePathCrypt extends FilePathWrapper {
...
@@ -41,7 +41,7 @@ public class FilePathCrypt extends FilePathWrapper {
String
[]
parsed
=
parse
(
name
);
String
[]
parsed
=
parse
(
name
);
FileChannel
file
=
FileUtils
.
open
(
parsed
[
1
],
mode
);
FileChannel
file
=
FileUtils
.
open
(
parsed
[
1
],
mode
);
byte
[]
passwordBytes
=
parsed
[
0
].
getBytes
(
Constants
.
UTF8
);
byte
[]
passwordBytes
=
parsed
[
0
].
getBytes
(
Constants
.
UTF8
);
return
new
File
C
rypt
(
name
,
passwordBytes
,
file
);
return
new
File
Enc
rypt
(
name
,
passwordBytes
,
file
);
}
}
@Override
@Override
...
@@ -62,10 +62,10 @@ public class FilePathCrypt extends FilePathWrapper {
...
@@ -62,10 +62,10 @@ public class FilePathCrypt extends FilePathWrapper {
@Override
@Override
public
long
size
()
{
public
long
size
()
{
long
size
=
getBase
().
size
()
-
File
C
rypt
.
HEADER_LENGTH
;
long
size
=
getBase
().
size
()
-
File
Enc
rypt
.
HEADER_LENGTH
;
size
=
Math
.
max
(
0
,
size
);
size
=
Math
.
max
(
0
,
size
);
if
((
size
&
File
C
rypt
.
BLOCK_SIZE_MASK
)
!=
0
)
{
if
((
size
&
File
Enc
rypt
.
BLOCK_SIZE_MASK
)
!=
0
)
{
size
-=
File
C
rypt
.
BLOCK_SIZE
;
size
-=
File
Enc
rypt
.
BLOCK_SIZE
;
}
}
return
size
;
return
size
;
}
}
...
@@ -123,7 +123,7 @@ public class FilePathCrypt extends FilePathWrapper {
...
@@ -123,7 +123,7 @@ public class FilePathCrypt extends FilePathWrapper {
/**
/**
* An encrypted file with a read cache.
* An encrypted file with a read cache.
*/
*/
public
static
class
File
C
rypt
extends
FileBase
{
public
static
class
File
Enc
rypt
extends
FileBase
{
/**
/**
* The block size.
* The block size.
...
@@ -171,7 +171,7 @@ public class FilePathCrypt extends FilePathWrapper {
...
@@ -171,7 +171,7 @@ public class FilePathCrypt extends FilePathWrapper {
private
final
String
name
;
private
final
String
name
;
public
File
C
rypt
(
String
name
,
byte
[]
encryptionKey
,
FileChannel
base
)
throws
IOException
{
public
File
Enc
rypt
(
String
name
,
byte
[]
encryptionKey
,
FileChannel
base
)
throws
IOException
{
this
.
name
=
name
;
this
.
name
=
name
;
this
.
base
=
base
;
this
.
base
=
base
;
this
.
size
=
base
.
size
()
-
HEADER_LENGTH
;
this
.
size
=
base
.
size
()
-
HEADER_LENGTH
;
...
...
h2/src/main/org/h2/tools/ChangeFileEncryption.java
浏览文件 @
d3c47d30
...
@@ -21,7 +21,7 @@ import org.h2.store.FileStore;
...
@@ -21,7 +21,7 @@ import org.h2.store.FileStore;
import
org.h2.store.fs.FileChannelInputStream
;
import
org.h2.store.fs.FileChannelInputStream
;
import
org.h2.store.fs.FileChannelOutputStream
;
import
org.h2.store.fs.FileChannelOutputStream
;
import
org.h2.store.fs.FilePath
;
import
org.h2.store.fs.FilePath
;
import
org.h2.store.fs.FilePath
C
rypt
;
import
org.h2.store.fs.FilePath
Enc
rypt
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.util.Tool
;
import
org.h2.util.Tool
;
...
@@ -152,11 +152,11 @@ public class ChangeFileEncryption extends Tool {
...
@@ -152,11 +152,11 @@ public class ChangeFileEncryption extends Tool {
throw
new
SQLException
(
"The file password may not contain spaces"
);
throw
new
SQLException
(
"The file password may not contain spaces"
);
}
}
}
}
change
.
encryptKey
=
FilePath
C
rypt
.
getPasswordBytes
(
encryptPassword
);
change
.
encryptKey
=
FilePath
Enc
rypt
.
getPasswordBytes
(
encryptPassword
);
change
.
encrypt
=
getFileEncryptionKey
(
encryptPassword
);
change
.
encrypt
=
getFileEncryptionKey
(
encryptPassword
);
}
}
if
(
decryptPassword
!=
null
)
{
if
(
decryptPassword
!=
null
)
{
change
.
decryptKey
=
FilePath
C
rypt
.
getPasswordBytes
(
decryptPassword
);
change
.
decryptKey
=
FilePath
Enc
rypt
.
getPasswordBytes
(
decryptPassword
);
change
.
decrypt
=
getFileEncryptionKey
(
decryptPassword
);
change
.
decrypt
=
getFileEncryptionKey
(
decryptPassword
);
}
}
change
.
out
=
out
;
change
.
out
=
out
;
...
@@ -213,14 +213,14 @@ public class ChangeFileEncryption extends Tool {
...
@@ -213,14 +213,14 @@ public class ChangeFileEncryption extends Tool {
}
}
FileChannel
fileIn
=
FilePath
.
get
(
fileName
).
open
(
"r"
);
FileChannel
fileIn
=
FilePath
.
get
(
fileName
).
open
(
"r"
);
if
(
decryptKey
!=
null
)
{
if
(
decryptKey
!=
null
)
{
fileIn
=
new
FilePath
Crypt
.
FileC
rypt
(
fileName
,
decryptKey
,
fileIn
);
fileIn
=
new
FilePath
Encrypt
.
FileEnc
rypt
(
fileName
,
decryptKey
,
fileIn
);
}
}
InputStream
inStream
=
new
FileChannelInputStream
(
fileIn
,
true
);
InputStream
inStream
=
new
FileChannelInputStream
(
fileIn
,
true
);
String
temp
=
directory
+
"/temp.db"
;
String
temp
=
directory
+
"/temp.db"
;
FileUtils
.
delete
(
temp
);
FileUtils
.
delete
(
temp
);
FileChannel
fileOut
=
FilePath
.
get
(
temp
).
open
(
"rw"
);
FileChannel
fileOut
=
FilePath
.
get
(
temp
).
open
(
"rw"
);
if
(
encryptKey
!=
null
)
{
if
(
encryptKey
!=
null
)
{
fileOut
=
new
FilePath
Crypt
.
FileC
rypt
(
temp
,
encryptKey
,
fileOut
);
fileOut
=
new
FilePath
Encrypt
.
FileEnc
rypt
(
temp
,
encryptKey
,
fileOut
);
}
}
OutputStream
outStream
=
new
FileChannelOutputStream
(
fileOut
,
true
);
OutputStream
outStream
=
new
FileChannelOutputStream
(
fileOut
,
true
);
byte
[]
buffer
=
new
byte
[
4
*
1024
];
byte
[]
buffer
=
new
byte
[
4
*
1024
];
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论