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


Java Conditions.setNotBefore方法代码示例

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


在下文中一共展示了Conditions.setNotBefore方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processAttribute

import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    Conditions conditions = (Conditions) samlObject;

    if (attribute.getLocalName().equals(Conditions.NOT_BEFORE_ATTRIB_NAME)
            && !DatatypeHelper.isEmpty(attribute.getValue())) {
        conditions.setNotBefore(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
    } else if (attribute.getLocalName().equals(Conditions.NOT_ON_OR_AFTER_ATTRIB_NAME)
            && !DatatypeHelper.isEmpty(attribute.getValue())) {
        conditions.setNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:ConditionsUnmarshaller.java

示例2: testSingleElementMarshall

import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementMarshall() {
    QName qname = new QName(SAMLConstants.SAML20_NS, Conditions.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    Conditions conditions = (Conditions) buildXMLObject(qname);

    conditions.setNotBefore(expectedNotBefore);
    assertEquals(expectedDOM, conditions);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:9,代码来源:ConditionsTest.java

示例3: testSingleElementOptionalAttributesMarshall

import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesMarshall() {
    QName qname = new QName(SAMLConstants.SAML20_NS, Conditions.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    Conditions conditions = (Conditions) buildXMLObject(qname);

    conditions.setNotBefore(expectedNotBefore);
    conditions.setNotOnOrAfter(expectedNotOnOrAfter);

    assertEquals(expectedOptionalAttributesDOM, conditions);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:11,代码来源:ConditionsTest.java

示例4: buildConditions

import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
private Conditions buildConditions() throws IllegalAccessException {
	Conditions conditions = buildXMLObjectDefaultName(Conditions.class);
	conditions.setNotBefore(new DateTime().minusDays(2));
	conditions.setNotOnOrAfter(new DateTime().plusDays(2));
	AudienceRestriction audienceRestriction = buildXMLObjectDefaultName(AudienceRestriction.class);
	Audience audience = buildXMLObjectDefaultName(Audience.class);
	audience.setAudienceURI(MockIDPSPMetadata.getAudienceUri());
	audienceRestriction.getAudiences().add(audience);
	conditions.getAudienceRestrictions().add(audienceRestriction);
	return conditions;
}
 
开发者ID:rasmusson,项目名称:MockIDP,代码行数:12,代码来源:MockIDPArtifactResolve.java

示例5: createCondition

import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
private static Conditions createCondition() {
	Conditions conditions = null;
	AudienceRestriction audienceRestriction = null;
	if (samlResponseData.getAudience() != null
			&& samlResponseData.getAudience().length() > 0) {
		Audience audience = create(Audience.DEFAULT_ELEMENT_NAME);

		if (SamlResponseData.REPLACE_WITH_AUTHN_REQUEST
				.equals(samlResponseData.getAudience())) {
			audience.setAudienceURI(authnRequest.getIssuer().getValue());
		} else {
			audience.setAudienceURI(samlResponseData.getAudience());
		}

		audienceRestriction = create(AudienceRestriction.DEFAULT_ELEMENT_NAME);
		audienceRestriction.getAudiences().add(audience);
	}

	if (samlResponseData.getConditionNotBefore() != null
			|| samlResponseData.getConditionNotOnOrAfter() != null
			|| audienceRestriction != null) {
		conditions = create(Conditions.DEFAULT_ELEMENT_NAME);
		if (samlResponseData.getConditionNotBefore() != null)
			conditions.setNotBefore(startTime.plusMinutes(samlResponseData
					.getConditionNotBefore()));
		if (samlResponseData.getConditionNotOnOrAfter() != null)
			conditions.setNotOnOrAfter(startTime
					.plusMinutes(samlResponseData
							.getConditionNotOnOrAfter()));
		conditions.getAudienceRestrictions().add(audienceRestriction);
	}

	return conditions;
}
 
开发者ID:vetsin,项目名称:SamlSnort,代码行数:35,代码来源:SamlTool.java

示例6: buildSAMLAssertion

import org.opensaml.saml2.core.Conditions; //导入方法依赖的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

示例7: buildSAMLAssertion

import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
private Assertion buildSAMLAssertion(final String emailAddress)
{
    // Bootstrap the OpenSAML library
    try {
        DefaultBootstrap.bootstrap();
    } catch (ConfigurationException e) {
    }

    DateTime issueInstant = new DateTime();
    DateTime notOnOrAfter = issueInstant.plusMinutes(15);
    DateTime notBefore    = issueInstant.minusMinutes(5);
    
    NameID nameID = (new NameIDBuilder().buildObject());
    nameID.setFormat(NameIDType.EMAIL);
    nameID.setValue(emailAddress);
    
    SubjectConfirmationData subjectConfirmationData = (new SubjectConfirmationDataBuilder().buildObject());
    subjectConfirmationData.setRecipient(applicationLink.getRpcUrl().toString() + ACCESS_TOKEN_URL);
    subjectConfirmationData.setNotOnOrAfter(notOnOrAfter);
    
    SubjectConfirmation subjectConfirmation = (new SubjectConfirmationBuilder().buildObject());
    subjectConfirmation.setMethod(SubjectConfirmation.METHOD_BEARER);
    subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);

    Subject subject = (new SubjectBuilder().buildObject());
    subject.setNameID(nameID);
    subject.getSubjectConfirmations().add(subjectConfirmation);
    
    Issuer issuer = (new IssuerBuilder().buildObject());
    issuer.setValue(providerID);
    
    Audience audience = (new AudienceBuilder().buildObject());
    audience.setAudienceURI(AUDIENCE_RESTRICTION);
    
    AudienceRestriction audienceRestriction = (new AudienceRestrictionBuilder().buildObject());
    audienceRestriction.getAudiences().add(audience);
    
    Conditions conditions = (new ConditionsBuilder().buildObject());
    conditions.setNotBefore(notBefore);
    conditions.setNotOnOrAfter(notOnOrAfter);
    conditions.getAudienceRestrictions().add(audienceRestriction);
    
    XSString attributeValue = (XSString)Configuration.getBuilderFactory().getBuilder(XSString.TYPE_NAME).buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
    attributeValue.setValue(clientID);

    Attribute attribute = (new AttributeBuilder().buildObject());
    attribute.setName("client_id");
    attribute.getAttributeValues().add(attributeValue);

    AttributeStatement attributeStatement = (new AttributeStatementBuilder().buildObject());
    attributeStatement.getAttributes().add(attribute);

    Assertion assertion = (new AssertionBuilder().buildObject());
    assertion.setID(UUID.randomUUID().toString());
    assertion.setVersion(SAMLVersion.VERSION_20);
    assertion.setIssueInstant(issueInstant);
    assertion.setIssuer(issuer);
    assertion.setSubject(subject);
    assertion.setConditions(conditions);
    assertion.getAttributeStatements().add(attributeStatement);

    return assertion;
}
 
开发者ID:SAP,项目名称:SAPJamWorkPatternJIRAIntegration,代码行数:64,代码来源:JamConsumer.java

示例8: buildSAML2Assertion

import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
private static Assertion buildSAML2Assertion(boolean includeClientKeyAttribute)
{
    // Bootstrap the OpenSAML library
    try {
        DefaultBootstrap.bootstrap();
    } catch (ConfigurationException e) {
    }

    DateTime issueInstant = new DateTime();
    DateTime notOnOrAfter = issueInstant.plusMinutes(10);
    DateTime notBefore = issueInstant.minusMinutes(10);
    
    NameID nameID = (new NameIDBuilder().buildObject());
    if (SUBJECT_NAME_ID_FORMAT.equals("email")) {
        nameID.setFormat(NameIDType.EMAIL);
    } else if (SUBJECT_NAME_ID_FORMAT.equals("unspecified")) {
        nameID.setFormat(NameIDType.UNSPECIFIED);
    } else {
        throw new IllegalArgumentException("SUBJECT_NAME_ID_FORMAT must be 'email' or 'unspecified'.");
    }
    if (subjectNameIdQualifier != null) {
        nameID.setNameQualifier(subjectNameIdQualifier);
    }
    nameID.setValue(SUBJECT_NAME_ID);
    
    SubjectConfirmationData subjectConfirmationData = (new SubjectConfirmationDataBuilder().buildObject());
    subjectConfirmationData.setRecipient(BASE_URL + ACCESS_TOKEN_URL_PATH);
    subjectConfirmationData.setNotOnOrAfter(notOnOrAfter);
    
    SubjectConfirmation subjectConfirmation = (new SubjectConfirmationBuilder().buildObject());
    subjectConfirmation.setMethod(SubjectConfirmation.METHOD_BEARER);
    subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);

    Subject subject = (new SubjectBuilder().buildObject());
    subject.setNameID(nameID);
    subject.getSubjectConfirmations().add(subjectConfirmation);
    
    Issuer issuer = (new IssuerBuilder().buildObject());
    issuer.setValue(IDP_ID);
    
    Audience audience = (new AudienceBuilder().buildObject());
    audience.setAudienceURI(SP_ID_JAM);
    
    AudienceRestriction audienceRestriction = (new AudienceRestrictionBuilder().buildObject());
    audienceRestriction.getAudiences().add(audience);
    
    Conditions conditions = (new ConditionsBuilder().buildObject());
    conditions.setNotBefore(notBefore);
    conditions.setNotOnOrAfter(notOnOrAfter);
    conditions.getAudienceRestrictions().add(audienceRestriction);
   
    Assertion assertion = (new AssertionBuilder().buildObject());
    assertion.setID(UUID.randomUUID().toString());
    assertion.setVersion(SAMLVersion.VERSION_20);
    assertion.setIssueInstant(issueInstant);
    assertion.setIssuer(issuer);
    assertion.setSubject(subject);
    assertion.setConditions(conditions);
    
    if (includeClientKeyAttribute) {
        XSString attributeValue = (XSString)Configuration.getBuilderFactory().getBuilder(XSString.TYPE_NAME).buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
        attributeValue.setValue(CLIENT_KEY);

        Attribute attribute = (new AttributeBuilder().buildObject());
        attribute.setName("client_id");
        attribute.getAttributeValues().add(attributeValue);

        AttributeStatement attributeStatement = (new AttributeStatementBuilder().buildObject());
        attributeStatement.getAttributes().add(attribute);
        assertion.getAttributeStatements().add(attributeStatement);
    }

    return assertion;
}
 
开发者ID:SAP,项目名称:SAPJamSampleCode,代码行数:75,代码来源:OAuth2SAMLWorkflowSample.java

示例9: buildSAML2Assertion

import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
private static Assertion buildSAML2Assertion(
        String baseUrl,
        String subjectNameId,
        String subjectNameIdFormat,
        String subjectNameIdQualifier,
        String idpId,
        String clientKey,
        boolean includeClientKeyAttribute)
{
    // Bootstrap the OpenSAML library
    try {
        DefaultBootstrap.bootstrap();
    } catch (ConfigurationException e) {
    }

    DateTime issueInstant = new DateTime();
    DateTime notOnOrAfter = issueInstant.plusMinutes(10);
    DateTime notBefore = issueInstant.minusMinutes(10);
    
    NameID nameID = (new NameIDBuilder().buildObject());
    if (subjectNameIdFormat.equals("email")) {
        nameID.setFormat(NameIDType.EMAIL);
    } else if (subjectNameIdFormat.equals("unspecified")) {
        nameID.setFormat(NameIDType.UNSPECIFIED);
    } else {
        throw new IllegalArgumentException("subjectNameIdFormat must be 'email' or 'unspecified'.");
    }
    if (subjectNameIdQualifier != null) {
        nameID.setNameQualifier(subjectNameIdQualifier);
    }
    nameID.setValue(subjectNameId);
    
    SubjectConfirmationData subjectConfirmationData = (new SubjectConfirmationDataBuilder().buildObject());
    subjectConfirmationData.setRecipient(baseUrl + ACCESS_TOKEN_URL_PATH);
    subjectConfirmationData.setNotOnOrAfter(notOnOrAfter);
    
    SubjectConfirmation subjectConfirmation = (new SubjectConfirmationBuilder().buildObject());
    subjectConfirmation.setMethod(SubjectConfirmation.METHOD_BEARER);
    subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);

    Subject subject = (new SubjectBuilder().buildObject());
    subject.setNameID(nameID);
    subject.getSubjectConfirmations().add(subjectConfirmation);
    
    Issuer issuer = (new IssuerBuilder().buildObject());
    issuer.setValue(idpId);
    
    Audience audience = (new AudienceBuilder().buildObject());
    audience.setAudienceURI(SP_ID_JAM);
    
    AudienceRestriction audienceRestriction = (new AudienceRestrictionBuilder().buildObject());
    audienceRestriction.getAudiences().add(audience);
    
    Conditions conditions = (new ConditionsBuilder().buildObject());
    conditions.setNotBefore(notBefore);
    conditions.setNotOnOrAfter(notOnOrAfter);
    conditions.getAudienceRestrictions().add(audienceRestriction);
   
    Assertion assertion = (new AssertionBuilder().buildObject());
    assertion.setID(UUID.randomUUID().toString());
    assertion.setVersion(SAMLVersion.VERSION_20);
    assertion.setIssueInstant(issueInstant);
    assertion.setIssuer(issuer);
    assertion.setSubject(subject);
    assertion.setConditions(conditions);
    
    if (includeClientKeyAttribute) {
        XSString attributeValue = (XSString)Configuration.getBuilderFactory().getBuilder(XSString.TYPE_NAME).buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
        attributeValue.setValue(clientKey);

        Attribute attribute = (new AttributeBuilder().buildObject());
        attribute.setName("client_id");
        attribute.getAttributeValues().add(attributeValue);

        AttributeStatement attributeStatement = (new AttributeStatementBuilder().buildObject());
        attributeStatement.getAttributes().add(attribute);
        assertion.getAttributeStatements().add(attributeStatement);
    }

    return assertion;
}
 
开发者ID:SAP,项目名称:SAPJamSampleCode,代码行数:82,代码来源:OAuth2SAMLWorkflowSample.java

示例10: buildSignedSAML2Assertion

import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
public static String buildSignedSAML2Assertion(
    final String idpId,
    final String destinationUri,
    
    final String subjectNameId,
    final String subjectNameIdFormat,
    final String subjectNameIdQualifier,

    final PrivateKey idpPrivateKey,
    final X509Certificate idpCertificate,
    final String spJamId,
    final Map<String, List<Object>> attributes) throws Exception {
            
    // Bootstrap the OpenSAML library
    try {
        DefaultBootstrap.bootstrap();
    } catch (ConfigurationException e) {
        
    }

    DateTime issueInstant = new DateTime();
    DateTime notOnOrAfter = issueInstant.plusMinutes(10);
    DateTime notBefore = issueInstant.minusMinutes(10);
    
    NameID nameID = makeEmailFormatName(subjectNameId, subjectNameIdFormat, subjectNameIdQualifier);
    
    SubjectConfirmationData subjectConfirmationData = (new SubjectConfirmationDataBuilder().buildObject());
    subjectConfirmationData.setRecipient(destinationUri);
    subjectConfirmationData.setNotOnOrAfter(notOnOrAfter);
    
    SubjectConfirmation subjectConfirmation = (new SubjectConfirmationBuilder().buildObject());
    subjectConfirmation.setMethod(SubjectConfirmation.METHOD_BEARER);
    subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);

    Subject subject = (new SubjectBuilder().buildObject());
    subject.setNameID(nameID);
    subject.getSubjectConfirmations().add(subjectConfirmation);
    
    Issuer issuer = (new IssuerBuilder().buildObject());
    issuer.setValue(idpId);
    
    Audience audience = (new AudienceBuilder().buildObject());
    audience.setAudienceURI(spJamId);
    
    AudienceRestriction audienceRestriction = (new AudienceRestrictionBuilder().buildObject());
    audienceRestriction.getAudiences().add(audience);
    
    Conditions conditions = (new ConditionsBuilder().buildObject());
    conditions.setNotBefore(notBefore);
    conditions.setNotOnOrAfter(notOnOrAfter);
    conditions.getAudienceRestrictions().add(audienceRestriction);
   
    Assertion assertion = (new AssertionBuilder().buildObject());
    assertion.setID(UUID.randomUUID().toString());
    assertion.setVersion(SAMLVersion.VERSION_20);
    assertion.setIssueInstant(issueInstant);
    assertion.setIssuer(issuer);
    assertion.setSubject(subject);
    assertion.setConditions(conditions);

    return signAssertion(assertion, idpPrivateKey);
}
 
开发者ID:SAP,项目名称:SAPJamSampleCode,代码行数:63,代码来源:OAuth2SAMLUtil.java

示例11: createSAMLAssertion

import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
@Override
public void createSAMLAssertion(DateTime notAfter, DateTime notBefore, String assertionId)
        throws IdentityProviderException {
    assertion = (Assertion) buildXMLObject(Assertion.DEFAULT_ELEMENT_NAME);
    Conditions conditions = (Conditions) buildXMLObject(Conditions.DEFAULT_ELEMENT_NAME);
    conditions.setNotBefore(notBefore);
    conditions.setNotOnOrAfter(notAfter);

    ServerConfiguration config = ServerConfiguration.getInstance();
    String host = "http://" + config.getFirstProperty("HostName");

    Issuer issuer = (Issuer) buildXMLObject(Issuer.DEFAULT_ELEMENT_NAME);
    issuer.setValue(host);
    assertion.setIssuer(issuer);
    assertion.setIssueInstant(new DateTime());

    if (appilesTo != null) {
        Audience audience = (Audience) buildXMLObject(Audience.DEFAULT_ELEMENT_NAME);
        audience.setAudienceURI(appilesTo);
        AudienceRestriction audienceRestrictions =
                (AudienceRestriction) buildXMLObject(AudienceRestriction.DEFAULT_ELEMENT_NAME);
        audienceRestrictions.getAudiences().add(audience);

        conditions.getAudienceRestrictions().add(audienceRestrictions);
    }

    assertion.setConditions(conditions);

    assertion.getAttributeStatements().add(this.attributeStmt);
    assertion.setID(assertionId);

    Subject subject = (Subject) buildXMLObject(Subject.DEFAULT_ELEMENT_NAME);
    SubjectConfirmation subjectConf =
            (SubjectConfirmation) buildXMLObject(SubjectConfirmation.DEFAULT_ELEMENT_NAME);
    SubjectConfirmationData confData =
            (SubjectConfirmationData) buildXMLObject(SubjectConfirmationData.DEFAULT_ELEMENT_NAME);
    confData.setAddress(CONF_KEY);
    subjectConf.setSubjectConfirmationData(confData);
    subject.getSubjectConfirmations().add(subjectConf);
    assertion.setSubject(subject);

}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:43,代码来源:SAML2TokenBuilder.java

示例12: buildAuthnRequest

import org.opensaml.saml2.core.Conditions; //导入方法依赖的package包/类
/**
 * Build a SAML2 authentication request.
 * 
 * @param requestId
 *            the request Id
 * @return the authentication request
 */
protected AuthnRequest buildAuthnRequest(final SamlBindingEnum binding) {
	final Issuer issuer = this.buildIssuer();

	// Create NameIDPolicy
	final NameIDPolicyBuilder nameIdPolicyBuilder = new NameIDPolicyBuilder();
	final NameIDPolicy nameIdPolicy = nameIdPolicyBuilder.buildObject();
	nameIdPolicy.setFormat("urn:oasis:names:tc:SAML:2.0:nameid-format:transient");
	nameIdPolicy.setAllowCreate(false);

	// Create AuthnContextClassRef
	final AuthnContextClassRef authnContextClassRef = this.authnContextClassRefBuilder
			.buildObject(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
	authnContextClassRef
			.setAuthnContextClassRef("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport");

	// Create RequestedAuthnContext
	final RequestedAuthnContext requestedAuthnContext = this.requestedAuthnContextBuilder
			.buildObject(RequestedAuthnContext.DEFAULT_ELEMENT_NAME);
	requestedAuthnContext.setComparison(AuthnContextComparisonTypeEnumeration.EXACT);
	requestedAuthnContext.getAuthnContextClassRefs().add(authnContextClassRef);

	final DateTime issueInstant = new DateTime();
	final AuthnRequest authnRequest = this.authRequestBuilder.buildObject(AuthnRequest.DEFAULT_ELEMENT_NAME);

	// Force IdP authentication.
	authnRequest.setForceAuthn(this.idpConfig.isForceAuthentication());
	authnRequest.setIsPassive(false);
	authnRequest.setIssueInstant(issueInstant);

	final SamlBindingEnum responseBinding = this.idpConfig.getResponseBinding();
	authnRequest.setProtocolBinding(responseBinding.getUri());
	final ISpConfig spConfig = this.getSaml20SpProcessor().getSpConfig();
	authnRequest.setAssertionConsumerServiceURL(spConfig.getEndpointUrl(responseBinding));

	authnRequest.setIssuer(issuer);
	authnRequest.setNameIDPolicy(nameIdPolicy);
	// authnRequest.setRequestedAuthnContext(requestedAuthnContext);
	// authnRequest.setProviderName(this.spConfig.getEntityId());
	authnRequest.setDestination(this.idpConfig.getIdpSsoEndpointUrl(binding));
	authnRequest.setVersion(SAMLVersion.VERSION_20);

	// Select the Attributes to be returned
	if (this.idpConfig.getAttributeConsumingServiceIndex() != null) {
		authnRequest.setAttributeConsumingServiceIndex(this.idpConfig.getAttributeConsumingServiceIndex());
	}

	// Subject subject = this.subjectBuilder.buildObject();
	// authnRequest.setSubject(subject);

	// Time validity window : + or - XX ms
	final Conditions conditions = this.conditionsBuilder.buildObject();
	conditions.setNotBefore(this.buildNotBeforeTime(issueInstant));
	conditions.setNotOnOrAfter(this.buildNotOnOrAfterTime(issueInstant));
	authnRequest.setConditions(conditions);

	this.getSaml20SpProcessor().signSamlObject(authnRequest);

	return authnRequest;
}
 
开发者ID:mxbossard,项目名称:java-saml2-sp,代码行数:67,代码来源:OpenSaml20IdpConnector.java


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