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


Java Audience类代码示例

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


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

示例1: getSAMLBuilder

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
private static XMLObjectBuilderFactory getSAMLBuilder() throws ConfigurationException {

	if (builderFactory == null) {
	    // OpenSAML 2.3
	    DefaultBootstrap.bootstrap();
	    builderFactory = Configuration.getBuilderFactory();
	    nameIdBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(NameID.DEFAULT_ELEMENT_NAME);
	    confirmationMethodBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(SubjectConfirmationData.DEFAULT_ELEMENT_NAME);
	    subjectConfirmationBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(SubjectConfirmation.DEFAULT_ELEMENT_NAME);
	    subjectBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Subject.DEFAULT_ELEMENT_NAME);
	    attrStatementBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AttributeStatement.DEFAULT_ELEMENT_NAME);
	    audienceRestrictionnBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AudienceRestriction.DEFAULT_ELEMENT_NAME);
	    audienceBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Audience.DEFAULT_ELEMENT_NAME);
	    authStatementBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnStatement.DEFAULT_ELEMENT_NAME);
	    authContextBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnContext.DEFAULT_ELEMENT_NAME);
	    authContextClassRefBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
	    issuerBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Issuer.DEFAULT_ELEMENT_NAME);
	    assertionBuilder = (SAMLObjectBuilder) getSAMLBuilder().getBuilder(Assertion.DEFAULT_ELEMENT_NAME);

	}

	return builderFactory;
    }
 
开发者ID:mwdb,项目名称:OA2C,代码行数:24,代码来源:LocalSamlTokenFactory.java

示例2: processChildElement

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
    AudienceRestriction audienceRestriction = (AudienceRestriction) parentObject;

    if (childObject instanceof Audience) {
        audienceRestriction.getAudiences().add((Audience) childObject);
    } else {
        super.processChildElement(parentObject, childObject);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:AudienceRestrictionUnmarshaller.java

示例3: processChildElement

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
    ProxyRestriction proxyRestriction = (ProxyRestriction) parentObject;

    if (childObject instanceof Audience) {
        proxyRestriction.getAudiences().add((Audience) childObject);
    } else {
        super.processChildElement(parentObject, childObject);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:ProxyRestrictionUnmarshaller.java

示例4: validateAudienceRestriction

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
/**
 * Validate the AudienceRestriction of SAML2 Response
 *
 * @param assertion SAML2 Assertion
 * @return validity
 */
protected void validateAudienceRestriction(Assertion assertion) throws SSOAgentException {

    if (assertion != null) {
        Conditions conditions = assertion.getConditions();
        if (conditions != null) {
            List<AudienceRestriction> audienceRestrictions = conditions.getAudienceRestrictions();
            if (audienceRestrictions != null && !audienceRestrictions.isEmpty()) {
                boolean audienceFound = false;
                for (AudienceRestriction audienceRestriction : audienceRestrictions) {
                    if (audienceRestriction.getAudiences() != null && !audienceRestriction.getAudiences().isEmpty()
                            ) {
                        for (Audience audience : audienceRestriction.getAudiences()) {
                            if (ssoAgentConfig.getSAML2().getSPEntityId().equals(audience.getAudienceURI())) {
                                audienceFound = true;
                                break;
                            }
                        }
                    }
                    if (audienceFound) {
                        break;
                    }
                }
                if (!audienceFound) {
                    throw new SSOAgentException("SAML2 Assertion Audience Restriction validation failed");
                }
            } else {
                throw new SSOAgentException("SAML2 Response doesn't contain AudienceRestrictions");
            }
        } else {
            throw new SSOAgentException("SAML2 Response doesn't contain Conditions");
        }
    }
}
 
开发者ID:wso2-extensions,项目名称:identity-agent-sso,代码行数:40,代码来源:SAML2SSOManager.java

示例5: getAudience

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
public Collection<String> getAudience() {
	List<String> audiences = new ArrayList<String>();
	
	if (assertion.getConditions() == null) return audiences;
	
	for (AudienceRestriction audienceRestriction : assertion.getConditions().getAudienceRestrictions()) {
		for (Audience audience : audienceRestriction.getAudiences()) {
			audiences.add(audience.getAudienceURI());
		}
	}
	
	return audiences;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:14,代码来源:OIOAssertion.java

示例6: createAudienceCondition

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
/**
 * Create SAML Conditions with an audience element.
 * 
 * @param audienceURI
 *            The value of the audience element
 * @return The SAML Conditions with the given audience element
 */
public static Conditions createAudienceCondition(String audienceURI) {
	Audience audience = buildXMLObject(Audience.class);
	audience.setAudienceURI(audienceURI);
	AudienceRestriction audienceRestriction = buildXMLObject(AudienceRestriction.class);
	audienceRestriction.getAudiences().add(audience);
	Conditions conditions = buildXMLObject(Conditions.class);
	conditions.getAudienceRestrictions().add(audienceRestriction);
	return conditions;
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:17,代码来源:SAMLUtil.java

示例7: testCreateAudienceCondition

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
@Test
public void testCreateAudienceCondition() {
	Conditions ac = SAMLUtil.createAudienceCondition("uri");
	assertNotNull(ac);
	assertEquals(1, ac.getConditions().size());
	assertNull(ac.getNotBefore());
	assertNull(ac.getNotOnOrAfter());
	assertNull(ac.getProxyRestriction());
	assertNull(ac.getOneTimeUse());
	
	AudienceRestriction ar = ac.getAudienceRestrictions().get(0);
	assertEquals(1, ar.getAudiences().size());
	Audience audience = ar.getAudiences().get(0);
	assertEquals("uri", audience.getAudienceURI());
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:16,代码来源:SAMLUtilTest.java

示例8: validateAudienceRestriction

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
/**
 * Validate the AudienceRestriction of SAML2 Response
 *
 * @param assertion SAML2 Assertion
 * @return validity
 */
private void validateAudienceRestriction(Assertion assertion) throws SAMLSSOException {

    if (assertion != null) {
        Conditions conditions = assertion.getConditions();
        if (conditions != null) {
            List<AudienceRestriction> audienceRestrictions = conditions.getAudienceRestrictions();
            if (audienceRestrictions != null && !audienceRestrictions.isEmpty()) {
                for (AudienceRestriction audienceRestriction : audienceRestrictions) {
                    if (CollectionUtils.isNotEmpty(audienceRestriction.getAudiences())) {
                        boolean audienceFound = false;
                        for (Audience audience : audienceRestriction.getAudiences()) {
                            if (properties.get(IdentityApplicationConstants.Authenticator.SAML2SSO.SP_ENTITY_ID)
                                    .equals(audience.getAudienceURI())) {
                                audienceFound = true;
                                break;
                            }
                        }
                        if (!audienceFound) {
                            throw new SAMLSSOException("SAML Assertion Audience Restriction validation failed");
                        }
                    } else {
                        throw new SAMLSSOException("SAML Response's AudienceRestriction doesn't contain Audiences");
                    }
                }
            } else {
                throw new SAMLSSOException("SAML Response doesn't contain AudienceRestrictions");
            }
        } else {
            throw new SAMLSSOException("SAML Response doesn't contain Conditions");
        }
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:39,代码来源:DefaultSAML2SSOManager.java

示例9: validateAudienceRestrictionInAssertion

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
/**
 * Validate the AudienceRestriction of SAML2 Assertion
 *
 * @param assertion SAML2 Assertion
 * @return validity
 */
public boolean validateAudienceRestrictionInAssertion(Assertion assertion) {
    if (assertion != null) {
        Conditions conditions = assertion.getConditions();
        if (conditions != null) {
            List<AudienceRestriction> audienceRestrictions = conditions.getAudienceRestrictions();
            if (audienceRestrictions != null && !audienceRestrictions.isEmpty()) {
                for (AudienceRestriction audienceRestriction : audienceRestrictions) {
                    if (audienceRestriction.getAudiences() != null && audienceRestriction.getAudiences().size() > 0) {
                        for (Audience audience : audienceRestriction.getAudiences()) {
                            String spId = org.wso2.carbon.identity.authenticator.saml2.sso.common.Util.getServiceProviderId();
                            if (spId == null) {
                                org.wso2.carbon.identity.authenticator.saml2.sso.common.Util.initSSOConfigParams();
                                spId = org.wso2.carbon.identity.authenticator.saml2.sso.common.Util.getServiceProviderId();
                            }
                            if (spId != null) {
                                if (spId.equals(audience.getAudienceURI())) {
                                    return true;
                                }
                            } else {
                                log.warn("No SAML2 service provider ID defined.");
                            }
                        }
                    } else {
                        log.warn("SAML2 Response's AudienceRestriction doesn't contain Audiences");
                    }
                }
            } else {
                log.error("SAML2 Response doesn't contain AudienceRestrictions");
            }
        } else {
            log.error("SAML2 Response doesn't contain Conditions");
        }
    }
    return false;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:42,代码来源:SAML2SSOAuthenticator.java

示例10: testURIFailure

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
/**
 * Tests absent URI failure.
 * 
 * @throws ValidationException
 */
public void testURIFailure() throws ValidationException {
    Audience audience = (Audience) target;

    audience.setAudienceURI(null);
    assertValidationFail("URI was null, should raise a Validation Exception");

    audience.setAudienceURI("");
    assertValidationFail("URI was empty string, should raise a Validation Exception");
    
    audience.setAudienceURI("    ");
    assertValidationFail("URI was white space, should raise a Validation Exception");
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:18,代码来源:AudienceSchemaTest.java

示例11: populateRequiredData

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
protected void populateRequiredData() {
    super.populateRequiredData();
    AudienceRestriction audienceRestriction = (AudienceRestriction) target;
    Audience audience = (Audience) buildXMLObject(new QName(SAMLConstants.SAML20_NS, Audience.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLConstants.SAML20_PREFIX));
    audienceRestriction.getAudiences().add(audience);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:8,代码来源:AudienceRestrictionSchemaTest.java

示例12: testChildElementsMarshall

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsMarshall() {
    QName qname = new QName(SAMLConstants.SAML20_NS, ProxyRestriction.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    ProxyRestriction proxyRestriction = (ProxyRestriction) buildXMLObject(qname);

    QName audienceQName = new QName(SAMLConstants.SAML20_NS, Audience.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    for (int i = 0; i < expectedAudienceCount; i++) {
        proxyRestriction.getAudiences().add((Audience) buildXMLObject(audienceQName));
    }

    assertEquals(expectedChildElementsDOM, proxyRestriction);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:13,代码来源:ProxyRestrictionTest.java

示例13: testSingleElementUnmarshall

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementUnmarshall() {
    Audience audience = (Audience) unmarshallElement(singleElementFile);

    String audienceURI = audience.getAudienceURI();
    assertEquals("AssertionURI was " + audienceURI + ", expected " + expectedAudienceURI, expectedAudienceURI,
            audienceURI);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:9,代码来源:AudienceTest.java

示例14: testSingleElementMarshall

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

    audience.setAudienceURI(expectedAudienceURI);
    assertEquals(expectedDOM, audience);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:9,代码来源:AudienceTest.java

示例15: testChildElementsMarshall

import org.opensaml.saml2.core.Audience; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsMarshall() {
    QName qname = new QName(SAMLConstants.SAML20_NS, AudienceRestriction.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    AudienceRestriction audienceRestriction = (AudienceRestriction) buildXMLObject(qname);

    QName audienceQName = new QName(SAMLConstants.SAML20_NS, Audience.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
    for (int i = 0; i < expectedAudienceCount; i++) {
        audienceRestriction.getAudiences().add((Audience) buildXMLObject(audienceQName));
    }

    assertEquals(expectedChildElementsDOM, audienceRestriction);
}
 
开发者ID:apigee,项目名称:java-opensaml2,代码行数:13,代码来源:AudienceRestrictionTest.java


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