Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3833074b
提交
3833074b
authored
6月 17, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix long lines, missing javadoc, and other formatting
上级
74de7992
显示空白字符变更
内嵌
并排
正在显示
33 个修改的文件
包含
213 行增加
和
158 行删除
+213
-158
changelog.html
h2/src/docsrc/html/changelog.html
+4
-4
features.html
h2/src/docsrc/html/features.html
+9
-9
CredentialsValidator.java
h2/src/main/org/h2/api/CredentialsValidator.java
+10
-6
ErrorCode.java
h2/src/main/org/h2/api/ErrorCode.java
+4
-4
UserToRolesMapper.java
h2/src/main/org/h2/api/UserToRolesMapper.java
+7
-4
Set.java
h2/src/main/org/h2/command/dml/Set.java
+3
-2
ConnectionInfo.java
h2/src/main/org/h2/engine/ConnectionInfo.java
+5
-2
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-1
RightOwner.java
h2/src/main/org/h2/engine/RightOwner.java
+4
-4
SysProperties.java
h2/src/main/org/h2/engine/SysProperties.java
+3
-3
Transaction.java
h2/src/main/org/h2/mvstore/tx/Transaction.java
+10
-5
TransactionMap.java
h2/src/main/org/h2/mvstore/tx/TransactionMap.java
+18
-10
TransactionStore.java
h2/src/main/org/h2/mvstore/tx/TransactionStore.java
+4
-3
TxDecisionMaker.java
h2/src/main/org/h2/mvstore/tx/TxDecisionMaker.java
+4
-3
VersionedValue.java
h2/src/main/org/h2/mvstore/tx/VersionedValue.java
+1
-1
AuthenticationInfo.java
h2/src/main/org/h2/security/auth/AuthenticationInfo.java
+11
-7
Authenticator.java
h2/src/main/org/h2/security/auth/Authenticator.java
+10
-8
ConfigProperties.java
h2/src/main/org/h2/security/auth/ConfigProperties.java
+9
-9
DefaultAuthenticator.java
h2/src/main/org/h2/security/auth/DefaultAuthenticator.java
+45
-37
H2AuthConfig.java
h2/src/main/org/h2/security/auth/H2AuthConfig.java
+1
-1
PropertyConfig.java
h2/src/main/org/h2/security/auth/PropertyConfig.java
+4
-3
RealmConfig.java
h2/src/main/org/h2/security/auth/RealmConfig.java
+3
-0
UserToRolesMapperConfig.java
...rc/main/org/h2/security/auth/UserToRolesMapperConfig.java
+3
-0
AssignRealmNameRole.java
...c/main/org/h2/security/auth/impl/AssignRealmNameRole.java
+4
-4
JaasCredentialsValidator.java
...n/org/h2/security/auth/impl/JaasCredentialsValidator.java
+9
-8
LdapCredentialsValidator.java
...n/org/h2/security/auth/impl/LdapCredentialsValidator.java
+2
-1
StaticRolesMapper.java
h2/src/main/org/h2/security/auth/impl/StaticRolesMapper.java
+4
-4
StaticUserCredentialsValidator.java
...h2/security/auth/impl/StaticUserCredentialsValidator.java
+6
-6
Table.java
h2/src/main/org/h2/table/Table.java
+2
-1
MyLoginModule.java
h2/src/test/org/h2/test/auth/MyLoginModule.java
+1
-1
TestAuthentication.java
h2/src/test/org/h2/test/auth/TestAuthentication.java
+8
-4
TestMvcc4.java
h2/src/test/org/h2/test/mvcc/TestMvcc4.java
+2
-2
TestScript.java
h2/src/test/org/h2/test/scripts/TestScript.java
+2
-1
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
3833074b
h2/src/docsrc/html/features.html
浏览文件 @
3833074b
h2/src/main/org/h2/api/CredentialsValidator.java
浏览文件 @
3833074b
...
...
@@ -9,8 +9,8 @@ import org.h2.security.auth.AuthenticationInfo;
import
org.h2.security.auth.Configurable
;
/**
* A class that implement this interface can be used to validate
*
credentials
provided by client.
* A class that implement this interface can be used to validate
credentials
* provided by client.
* <p>
* <b>This feature is experimental and subject to change</b>
* </p>
...
...
@@ -18,10 +18,14 @@ import org.h2.security.auth.Configurable;
public
interface
CredentialsValidator
extends
Configurable
{
/**
* Validate user credential
* @param authenticationInfo = authentication info
* Validate user credential.
*
* @param authenticationInfo
* = authentication info
* @return true if credentials are valid, otherwise false
* @throws Exception any exception occurred (invalid credentials or internal issue) prevent user login
* @throws Exception
* any exception occurred (invalid credentials or internal
* issue) prevent user login
*/
boolean
validateCredentials
(
AuthenticationInfo
authenticationInfo
)
throws
Exception
;
...
...
h2/src/main/org/h2/api/ErrorCode.java
浏览文件 @
3833074b
h2/src/main/org/h2/api/UserToRolesMapper.java
浏览文件 @
3833074b
...
...
@@ -12,8 +12,8 @@ import org.h2.security.auth.AuthenticationInfo;
import
org.h2.security.auth.Configurable
;
/**
* A class that implement this interface can be used during
*
authentication to
map external users to database roles.
* A class that implement this interface can be used during
authentication to
* map external users to database roles.
* <p>
* <b>This feature is experimental and subject to change</b>
* </p>
...
...
@@ -21,10 +21,13 @@ import org.h2.security.auth.Configurable;
public
interface
UserToRolesMapper
extends
Configurable
{
/**
* Map user identified by authentication info to a set of granted roles
* Map user identified by authentication info to a set of granted roles.
*
* @param authenticationInfo
* authentication information
* @return list of roles to be assigned to the user temporary
* @throws AuthenticationException
* on authentication exception
*/
Collection
<
String
>
mapUserToRoles
(
AuthenticationInfo
authenticationInfo
)
throws
AuthenticationException
;
}
h2/src/main/org/h2/command/dml/Set.java
浏览文件 @
3833074b
...
...
@@ -548,9 +548,10 @@ public class Set extends Prepared {
}
addOrUpdateSetting
(
name
,
expression
.
getValue
(
session
).
getString
(),
0
);
}
catch
(
Exception
e
)
{
//Errors during start are ignored to allow to open the database
//
Errors during start are ignored to allow to open the database
if
(
database
.
isStarting
())
{
database
.
getTrace
(
Trace
.
DATABASE
).
error
(
e
,
"{0}: failed to set authenticator during database start "
,
expression
.
toString
());
database
.
getTrace
(
Trace
.
DATABASE
).
error
(
e
,
"{0}: failed to set authenticator during database start "
,
expression
.
toString
());
}
else
{
throw
DbException
.
convert
(
e
);
}
...
...
h2/src/main/org/h2/engine/ConnectionInfo.java
浏览文件 @
3833074b
...
...
@@ -664,6 +664,9 @@ public class ConnectionInfo implements Cloneable {
return
url
;
}
/**
* Clear authentication properties.
*/
public
void
cleanAuthenticationInfo
()
{
removeProperty
(
"AUTHREALM"
,
false
);
removeProperty
(
"AUTHZPWD"
,
false
);
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
3833074b
h2/src/main/org/h2/engine/RightOwner.java
浏览文件 @
3833074b
h2/src/main/org/h2/engine/SysProperties.java
浏览文件 @
3833074b
h2/src/main/org/h2/mvstore/tx/Transaction.java
浏览文件 @
3833074b
...
...
@@ -475,14 +475,19 @@ public class Transaction {
public
boolean
waitFor
(
Transaction
toWaitFor
)
{
if
(
isDeadlocked
(
toWaitFor
))
{
StringBuilder
details
=
new
StringBuilder
(
String
.
format
(
"Transaction %d has been chosen as a deadlock victim. Details:%n"
,
transactionId
));
for
(
Transaction
tx
=
toWaitFor
,
nextTx
;
(
nextTx
=
tx
.
blockingTransaction
)
!=
null
;
tx
=
nextTx
)
{
details
.
append
(
String
.
format
(
"Transaction %d attempts to update map <%s> entry with key <%s> modified by transaction %s%n"
,
StringBuilder
details
=
new
StringBuilder
(
String
.
format
(
"Transaction %d has been chosen as a deadlock victim. Details:%n"
,
transactionId
));
for
(
Transaction
tx
=
toWaitFor
,
nextTx
;
(
nextTx
=
tx
.
blockingTransaction
)
!=
null
;
tx
=
nextTx
)
{
details
.
append
(
String
.
format
(
"Transaction %d attempts to update map <%s> entry with key <%s> modified by transaction %s%n"
,
tx
.
transactionId
,
tx
.
blockingMap
.
getName
(),
tx
.
blockingKey
,
tx
.
blockingTransaction
));
if
(
nextTx
==
this
)
{
details
.
append
(
String
.
format
(
"Transaction %d attempts to update map <%s> entry with key <%s> modified by transaction %s%n"
,
details
.
append
(
String
.
format
(
"Transaction %d attempts to update map <%s> entry with key <%s>"
+
" modified by transaction %s%n"
,
transactionId
,
blockingMap
.
getName
(),
blockingKey
,
toWaitFor
));
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_TRANSACTIONS_DEADLOCK
,
details
.
toString
());
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_TRANSACTIONS_DEADLOCK
,
details
.
toString
());
}
}
}
...
...
h2/src/main/org/h2/mvstore/tx/TransactionMap.java
浏览文件 @
3833074b
...
...
@@ -130,7 +130,8 @@ public class TransactionMap<K, V> {
}
}
}
else
{
// The undo logs are much smaller than the map - scan all undo logs, and then lookup relevant map entry.
// The undo logs are much smaller than the map - scan all undo logs,
// and then lookup relevant map entry.
for
(
MVMap
.
RootReference
undoLogRootReference
:
undoLogRootReferences
)
{
if
(
undoLogRootReference
!=
null
)
{
Cursor
<
Long
,
Object
[]>
cursor
=
new
Cursor
<>(
undoLogRootReference
.
root
,
null
);
...
...
@@ -139,12 +140,15 @@ public class TransactionMap<K, V> {
Object
op
[]
=
cursor
.
getValue
();
if
((
int
)
op
[
0
]
==
map
.
getId
())
{
VersionedValue
currentValue
=
map
.
get
(
mapRootPage
,
op
[
1
]);
// If map entry is not there, then we never counted it, in the first place, so skip it.
// This is possible when undo entry exists because it belongs
// to a committed but not yet closed transaction,
// and it was later deleted by some other already committed and closed transaction.
// If map entry is not there, then we never counted
// it, in the first place, so skip it.
// This is possible when undo entry exists because
// it belongs to a committed but not yet closed
// transaction, and it was later deleted by some
// other already committed and closed transaction.
if
(
currentValue
!=
null
)
{
// only the last undo entry for any given map key should be considered
// only the last undo entry for any given map
// key should be considered
long
operationId
=
cursor
.
getKey
();
if
(
currentValue
.
getOperationId
()
==
operationId
)
{
int
txId
=
TransactionStore
.
getTransactionId
(
operationId
);
...
...
@@ -204,7 +208,8 @@ public class TransactionMap<K, V> {
*/
public
V
putIfAbsent
(
K
key
,
V
value
)
{
DataUtils
.
checkArgument
(
value
!=
null
,
"The value may not be null"
);
TxDecisionMaker
decisionMaker
=
new
TxDecisionMaker
.
PutIfAbsentDecisionMaker
(
map
.
getId
(),
key
,
value
,
transaction
);
TxDecisionMaker
decisionMaker
=
new
TxDecisionMaker
.
PutIfAbsentDecisionMaker
(
map
.
getId
(),
key
,
value
,
transaction
);
return
set
(
key
,
decisionMaker
);
}
...
...
@@ -275,8 +280,10 @@ public class TransactionMap<K, V> {
}
while
(
blockingTransaction
.
sequenceNum
>
sequenceNumWhenStarted
||
transaction
.
waitFor
(
blockingTransaction
));
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_TRANSACTION_LOCKED
,
"Map entry <{0}> with key <{1}> and value {2} is locked by tx {3} and can not be updated by tx {4} within allocated time interval {5} ms."
,
map
.
getName
(),
key
,
result
,
blockingTransaction
.
transactionId
,
transaction
.
transactionId
,
transaction
.
timeoutMillis
);
"Map entry <{0}> with key <{1}> and value {2} is locked by tx {3} and can not be updated by tx {4}"
+
" within allocated time interval {5} ms."
,
map
.
getName
(),
key
,
result
,
blockingTransaction
.
transactionId
,
transaction
.
transactionId
,
transaction
.
timeoutMillis
);
}
/**
...
...
@@ -319,7 +326,8 @@ public class TransactionMap<K, V> {
*/
public
boolean
trySet
(
K
key
,
V
value
)
{
try
{
// TODO: effective transaction.timeoutMillis should be set to 0 here and restored before return
// TODO: effective transaction.timeoutMillis should be set to 0 here
// and restored before return
// TODO: eliminate exception usage as part of normal control flaw
set
(
key
,
value
);
return
true
;
...
...
h2/src/main/org/h2/mvstore/tx/TransactionStore.java
浏览文件 @
3833074b
...
...
@@ -168,7 +168,8 @@ public class TransactionStore {
assert
committed
||
lastUndoKey
!=
null
;
assert
committed
||
getTransactionId
(
lastUndoKey
)
==
transactionId
;
long
logId
=
lastUndoKey
==
null
?
0
:
getLogId
(
lastUndoKey
)
+
1
;
registerTransaction
(
transactionId
,
status
,
name
,
logId
,
timeoutMillis
,
0
,
RollbackListener
.
NONE
);
registerTransaction
(
transactionId
,
status
,
name
,
logId
,
timeoutMillis
,
0
,
RollbackListener
.
NONE
);
}
}
}
...
...
h2/src/main/org/h2/mvstore/tx/TxDecisionMaker.java
浏览文件 @
3833074b
...
...
@@ -52,7 +52,8 @@ public abstract class TxDecisionMaker extends MVMap.DecisionMaker<VersionedValue
// condition above means transaction has been committed/rplled back and closed by now
decision
=
MVMap
.
Decision
.
REPEAT
;
}
else
{
// this entry comes from a different transaction, and this transaction is not committed yet
// this entry comes from a different transaction, and this
// transaction is not committed yet
// should wait on blockingTransaction that was determined earlier
decision
=
MVMap
.
Decision
.
ABORT
;
}
...
...
h2/src/main/org/h2/mvstore/tx/VersionedValue.java
浏览文件 @
3833074b
h2/src/main/org/h2/security/auth/AuthenticationInfo.java
浏览文件 @
3833074b
...
...
@@ -27,8 +27,8 @@ public class AuthenticationInfo {
public
AuthenticationInfo
(
ConnectionInfo
connectionInfo
)
{
this
.
connectionInfo
=
connectionInfo
;
this
.
realm
=
connectionInfo
.
getProperty
(
"AUTHREALM"
,
null
);
if
(
this
.
realm
!=
null
)
{
this
.
realm
=
StringUtils
.
toUpperEnglish
(
this
.
realm
);
if
(
this
.
realm
!=
null
)
{
this
.
realm
=
StringUtils
.
toUpperEnglish
(
this
.
realm
);
}
this
.
password
=
connectionInfo
.
getProperty
(
"AUTHZPWD"
,
null
);
}
...
...
@@ -50,15 +50,16 @@ public class AuthenticationInfo {
}
public
String
getFullyQualifiedName
()
{
if
(
realm
==
null
)
{
if
(
realm
==
null
)
{
return
connectionInfo
.
getUserName
();
}
else
{
return
connectionInfo
.
getUserName
()+
"@"
+
realm
;
return
connectionInfo
.
getUserName
()
+
"@"
+
realm
;
}
}
/**
* get nested identity
*
* @return
*/
public
Object
getNestedIdentity
()
{
...
...
@@ -66,8 +67,11 @@ public class AuthenticationInfo {
}
/**
* Method used by authenticators to hold informations about authenticated user
* @param nestedIdentity = nested identity object
* Method used by authenticators to hold informations about authenticated
* user
*
* @param nestedIdentity
* = nested identity object
*/
public
void
setNestedIdentity
(
Object
nestedIdentity
)
{
this
.
nestedIdentity
=
nestedIdentity
;
...
...
h2/src/main/org/h2/security/auth/Authenticator.java
浏览文件 @
3833074b
...
...
@@ -9,25 +9,27 @@ import org.h2.engine.Database;
import
org.h2.engine.User
;
/**
* Low level interface to implement full authentication process
* Low level interface to implement full authentication process
.
*/
public
interface
Authenticator
{
/**
*
perform user authentication
*
Perform user authentication.
*
* @param authenticationInfo
* @param database
* @return valid database user or null if user doesn't exists in the database
* @return valid database user or null if user doesn't exists in the
* database
* @throws AuthenticationException
*/
User
authenticate
(
AuthenticationInfo
authenticationInfo
,
Database
database
)
throws
AuthenticationException
;
/**
* Initialize the authenticator. This method is invoked by databases when the authenticator is set
* when the authenticator is set.
* @param database = target database
* Initialize the authenticator. This method is invoked by databases when
* the authenticator is set when the authenticator is set.
*
* @param database
* target database
* @throws AuthConfigException
*/
void
init
(
Database
database
)
throws
AuthConfigException
;
...
...
h2/src/main/org/h2/security/auth/ConfigProperties.java
浏览文件 @
3833074b
...
...
@@ -23,16 +23,16 @@ public class ConfigProperties {
properties
=
new
HashMap
<>();
}
public
ConfigProperties
(
PropertyConfig
...
configProperties
)
{
this
(
configProperties
==
null
?
null
:
Arrays
.
asList
(
configProperties
));
public
ConfigProperties
(
PropertyConfig
...
configProperties
)
{
this
(
configProperties
==
null
?
null
:
Arrays
.
asList
(
configProperties
));
}
public
ConfigProperties
(
Collection
<
PropertyConfig
>
configProperties
)
{
properties
=
new
HashMap
<>();
if
(
properties
!=
null
)
{
for
(
PropertyConfig
currentProperty
:
configProperties
)
{
if
(
properties
.
put
(
currentProperty
.
getName
(),
currentProperty
.
getValue
())
!=
null
)
{
throw
new
AuthConfigException
(
"duplicate property "
+
currentProperty
.
getName
());
if
(
properties
.
put
(
currentProperty
.
getName
(),
currentProperty
.
getValue
())
!=
null
)
{
throw
new
AuthConfigException
(
"duplicate property "
+
currentProperty
.
getName
());
}
}
}
...
...
@@ -49,7 +49,7 @@ public class ConfigProperties {
public
String
getStringValue
(
String
name
)
{
String
result
=
properties
.
get
(
name
);
if
(
result
==
null
)
{
throw
new
AuthConfigException
(
"missing config property "
+
name
);
throw
new
AuthConfigException
(
"missing config property "
+
name
);
}
return
result
;
}
...
...
@@ -65,7 +65,7 @@ public class ConfigProperties {
public
int
getIntValue
(
String
name
)
{
String
result
=
properties
.
get
(
name
);
if
(
result
==
null
)
{
throw
new
AuthConfigException
(
"missing config property "
+
name
);
throw
new
AuthConfigException
(
"missing config property "
+
name
);
}
return
Integer
.
parseInt
(
result
);
}
...
...
h2/src/main/org/h2/security/auth/DefaultAuthenticator.java
浏览文件 @
3833074b
...
...
@@ -33,8 +33,8 @@ import org.h2.util.StringUtils;
* Default authenticator implementation.
* <p>
* When client connectionInfo contains property AUTHREALM={realName} credentials
*
(typically user id and password) are validated
by
*
by
{@link org.h2.api.CredentialsValidator} configured for that realm.
*
(typically user id and password) are validated by
by
* {@link org.h2.api.CredentialsValidator} configured for that realm.
* </p>
* <p>
* When client connectionInfo doesn't contains AUTHREALM property credentials
...
...
@@ -44,8 +44,9 @@ import org.h2.util.StringUtils;
* Rights assignment can be managed through {@link org.h2.api.UserToRolesMapper}
* </p>
* <p>
* Default configuration has a realm H2 that validate credentials through JAAS api (appName=h2).
* To customize configuration set h2.authConfigFile system property to refer a valid h2auth.xml config file
* Default configuration has a realm H2 that validate credentials through JAAS
* api (appName=h2). To customize configuration set h2.authConfigFile system
* property to refer a valid h2auth.xml config file
* </p>
*/
public
class
DefaultAuthenticator
implements
Authenticator
{
...
...
@@ -69,8 +70,8 @@ public class DefaultAuthenticator implements Authenticator {
private
static
DefaultAuthenticator
instance
;
protected
static
final
DefaultAuthenticator
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
DefaultAuthenticator
();
if
(
instance
==
null
)
{
instance
=
new
DefaultAuthenticator
();
}
return
instance
;
}
...
...
@@ -119,8 +120,8 @@ public class DefaultAuthenticator implements Authenticator {
}
/**
* When set create roles not found in the database. If not set roles not
found
* in the database are silently skipped
* When set create roles not found in the database. If not set roles not
*
found
in the database are silently skipped
*
* @return
*/
...
...
@@ -135,8 +136,10 @@ public class DefaultAuthenticator implements Authenticator {
/**
* Add an authentication realm. Realms are case insensitive
*
* @param name realm name
* @param credentialsValidator credentials validator for realm
* @param name
* realm name
* @param credentialsValidator
* credentials validator for realm
*/
public
void
addRealm
(
String
name
,
CredentialsValidator
credentialsValidator
)
{
realms
.
put
(
StringUtils
.
toUpperEnglish
(
name
),
credentialsValidator
);
...
...
@@ -162,13 +165,15 @@ public class DefaultAuthenticator implements Authenticator {
/**
* Initializes the authenticator (it is called by AuthententicationManager)
*
* this method is skipped if skipDefaultInitialization is set
*
Order of initialization is
* this method is skipped if skipDefaultInitialization is set
Order of
*
initialization is
* <ol>
* <li>Check h2.authConfigFile system property.</li>
* <li>Use the default configuration hard coded</li>
* </ol>
* @param database where authenticator is initialized
*
* @param database
* where authenticator is initialized
* @throws AuthConfigException
*/
public
void
init
(
Database
database
)
throws
AuthConfigException
{
...
...
@@ -182,13 +187,14 @@ public class DefaultAuthenticator implements Authenticator {
if
(
initialized
)
{
return
;
}
Trace
trace
=
database
.
getTrace
(
Trace
.
DATABASE
);
Trace
trace
=
database
.
getTrace
(
Trace
.
DATABASE
);
URL
h2AuthenticatorConfigurationUrl
=
null
;
try
{
String
configFile
=
SysProperties
.
AUTH_CONFIG_FILE
;
if
(
configFile
!=
null
)
{
if
(
trace
.
isDebugEnabled
())
{
trace
.
debug
(
"DefaultAuthenticator.config: configuration read from system property h2auth.configurationfile={0}"
,
configFile
);
trace
.
debug
(
"DefaultAuthenticator.config: configuration read from system property"
+
" h2auth.configurationfile={0}"
,
configFile
);
}
h2AuthenticatorConfigurationUrl
=
new
URL
(
configFile
);
}
...
...
@@ -201,11 +207,12 @@ public class DefaultAuthenticator implements Authenticator {
configureFromUrl
(
h2AuthenticatorConfigurationUrl
);
}
}
catch
(
Exception
e
)
{
trace
.
error
(
e
,
"DefaultAuthenticator.config: an error occurred during configuration from {0} "
,
h2AuthenticatorConfigurationUrl
);
throw
new
AuthConfigException
(
"Failed to configure authentication from "
+
h2AuthenticatorConfigurationUrl
,
e
);
trace
.
error
(
e
,
"DefaultAuthenticator.config: an error occurred during configuration from {0} "
,
h2AuthenticatorConfigurationUrl
);
throw
new
AuthConfigException
(
"Failed to configure authentication from "
+
h2AuthenticatorConfigurationUrl
,
e
);
}
initialized
=
true
;
initialized
=
true
;
}
}
...
...
@@ -224,7 +231,8 @@ public class DefaultAuthenticator implements Authenticator {
/**
* Configure the authenticator from a configuration file
*
* @param configUrl URL of configuration file
* @param configUrl
* URL of configuration file
* @throws Exception
*/
public
void
configureFromUrl
(
URL
configUrl
)
throws
Exception
{
...
...
h2/src/main/org/h2/security/auth/H2AuthConfig.java
浏览文件 @
3833074b
h2/src/main/org/h2/security/auth/PropertyConfig.java
浏览文件 @
3833074b
...
...
@@ -25,9 +25,10 @@ public class PropertyConfig {
}
public
PropertyConfig
(
String
name
,
String
value
)
{
this
.
name
=
name
;
this
.
value
=
value
;
this
.
name
=
name
;
this
.
value
=
value
;
}
public
String
getName
()
{
return
name
;
}
...
...
h2/src/main/org/h2/security/auth/RealmConfig.java
浏览文件 @
3833074b
...
...
@@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
/**
* Configuration for authentication realm.
*/
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
RealmConfig
{
...
...
h2/src/main/org/h2/security/auth/UserToRolesMapperConfig.java
浏览文件 @
3833074b
...
...
@@ -13,6 +13,9 @@ import javax.xml.bind.annotation.XmlAccessorType;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
/**
* Configuration for class that maps users to roles.
*/
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
UserToRolesMapperConfig
{
...
...
h2/src/main/org/h2/security/auth/impl/AssignRealmNameRole.java
浏览文件 @
3833074b
h2/src/main/org/h2/security/auth/impl/JaasCredentialsValidator.java
浏览文件 @
3833074b
...
...
@@ -75,7 +75,8 @@ public class JaasCredentialsValidator implements CredentialsValidator {
@Override
public
boolean
validateCredentials
(
AuthenticationInfo
authenticationInfo
)
throws
Exception
{
LoginContext
loginContext
=
new
LoginContext
(
appName
,
new
AuthenticationInfoCallbackHandler
(
authenticationInfo
));
LoginContext
loginContext
=
new
LoginContext
(
appName
,
new
AuthenticationInfoCallbackHandler
(
authenticationInfo
));
loginContext
.
login
();
authenticationInfo
.
setNestedIdentity
(
loginContext
.
getSubject
());
return
true
;
...
...
h2/src/main/org/h2/security/auth/impl/LdapCredentialsValidator.java
浏览文件 @
3833074b
...
...
@@ -21,7 +21,8 @@ import org.h2.security.auth.ConfigProperties;
* Configuration parameters:
* </p>
* <ul>
* <li>bindDnPattern bind dn pattern with %u instead of username (example: uid=%u,ou=users,dc=example,dc=com)</li>
* <li>bindDnPattern bind dn pattern with %u instead of username
* (example: uid=%u,ou=users,dc=example,dc=com)</li>
* <li>host ldap server</li>
* <li>port of ldap service; optional, by default 389 for unsecure, 636 for secure</li>
* <li>secure, optional by default is true (use SSL)</li>
...
...
h2/src/main/org/h2/security/auth/impl/StaticRolesMapper.java
浏览文件 @
3833074b
h2/src/main/org/h2/security/auth/impl/StaticUserCredentialsValidator.java
浏览文件 @
3833074b
...
...
@@ -41,7 +41,6 @@ public class StaticUserCredentialsValidator implements CredentialsValidator {
@Override
public
boolean
validateCredentials
(
AuthenticationInfo
authenticationInfo
)
throws
AuthenticationException
{
if
(
userNamePattern
!=
null
)
{
if
(!
userNamePattern
.
matcher
(
authenticationInfo
.
getUserName
()).
matches
())
{
return
false
;
...
...
@@ -50,7 +49,8 @@ public class StaticUserCredentialsValidator implements CredentialsValidator {
if
(
password
!=
null
)
{
return
password
.
equals
(
authenticationInfo
.
getPassword
());
}
return
Utils
.
compareSecure
(
hashWithSalt
,
SHA256
.
getHashWithSalt
(
authenticationInfo
.
getPassword
().
getBytes
(),
salt
));
return
Utils
.
compareSecure
(
hashWithSalt
,
SHA256
.
getHashWithSalt
(
authenticationInfo
.
getPassword
().
getBytes
(),
salt
));
}
@Override
...
...
h2/src/main/org/h2/table/Table.java
浏览文件 @
3833074b
...
...
@@ -510,7 +510,8 @@ public abstract class Table extends SchemaObjectBase {
try
{
removeRow
(
session
,
o
);
}
catch
(
DbException
e
)
{
if
(
e
.
getErrorCode
()
==
ErrorCode
.
CONCURRENT_UPDATE_1
||
e
.
getErrorCode
()
==
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
)
{
if
(
e
.
getErrorCode
()
==
ErrorCode
.
CONCURRENT_UPDATE_1
||
e
.
getErrorCode
()
==
ErrorCode
.
ROW_NOT_FOUND_WHEN_DELETING_1
)
{
session
.
rollbackTo
(
rollback
,
false
);
session
.
startStatementWithinTransaction
();
rollback
=
session
.
setSavepoint
();
...
...
h2/src/test/org/h2/test/auth/MyLoginModule.java
浏览文件 @
3833074b
h2/src/test/org/h2/test/auth/TestAuthentication.java
浏览文件 @
3833074b
...
...
@@ -31,6 +31,9 @@ import org.h2.security.auth.impl.StaticRolesMapper;
import
org.h2.security.auth.impl.StaticUserCredentialsValidator
;
import
org.h2.test.TestBase
;
/**
* Test for custom authentication.
*/
public
class
TestAuthentication
extends
TestBase
{
public
static
void
main
(
String
...
a
)
throws
Exception
{
...
...
@@ -221,7 +224,8 @@ public class TestAuthentication extends TestBase {
try
{
try
{
Connection
wrongLoginConnection
=
DriverManager
.
getConnection
(
getDatabaseURL
()
+
";AUTHREALM="
+
getRealmName
().
toUpperCase
(),
"___"
+
getExternalUser
(),
""
);
getDatabaseURL
()
+
";AUTHREALM="
+
getRealmName
().
toUpperCase
(),
"___"
+
getExternalUser
(),
""
);
wrongLoginConnection
.
close
();
throw
new
Exception
(
"unregistered external users should not be able to login when allowUserRegistration=false"
);
...
...
h2/src/test/org/h2/test/mvcc/TestMvcc4.java
浏览文件 @
3833074b
...
...
@@ -66,7 +66,6 @@ public class TestMvcc4 extends TestBase {
c1
.
setAutoCommit
(
false
);
//Fire off a concurrent update.
final
Thread
mainThread
=
Thread
.
currentThread
();
final
CountDownLatch
executedUpdate
=
new
CountDownLatch
(
1
);
new
Thread
()
{
@Override
...
...
@@ -83,7 +82,8 @@ public class TestMvcc4 extends TestBase {
executedUpdate
.
countDown
();
// interrogate new "blocker_id" metatable field instead of
// relying on stacktraces!? to determine when session is blocking
PreparedStatement
stmt
=
c2
.
prepareStatement
(
"SELECT * FROM INFORMATION_SCHEMA.SESSIONS WHERE BLOCKER_ID = SESSION_ID()"
);
PreparedStatement
stmt
=
c2
.
prepareStatement
(
"SELECT * FROM INFORMATION_SCHEMA.SESSIONS WHERE BLOCKER_ID = SESSION_ID()"
);
ResultSet
resultSet
;
do
{
resultSet
=
stmt
.
executeQuery
();
...
...
h2/src/test/org/h2/test/scripts/TestScript.java
浏览文件 @
3833074b
...
...
@@ -299,7 +299,8 @@ public class TestScript extends TestBase {
private
void
process
(
String
sql
,
boolean
allowReconnect
)
throws
Exception
{
if
(
allowReconnect
&&
reconnectOften
)
{
if
(!
containsTempTables
()
&&
((
JdbcConnection
)
conn
).
isRegularMode
()
&&
conn
.
getSchema
().
equals
(
"PUBLIC"
))
{
if
(!
containsTempTables
()
&&
((
JdbcConnection
)
conn
).
isRegularMode
()
&&
conn
.
getSchema
().
equals
(
"PUBLIC"
))
{
boolean
autocommit
=
conn
.
getAutoCommit
();
if
(
autocommit
&&
random
.
nextInt
(
10
)
<
1
)
{
// reconnect 10% of the time
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论