Apache Meecrowave OAuth2 JPA

问题描述 投票:0回答:1

我成功地使用JCache作为令牌存储创建了自己的OAuth2服务器,但是在转移到JPA时遇到了问题。

我的配置是:

                 "--users","test=test",
                 "--roles","test=test",
                 "--oauth2-provider","jpa",
                 "--oauth2-jpa-database-driver","org.h2.Driver",
                 "--oauth2-jpa-database-url","jdbc:h2:mem:oauth",
                 "--oauth2-jpa-database-username","sa",
                 "--oauth2-jpa-database-password",""

但是在OpenJPA引导过程中,我在下面遇到了异常:

here was an error while setting up the configuration plugin option "MetaDataFactory". 
The plugin was of type "org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory". 
Setter methods for the following plugin properties were not available in that type: [
org.apache.cxf.rs.security.oauth2.tokens.bearer.BearerAccessToken, 
org.apache.cxf.rs.security.oauth2.common.OAuthPermission, 
org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken, 
org.apache.cxf.rs.security.oauth2.grants.code.ServerAuthorizationCodeGrant, 
org.apache.cxf.rs.security.oauth2.common.UserSubject]. 
Possible plugin properties are: 
[AnnotationParser, ClasspathScan, FieldOverride, Files, JAR_FILE_URLS, MAPPING_FILE_NAMES, MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY, PERSISTENCE_UNIT_ROOT_URL, Repository, Resources, STORE_DEFAULT, STORE_PER_CLASS, STORE_VERBOSE, StoreDirectory, StoreMode, Strict, Types, URLs, XMLAnnotationParser, XMLParser].
Ensure that your plugin configuration string uses key values that correspond to setter methods in the plugin class.

我想我错过了配置中的某些内容...

任何帮助将不胜感激。

Tx

jpa oauth-2.0 openjpa
1个回答
0
投票

使用--oauth2-jpa-properties,您可以设置所需的任何持久性单元属性,我想您将必须覆盖openjpa.MetaDataFactory默认值,该默认值设置为jpa(Types=org.apache.cxf.rs.security.oauth2.common.Client,org.apache.cxf.rs.security.oauth2.common.OAuthPermission,org.apache.cxf.rs.security.oauth2.common.UserSubject,org.apache.cxf.rs.security.oauth2.grants.code.ServerAuthorizationCodeGrant,org.apache.cxf.rs.security.oauth2.tokens.bearer.BearerAccessToken,org.apache.cxf.rs.security.oauth2.tokens.refresh.RefreshToken)

您还可以检查您的配置是否正确传播,以及是否没有类路径冲突(另一个带有oauth2单元的persistence.xml?因为我刚刚进行了重新测试,并且您的配置似乎正常。

罗曼

© www.soinside.com 2019 - 2024. All rights reserved.