本文整理汇总了Java中org.opensaml.saml2.core.AuthnContextClassRef.getAuthnContextClassRef方法的典型用法代码示例。如果您正苦于以下问题:Java AuthnContextClassRef.getAuthnContextClassRef方法的具体用法?Java AuthnContextClassRef.getAuthnContextClassRef怎么用?Java AuthnContextClassRef.getAuthnContextClassRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.saml2.core.AuthnContextClassRef
的用法示例。
在下文中一共展示了AuthnContextClassRef.getAuthnContextClassRef方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAuthnContextClassRef
import org.opensaml.saml2.core.AuthnContextClassRef; //导入方法依赖的package包/类
/**
* Return the value of the /AuthnStatement/AuthnContext/AuthnContextClassRef
* element in an assertion
*
* @return The value. <code>null</code>, if the assertion does not
* contain the element.
*/
public String getAuthnContextClassRef() {
String retVal = null;
if (assertion.getAuthnStatements() != null) {
if (assertion.getAuthnStatements().size() > 0) {
// We only look into the first AuthnStatement
AuthnStatement authnStatement = (AuthnStatement) assertion.getAuthnStatements().get(0);
AuthnContext authnContext = authnStatement.getAuthnContext();
if (authnContext != null) {
AuthnContextClassRef authnContextClassRef = authnContext.getAuthnContextClassRef();
if (authnContextClassRef != null) {
retVal = authnContextClassRef.getAuthnContextClassRef();
}
}
}
}
return retVal;
}
示例2: testSingleElementUnmarshall
import org.opensaml.saml2.core.AuthnContextClassRef; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementUnmarshall() {
AuthnContextClassRef authnContextClassRef = (AuthnContextClassRef) unmarshallElement(singleElementFile);
String classRef = authnContextClassRef.getAuthnContextClassRef();
assertEquals("Class Reference was " + classRef + ", expected " + expectedClassRef, expectedClassRef, classRef);
}
示例3: validate
import org.opensaml.saml2.core.AuthnContextClassRef; //导入方法依赖的package包/类
public void validate(OIOAssertion assertion, String spEntityId, String spAssertionConsumerURL) throws ValidationException {
super.validate(assertion, spEntityId, spAssertionConsumerURL);
Assertion a = assertion.getAssertion();
DateTime confirmationTime = assertion.getConfirmationTime();
if (confirmationTime == null || !confirmationTime.isAfterNow()) {
throw new ValidationException("Subject Confirmation Data is expired: " + confirmationTime + " before " + new DateTime());
}
// There must be only be one AuthnStatement within the assertion
if (a.getAuthnStatements().size() != 1) {
throw new ValidationException("The assertion must contain exactly one AuthnStatement. Was " + a.getAuthnStatements().size());
}
// AssuranceLevel and AuthnStatement/AuthnContext/AuthnContextClassRef must be consistent
int assuranceLevel = assertion.getAssuranceLevel();
String authnContextClassRefValue = null;
AuthnStatement authnStatement = (AuthnStatement) a.getAuthnStatements().get(0);
AuthnContext authnContext = authnStatement.getAuthnContext();
if (authnContext != null) {
AuthnContextClassRef authnContextClassRef = authnContext.getAuthnContextClassRef();
if (authnContextClassRef != null) {
authnContextClassRefValue = authnContextClassRef.getAuthnContextClassRef();
}
}
if (assuranceLevel == AssuranceLevel.PASSWORD_ASSURANCE_LEVEL &&
!OIOSAMLConstants.PASSWORD_AUTHN_CONTEXT_CLASS_REF.equals(authnContextClassRefValue)) {
log.warn("The assuranceLevel attribute " + assuranceLevel + " in the assertion does not correspond with the value of AuthnStatement/AuthnContext/AuthnContextClassRef: " + authnContextClassRefValue);
} else if (assuranceLevel == AssuranceLevel.CERTIFICATE_ASSURANCE_LEVEL &&
!OIOSAMLConstants.X509_AUTHN_CONTEXT_CLASS_REF.equals(authnContextClassRefValue)) {
log.warn("The assuranceLevel attribute " + assuranceLevel + " in the assertion does not correspond with the value of AuthnStatement/AuthnContext/AuthnContextClassRef: " + authnContextClassRefValue);
}
// There must be a SessionIndex
if (assertion.getSessionIndex() == null) {
throw new ValidationException("The assertion must contain a [email protected]");
}
// There must be exactly one AttributeStatement within the assertion
if (a.getAttributeStatements().size() != 1) {
throw new ValidationException("The assertion must contain exactly one AttributeStatement. Contains " + a.getAttributeStatements().size());
}
// There must not be a AttributeStatement within the assertion
if (a.getAuthzDecisionStatements().size() != 0) {
throw new ValidationException("The assertion must not contain a AuthzDecisionStatement. Contains " + a.getAuthzDecisionStatements().size());
}
// There must be a valid recipient
if (!assertion.checkRecipient(spAssertionConsumerURL)) {
throw new ValidationException("The assertion must contain the recipient "+ spAssertionConsumerURL);
}
// Session must not have expired
if (authnStatement.getSessionNotOnOrAfter() != null &&
!authnStatement.getSessionNotOnOrAfter().isAfterNow()) {
throw new ValidationException("The assertion must have a [email protected] and it must not have expired. SessionNotOnOrAfter: " + authnStatement.getSessionNotOnOrAfter());
}
}