Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
16e4b4c6
提交
16e4b4c6
authored
6月 22, 2018
作者:
Noel Grandin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean up some throws clauses
上级
6e26dce4
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
21 行增加
和
14 行删除
+21
-14
DefaultAuthenticator.java
h2/src/main/org/h2/security/auth/DefaultAuthenticator.java
+10
-6
H2AuthConfigXml.java
h2/src/main/org/h2/security/auth/H2AuthConfigXml.java
+8
-4
PgServerThread.java
h2/src/main/org/h2/server/pg/PgServerThread.java
+3
-4
没有找到文件。
h2/src/main/org/h2/security/auth/DefaultAuthenticator.java
浏览文件 @
16e4b4c6
...
...
@@ -5,6 +5,7 @@
*/
package
org
.
h2
.
security
.
auth
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.Collection
;
...
...
@@ -13,6 +14,7 @@ import java.util.HashSet;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.xml.parsers.ParserConfigurationException
;
import
org.h2.api.CredentialsValidator
;
import
org.h2.api.UserToRolesMapper
;
import
org.h2.engine.Database
;
...
...
@@ -25,6 +27,7 @@ import org.h2.message.Trace;
import
org.h2.security.auth.impl.AssignRealmNameRole
;
import
org.h2.security.auth.impl.JaasCredentialsValidator
;
import
org.h2.util.StringUtils
;
import
org.xml.sax.SAXException
;
/**
* Default authenticator implementation.
...
...
@@ -223,19 +226,20 @@ public class DefaultAuthenticator implements Authenticator {
*
* @param configUrl URL of configuration file
*/
public
void
configureFromUrl
(
URL
configUrl
)
throws
Exception
{
public
void
configureFromUrl
(
URL
configUrl
)
throws
AuthenticationException
,
SAXException
,
IOException
,
ParserConfigurationException
{
H2AuthConfig
config
=
H2AuthConfigXml
.
parseFrom
(
configUrl
);
configureFrom
(
config
);
}
void
configureFrom
(
H2AuthConfig
config
)
throws
Exception
{
void
configureFrom
(
H2AuthConfig
config
)
throws
Authentication
Exception
{
allowUserRegistration
=
config
.
isAllowUserRegistration
();
createMissingRoles
=
config
.
isCreateMissingRoles
();
Map
<
String
,
CredentialsValidator
>
newRealms
=
new
HashMap
<>();
for
(
RealmConfig
currentRealmConfig
:
config
.
getRealms
())
{
String
currentRealmName
=
currentRealmConfig
.
getName
();
if
(
currentRealmName
==
null
)
{
throw
new
Exception
(
"Missing realm name"
);
throw
new
Authentication
Exception
(
"Missing realm name"
);
}
currentRealmName
=
currentRealmName
.
toUpperCase
();
CredentialsValidator
currentValidator
=
null
;
...
...
@@ -243,11 +247,11 @@ public class DefaultAuthenticator implements Authenticator {
currentValidator
=
(
CredentialsValidator
)
Class
.
forName
(
currentRealmConfig
.
getValidatorClass
())
.
newInstance
();
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"invalid validator class fo realm "
+
currentRealmName
,
e
);
throw
new
Authentication
Exception
(
"invalid validator class fo realm "
+
currentRealmName
,
e
);
}
currentValidator
.
configure
(
new
ConfigProperties
(
currentRealmConfig
.
getProperties
()));
if
(
newRealms
.
put
(
currentRealmConfig
.
getName
().
toUpperCase
(),
currentValidator
)
!=
null
)
{
throw
new
Exception
(
"Duplicate realm "
+
currentRealmConfig
.
getName
());
throw
new
Authentication
Exception
(
"Duplicate realm "
+
currentRealmConfig
.
getName
());
}
}
this
.
realms
=
newRealms
;
...
...
@@ -258,7 +262,7 @@ public class DefaultAuthenticator implements Authenticator {
currentUserToRolesMapper
=
(
UserToRolesMapper
)
Class
.
forName
(
currentUserToRolesMapperConfig
.
getClassName
()).
newInstance
();
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"Invalid class in UserToRolesMapperConfig"
,
e
);
throw
new
Authentication
Exception
(
"Invalid class in UserToRolesMapperConfig"
,
e
);
}
currentUserToRolesMapper
.
configure
(
new
ConfigProperties
(
currentUserToRolesMapperConfig
.
getProperties
()));
newUserToRolesMapper
.
add
(
currentUserToRolesMapper
);
...
...
h2/src/main/org/h2/security/auth/H2AuthConfigXml.java
浏览文件 @
16e4b4c6
...
...
@@ -5,8 +5,10 @@
*/
package
org
.
h2
.
security
.
auth
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
import
javax.xml.parsers.ParserConfigurationException
;
import
javax.xml.parsers.SAXParser
;
import
javax.xml.parsers.SAXParserFactory
;
import
org.xml.sax.Attributes
;
...
...
@@ -90,16 +92,18 @@ public class H2AuthConfigXml extends DefaultHandler{
/**
* Parse the xml
*/
public
static
H2AuthConfig
parseFrom
(
URL
url
)
throws
Exception
{
try
(
InputStream
inputStream
=
url
.
openStream
())
{
public
static
H2AuthConfig
parseFrom
(
URL
url
)
throws
SAXException
,
IOException
,
ParserConfigurationException
{
try
(
InputStream
inputStream
=
url
.
openStream
())
{
return
parseFrom
(
inputStream
);
}
}
public
static
H2AuthConfig
parseFrom
(
InputStream
inputStream
)
throws
Exception
{
public
static
H2AuthConfig
parseFrom
(
InputStream
inputStream
)
throws
SAXException
,
IOException
,
ParserConfigurationException
{
SAXParser
saxParser
=
SAXParserFactory
.
newInstance
().
newSAXParser
();
H2AuthConfigXml
xmlHandler
=
new
H2AuthConfigXml
();
saxParser
.
parse
(
inputStream
,
xmlHandler
);
saxParser
.
parse
(
inputStream
,
xmlHandler
);
return
xmlHandler
.
getResult
();
}
}
h2/src/main/org/h2/server/pg/PgServerThread.java
浏览文件 @
16e4b4c6
...
...
@@ -30,7 +30,6 @@ import java.sql.Types;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Properties
;
import
org.h2.command.CommandInterface
;
import
org.h2.engine.ConnectionInfo
;
import
org.h2.engine.Constants
;
...
...
@@ -508,7 +507,7 @@ public class PgServerThread implements Runnable {
sendMessage
();
}
private
void
sendDataRow
(
ResultSet
rs
,
int
[]
formatCodes
)
throws
Exception
{
private
void
sendDataRow
(
ResultSet
rs
,
int
[]
formatCodes
)
throws
IOException
,
SQL
Exception
{
ResultSetMetaData
metaData
=
rs
.
getMetaData
();
int
columns
=
metaData
.
getColumnCount
();
startMessage
(
'D'
);
...
...
@@ -535,7 +534,7 @@ public class PgServerThread implements Runnable {
}
private
void
writeDataColumn
(
ResultSet
rs
,
int
column
,
int
pgType
,
boolean
text
)
throws
Exception
{
throws
IO
Exception
{
Value
v
=
((
JdbcResultSet
)
rs
).
get
(
column
);
if
(
v
==
ValueNull
.
INSTANCE
)
{
writeInt
(-
1
);
...
...
@@ -758,7 +757,7 @@ public class PgServerThread implements Runnable {
sendMessage
();
}
private
void
sendRowDescription
(
ResultSetMetaData
meta
)
throws
Exception
{
private
void
sendRowDescription
(
ResultSetMetaData
meta
)
throws
IOException
,
SQL
Exception
{
if
(
meta
==
null
)
{
sendNoData
();
}
else
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论