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


Java AuthnContextBuilder类代码示例

本文整理汇总了Java中org.opensaml.saml2.core.impl.AuthnContextBuilder的典型用法代码示例。如果您正苦于以下问题:Java AuthnContextBuilder类的具体用法?Java AuthnContextBuilder怎么用?Java AuthnContextBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AuthnContextBuilder类属于org.opensaml.saml2.core.impl包,在下文中一共展示了AuthnContextBuilder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAuthnStatement

import org.opensaml.saml2.core.impl.AuthnContextBuilder; //导入依赖的package包/类
private AuthnStatement createAuthnStatement(final DateTime issueDate) {
	// create authcontextclassref object
	AuthnContextClassRefBuilder classRefBuilder = new AuthnContextClassRefBuilder();
	AuthnContextClassRef classRef = classRefBuilder.buildObject();
	classRef.setAuthnContextClassRef("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport");
	
	// create authcontext object
	AuthnContextBuilder authContextBuilder = new AuthnContextBuilder();
	AuthnContext authnContext = authContextBuilder.buildObject();
	authnContext.setAuthnContextClassRef(classRef);
	
	// create authenticationstatement object
	AuthnStatementBuilder authStatementBuilder = new AuthnStatementBuilder();
	AuthnStatement authnStatement = authStatementBuilder.buildObject();
	authnStatement.setAuthnInstant(issueDate);
	authnStatement.setAuthnContext(authnContext);
	
	return authnStatement;
}
 
开发者ID:rackerlabs,项目名称:saml-generator,代码行数:20,代码来源:SamlAssertionProducer.java

示例2: buildSAMLAssertion

import org.opensaml.saml2.core.impl.AuthnContextBuilder; //导入依赖的package包/类
/**
 * Build SAML Assertion object
 *
 * @param pRequestContext
 * @param pNotOnOrAfter
 * @param pRecipient
 * @param pAudienceURI
 * @param pAssertionAttributes
 * @param pSignAssertion
 * @param pDigitalCertificateName
 * @return SAML Assertion Object
 */
private Assertion buildSAMLAssertion(ActionRequestContext pRequestContext
  , DateTime pNotOnOrAfter
  , String pRecipient
  , String pAudienceURI
  , Map<String, String> pAssertionAttributes
  , boolean pSignAssertion
  , String pDigitalCertificateName
) {
  DateTime lCurrentTime = new DateTime();

  Assertion lAssertion = new AssertionBuilder().buildObject();
  lAssertion.setID(ASSERTION_ID_PREFIX + RandomString.getString(40));
  lAssertion.setVersion(SAMLVersion.VERSION_20);
  lAssertion.setIssuer(buildIssuer(pRequestContext.getFoxRequest().getHttpRequest().getRequestURL().toString()));
  lAssertion.setIssueInstant(lCurrentTime);

  Subject lSubject = new SubjectBuilder().buildObject();
  SubjectConfirmation lSubjectConfirmation = new SubjectConfirmationBuilder().buildObject();
  lSubjectConfirmation.setMethod(SubjectConfirmation.METHOD_BEARER);
  SubjectConfirmationData lSubjectConfirmationData = new SubjectConfirmationDataBuilder().buildObject();
  if (!XFUtil.isNull(pRecipient)) {
    lSubjectConfirmationData.setRecipient(pRecipient);
  }
  lSubjectConfirmationData.setNotOnOrAfter(pNotOnOrAfter);
  lSubjectConfirmation.setSubjectConfirmationData(lSubjectConfirmationData);
  lSubject.getSubjectConfirmations().add(lSubjectConfirmation);

  NameIDBuilder lNameIDBuilder = new NameIDBuilder();
  NameID lNameID = lNameIDBuilder.buildObject();
  lNameID.setValue(RandomString.getString(64));
  lNameID.setFormat(NameID.TRANSIENT);
  lSubject.setNameID(lNameID);

  lAssertion.setSubject(lSubject);

  AuthnStatement lAuthnStatement = new AuthnStatementBuilder().buildObject();
  lAuthnStatement.setAuthnInstant(new DateTime());
  AuthnContext lAuthnContext = new AuthnContextBuilder().buildObject();
  AuthnContextClassRef lAuthnContextClassRef = new AuthnContextClassRefBuilder().buildObject();
  lAuthnContextClassRef.setAuthnContextClassRef(AuthnContext.PASSWORD_AUTHN_CTX);
  lAuthnContext.setAuthnContextClassRef(lAuthnContextClassRef);
  lAuthnStatement.setAuthnContext(lAuthnContext);
  lAssertion.getAuthnStatements().add(lAuthnStatement);

  if (pAssertionAttributes != null && pAssertionAttributes.size() > 0) {
    lAssertion.getAttributeStatements().add(buildAttributeStatement(pAssertionAttributes));
  }

  AudienceRestriction lAudienceRestriction = new AudienceRestrictionBuilder().buildObject();
  if (!XFUtil.isNull(pAudienceURI)) {
    Audience lAudience = new AudienceBuilder().buildObject();
    lAudience.setAudienceURI(pAudienceURI);
    lAudienceRestriction.getAudiences().add(lAudience);
  }

  Conditions lConditions = new ConditionsBuilder().buildObject();
  lConditions.setNotBefore(lCurrentTime);
  lConditions.setNotOnOrAfter(pNotOnOrAfter);
  lConditions.getAudienceRestrictions().add(lAudienceRestriction);
  lAssertion.setConditions(lConditions);

  if (pSignAssertion) {
    signSAMLObject(lAssertion, pRequestContext, pDigitalCertificateName);
  }

  return lAssertion;
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:80,代码来源:SAMLResponseCommand.java


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