【问题标题】:How to import AuthnContextClassRef in opensaml 4.0.1?如何在 opensaml 4.0.1 中导入 AuthnContextClassRef?
【发布时间】:2022-01-11 03:54:51
【问题描述】:

我正在尝试将我的代码从旧版本的 opensaml 迁移到版本 4.0.1

AuthnContextClassRef authnCtxClassRef = null;
            
            final AuthnContext authnCtx = existing20authnStatement.getAuthnContext();

            if (authnCtx != null) {
                authnCtxClassRef = authnCtx.getAuthnContextClassRef();

                if (authnCtxClassRef != null) {
                    authnCtxClassRefName = authnCtxClassRef.getAuthnContextClassRef();

                    if (authnCtxClassRefName != null) {
                        authNStmt.setAuthenticationInstant(now);
                        authNStmt.setAuthenticationMethod(translateAuthN20to11(authnCtxClassRefName));
                        authNStmt.setSubject(makeSubject(subjectName, nameId));

                        assertion.getAuthenticationStatements().add(authNStmt);
                    }
                }
            }

我可以从源代码中看到该类定义在org.opensaml.saml.saml2.core.AuthnContextClassRef 但是当我尝试导入它时,它说

AuthnContextClassRef 无法解析为类型

类 ConfirmationMethod 也是如此,编写的代码如下:

final ConfirmationMethod confirmationMethod = buildObj(ConfirmationMethodBuilder.class,ConfirmationMethod.DEFAULT_ELEMENT_NAME);
confirmationMethod.setConfirmationMethod(SAML10_CM_SENDER_VOUCHES);

【问题讨论】:

    标签: java saml saml-2.0 opensaml


    【解决方案1】:

    我猜你的 POM 中缺少一些依赖项。我有一个working PoC for OpenSAML 4 here。我使用以下依赖项和 AuthnContextClassRef 工作正常。

    <dependency>
        <groupId>org.opensaml</groupId>
        <artifactId>opensaml-core</artifactId>
        <version>4.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.opensaml</groupId>
        <artifactId>opensaml-saml-api</artifactId>
        <version>4.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.opensaml</groupId>
        <artifactId>opensaml-saml-impl</artifactId>
        <version>4.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.opensaml</groupId>
        <artifactId>opensaml-messaging-api</artifactId>
        <version>4.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.opensaml</groupId>
        <artifactId>opensaml-messaging-impl</artifactId>
        <version>4.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.opensaml</groupId>
        <artifactId>opensaml-soap-api</artifactId>
        <version>4.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.opensaml</groupId>
        <artifactId>opensaml-soap-impl</artifactId>
        <version>4.1.1</version>
    </dependency>
    

    我尝试了 4.0.1,它也可以工作

    【讨论】:

    • 谢谢。我使用的是旧版本的eclipse。将该版本升级到 4.11 对我有用。
    • 好的,我现在也将链接添加到我的 PoC。可能有用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-17
    • 1970-01-01
    • 2018-03-25
    • 1970-01-01
    • 2023-01-30
    相关资源
    最近更新 更多