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


Java Assertion.setID方法代码示例

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


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

示例1: prepareResponse

import org.opensaml.saml1.core.Assertion; //导入方法依赖的package包/类
@Override
protected void prepareResponse(final Response response, final Map<String, Object> model) {
    final Authentication authentication = getAssertionFrom(model).getPrimaryAuthentication();
    final DateTime issuedAt = response.getIssueInstant();
    final Service service = getAssertionFrom(model).getService();

    final Object o = authentication.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
    final boolean isRemembered = o == Boolean.TRUE && !getAssertionFrom(model).isFromNewLogin();

    // Build up the SAML assertion containing AuthenticationStatement and AttributeStatement
    final Assertion assertion = newSamlObject(Assertion.class);
    assertion.setID(generateId());
    assertion.setIssueInstant(issuedAt);
    assertion.setIssuer(this.issuer);
    assertion.setConditions(newConditions(issuedAt, service.getId()));
    final AuthenticationStatement authnStatement = newAuthenticationStatement(authentication);
    assertion.getAuthenticationStatements().add(authnStatement);
    final Map<String, Object> attributes = authentication.getPrincipal().getAttributes();
    if (!attributes.isEmpty() || isRemembered) {
        assertion.getAttributeStatements().add(
                newAttributeStatement(newSubject(authentication.getPrincipal().getId()), attributes, isRemembered));
    }
    response.setStatus(newStatus(StatusCode.SUCCESS, null));
    response.getAssertions().add(assertion);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:26,代码来源:Saml10SuccessResponseView.java

示例2: processAttribute

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

    Assertion assertion = (Assertion) samlObject;

    if (Assertion.ID_ATTRIB_NAME.equals(attribute.getLocalName())) {
        assertion.setID(attribute.getValue());
    } else if (Assertion.ISSUER_ATTRIB_NAME.equals(attribute.getLocalName())) {
        assertion.setIssuer(attribute.getValue());
    } else if (Assertion.ISSUEINSTANT_ATTRIB_NAME.equals(attribute.getLocalName())
            && !DatatypeHelper.isEmpty(attribute.getValue())) {
        assertion.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
    } else if (Assertion.MINORVERSION_ATTRIB_NAME.equals(attribute.getLocalName())) {
        if (attribute.getValue().equals("0")) {
            assertion.setVersion(SAMLVersion.VERSION_10);
        } else {
            assertion.setVersion(SAMLVersion.VERSION_11);
        }
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:AssertionUnmarshaller.java

示例3: prepareResponse

import org.opensaml.saml1.core.Assertion; //导入方法依赖的package包/类
@Override
protected void prepareResponse(final Response response, final Map<String, Object> model) {
    final Authentication authentication = getAssertionFrom(model).getChainedAuthentications().get(0);
    final DateTime issuedAt = response.getIssueInstant();
    final Service service = getAssertionFrom(model).getService();

    final Object o = authentication.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME);
    final boolean isRemembered = o == Boolean.TRUE && !getAssertionFrom(model).isFromNewLogin();

    // Build up the SAML assertion containing AuthenticationStatement and AttributeStatement
    final Assertion assertion = newSamlObject(Assertion.class);
    assertion.setID(generateId());
    assertion.setIssueInstant(issuedAt);
    assertion.setIssuer(this.issuer);
    assertion.setConditions(newConditions(issuedAt, service.getId()));
    final AuthenticationStatement authnStatement = newAuthenticationStatement(authentication);
    assertion.getAuthenticationStatements().add(authnStatement);
    final Map<String, Object> attributes = authentication.getPrincipal().getAttributes();
    if (!attributes.isEmpty() || isRemembered) {
        assertion.getAttributeStatements().add(
                newAttributeStatement(newSubject(authentication.getPrincipal().getId()), attributes, isRemembered));
    }
    response.setStatus(newStatus(StatusCode.SUCCESS, null));
    response.getAssertions().add(assertion);
}
 
开发者ID:kevin3061,项目名称:cas-4.0.1,代码行数:26,代码来源:Saml10SuccessResponseView.java

示例4: createSAMLAssertion

import org.opensaml.saml1.core.Assertion; //导入方法依赖的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");
    assertion.setIssuer(host);
    assertion.setIssueInstant(new DateTime());

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

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

    assertion.setConditions(conditions);

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

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

示例5: setupRequiredData

import org.opensaml.saml1.core.Assertion; //导入方法依赖的package包/类
/**
 * Common setup method (populateRequiredData & the first test
 */
private void setupRequiredData() {
    
    Assertion assertion = (Assertion) target;
    assertion.setIssuer("Issuer");
    assertion.setID("ident");
    assertion.setIssueInstant(new DateTime());
    QName name = new QName(SAMLConstants.SAML1_NS, AttributeStatement.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
    assertion.getStatements().add((AttributeStatement)buildXMLObject(name));
    
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:14,代码来源:AssertionSchemaTest.java

示例6: testMissingID

import org.opensaml.saml1.core.Assertion; //导入方法依赖的package包/类
public void testMissingID(){
    Assertion assertion = (Assertion) target;
    assertion.setID("");
    assertValidationFail("ID was empty, should raise a Validation Exception");
    assertion.setID(null);
    assertValidationFail("ID was null, should raise a Validation Exception");
    assertion.setID("  ");
    assertValidationFail("ID was whitespace, should raise a Validation Exception");

}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:11,代码来源:AssertionSchemaTest.java

示例7: populateRequiredData

import org.opensaml.saml1.core.Assertion; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void populateRequiredData() {
    super.populateRequiredData();
    Assertion assertion = (Assertion) target;
    assertion.setIssuer("Issuer");
    assertion.setID("ident");
    assertion.setIssueInstant(new DateTime());
    QName name = new QName(SAMLConstants.SAML1_NS, AttributeStatement.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML1_PREFIX);
    assertion.getStatements().add((AttributeStatement)buildXMLObject(name));
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:11,代码来源:AssertionSpecTest.java

示例8: testSingleElementOptionalAttributesMarshall

import org.opensaml.saml1.core.Assertion; //导入方法依赖的package包/类
/** {@inheritDoc} */

    public void testSingleElementOptionalAttributesMarshall() {
        Assertion assertion = (Assertion) buildXMLObject(qname);

        assertion.setIssueInstant(expectedIssueInstant);
        assertion.setID(expectedID);
        assertion.setIssuer(expectedIssuer);
        assertEquals(expectedOptionalAttributesDOM, assertion);
    }
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:11,代码来源:AssertionTest.java

示例9: testDOMIDResolutionMarshall

import org.opensaml.saml1.core.Assertion; //导入方法依赖的package包/类
public void testDOMIDResolutionMarshall() throws MarshallingException {
    Assertion assertion = (Assertion) buildXMLObject(Assertion.DEFAULT_ELEMENT_NAME);
    assertion.setID(expectedID);
    assertion.getAttributeStatements().add((AttributeStatement) buildXMLObject(AttributeStatement.DEFAULT_ELEMENT_NAME));
    
    marshallerFactory.getMarshaller(assertion).marshall(assertion);
    
    Document document = assertion.getStatements().get(0).getDOM().getOwnerDocument();
    Element idElem = assertion.getDOM();
    
    assertNotNull("DOM ID resolution returned null", document.getElementById(expectedID));
    assertTrue("DOM elements were not equal", idElem.isSameNode(document.getElementById(expectedID)));
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:14,代码来源:AssertionTest.java


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