当前位置: 首页>>代码示例>>Java>>正文


Java AuthnContextClassRef.getAuthnContextClassRef方法代码示例

本文整理汇总了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;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:25,代码来源:OIOAssertion.java

示例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);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:8,代码来源:AuthnContextClassRefTest.java

示例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());
   	}
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:58,代码来源:OIOSAMLAssertionValidator.java


注:本文中的org.opensaml.saml2.core.AuthnContextClassRef.getAuthnContextClassRef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。