如何在 opensaml 4.0.1 中导入 AuthnContextClassRef?
How to import AuthnContextClassRef in opensaml 4.0.1?
我正在尝试将我的代码从旧版本的 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);
}
}
}
我可以从源代码中看到 class 定义在 org.opensaml.saml.saml2.core.AuthnContextClassRef
但是当我尝试导入它时,它说
AuthnContextClassRef cannot be resolved to a type
classConfirmationMethod也是如此,代码如下:
final ConfirmationMethod confirmationMethod = buildObj(ConfirmationMethodBuilder.class,ConfirmationMethod.DEFAULT_ELEMENT_NAME);
confirmationMethod.setConfirmationMethod(SAML10_CM_SENDER_VOUCHES);
我猜你的 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,它也可以
我正在尝试将我的代码从旧版本的 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);
}
}
}
我可以从源代码中看到 class 定义在 org.opensaml.saml.saml2.core.AuthnContextClassRef
但是当我尝试导入它时,它说
AuthnContextClassRef cannot be resolved to a type
classConfirmationMethod也是如此,代码如下:
final ConfirmationMethod confirmationMethod = buildObj(ConfirmationMethodBuilder.class,ConfirmationMethod.DEFAULT_ELEMENT_NAME);
confirmationMethod.setConfirmationMethod(SAML10_CM_SENDER_VOUCHES);
我猜你的 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,它也可以