【问题标题】:Apache Meecrowave OAuth2 JPAApache Meecrowave OAuth2 JPA
【发布时间】:2020-05-06 06:28:38
【问题描述】:

我成功地使用 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.

我想我在配置中遗漏了一些东西......

任何帮助将不胜感激。

发送

【问题讨论】:

    标签: jpa oauth-2.0 openjpa


    【解决方案1】:

    使用--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?),因为我刚刚重新测试并且您的配置似乎有效。

    罗曼

    【讨论】:

    • 我的 pom 中没有其他 PU,只有 Meecrowave deps。虽然调试 jdbc 设置在 props 中正确传播,但 ConnectionUsername、ConnectionURL 仍然为空。我注意到我有 mee oauth2 和 jpa deps,也许 oauth2 就足够了?
    • 我在项目中只有 mee oauth2 和 httpclient 依赖,openjpa 引导仍然失败。我不知道如何设置元数据工厂...
    • 嗨@ocarrey,--oauth2-jpa-properties 使您能够配置完整的持久性单元,只需传递它的属性。您能否在 github 上推送一个使用 h2/hsqldb 复制它的示例项目,让我们有机会仔细看看?
    猜你喜欢
    • 1970-01-01
    • 2015-11-11
    • 2021-08-07
    • 2018-01-17
    • 1970-01-01
    • 2016-09-18
    • 1970-01-01
    • 2015-06-10
    • 1970-01-01
    相关资源
    最近更新 更多