本文整理汇总了Java中org.opensaml.saml2.core.SubjectConfirmation类的典型用法代码示例。如果您正苦于以下问题:Java SubjectConfirmation类的具体用法?Java SubjectConfirmation怎么用?Java SubjectConfirmation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubjectConfirmation类属于org.opensaml.saml2.core包,在下文中一共展示了SubjectConfirmation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processChildElement
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
Subject subject = (Subject) parentObject;
if (childObject instanceof BaseID) {
subject.setBaseID((BaseID) childObject);
} else if (childObject instanceof NameID) {
subject.setNameID((NameID) childObject);
} else if (childObject instanceof EncryptedID) {
subject.setEncryptedID((EncryptedID) childObject);
} else if (childObject instanceof SubjectConfirmation) {
subject.getSubjectConfirmations().add((SubjectConfirmation) childObject);
} else {
super.processChildElement(parentObject, childObject);
}
}
示例2: processChildElement
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
SubjectConfirmation subjectConfirmation = (SubjectConfirmation) parentObject;
if (childObject instanceof BaseID) {
subjectConfirmation.setBaseID((BaseID) childObject);
} else if (childObject instanceof NameID) {
subjectConfirmation.setNameID((NameID) childObject);
} else if (childObject instanceof EncryptedID) {
subjectConfirmation.setEncryptedID((EncryptedID) childObject);
} else if (childObject instanceof SubjectConfirmationData) {
subjectConfirmation.setSubjectConfirmationData((SubjectConfirmationData) childObject);
} else {
super.processChildElement(parentObject, childObject);
}
}
示例3: checkRecipient
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
/**
* Check whether an assertion contains an assertionConsumerURL
* within a subjectConfirmationData having the
* subjectConfirmationMethod=urn:oasis:names:tc:SAML:2.0:cm:bearer
*
* @return <code>true</code>, if the assertion contains the
* assertionConsumerURL. <code>false</code>
* otherwise.
*/
public boolean checkRecipient(String assertionConsumerURL) {
if (assertionConsumerURL == null) return false;
if (assertion.getSubject() == null) return false;
if (assertion.getSubject().getSubjectConfirmations() == null) return false;
for (SubjectConfirmation subjectConfirmation : assertion.getSubject().getSubjectConfirmations()) {
if (!OIOSAMLConstants.METHOD_BEARER.equals(subjectConfirmation.getMethod())) continue;
SubjectConfirmationData subjectConfirmationData = subjectConfirmation.getSubjectConfirmationData();
if (subjectConfirmationData == null) continue;
if (assertionConsumerURL.equals(subjectConfirmationData.getRecipient())) {
return true;
}
}
return false;
}
示例4: getSAMLBuilder
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的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;
}
示例5: processAttribute
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
SubjectConfirmation subjectConfirmation = (SubjectConfirmation) samlObject;
if (attribute.getLocalName().equals(SubjectConfirmation.METHOD_ATTRIB_NAME)) {
subjectConfirmation.setMethod(attribute.getValue());
} else {
super.processAttribute(samlObject, attribute);
}
}
示例6: marshallAttributes
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
SubjectConfirmation subjectConfirmation = (SubjectConfirmation) samlObject;
if (subjectConfirmation.getMethod() != null) {
domElement.setAttributeNS(null, SubjectConfirmation.METHOD_ATTRIB_NAME, subjectConfirmation.getMethod());
}
}
示例7: getConfirmationTime
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
public DateTime getConfirmationTime() {
if (assertion.getSubject() == null) return null;
if (assertion.getSubject().getSubjectConfirmations() == null ||
assertion.getSubject().getSubjectConfirmations().isEmpty()) return null;
for (SubjectConfirmation subjectConfirmation : assertion.getSubject().getSubjectConfirmations()) {
SubjectConfirmationData data = subjectConfirmation.getSubjectConfirmationData();
if (data != null && data.getNotOnOrAfter() != null) {
return data.getNotOnOrAfter();
}
}
return null;
}
示例8: createSubject
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
/**
* Create a subject with a given nameID value.
*
* The subject is given a confirmation with method bearer.
*
* @param nameIDValue
* The value of the nameID
* @return The SAML subject with the given nameId
*/
public static Subject createSubject(String nameIDValue,
String recipient, DateTime notOnOrAfter) {
Subject subject = buildXMLObject(Subject.class);
subject.setNameID(createNameID(nameIDValue));
SubjectConfirmation subjectConfirmation = buildXMLObject(SubjectConfirmation.class);
subjectConfirmation.setMethod(OIOSAMLConstants.METHOD_BEARER);
SubjectConfirmationData subjectConfirmationData = buildXMLObject(SubjectConfirmationData.class);
subjectConfirmationData.setRecipient(recipient);
subjectConfirmationData.setNotOnOrAfter(notOnOrAfter);
subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);
subject.getSubjectConfirmations().add(subjectConfirmation);
return subject;
}
示例9: checkRecipient
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
@Test
public void checkRecipient() {
String requiredMethodBearer = "urn:oasis:names:tc:SAML:2.0:cm:bearer";
assertFalse(assertion.checkRecipient(null));
assertFalse(new OIOAssertion(new AssertionStubImpl()).checkRecipient(""));
Assertion localAssertion = new AssertionStubImpl();
localAssertion.setSubject(new SubjectStubImpl());
assertFalse(assertion.checkRecipient(""));
SubjectConfirmation subjectConfirmation = new SubjectConfirmationStubImpl();
subjectConfirmation.setMethod(requiredMethodBearer);
SubjectConfirmationData subConfData = new SubjectConfirmationDataStubImpl();
String expectedRecipient = "recipient";
subConfData.setRecipient(expectedRecipient);
subjectConfirmation.setSubjectConfirmationData(subConfData);
Subject subject = new SubjectStubImpl(Collections.singletonList(subjectConfirmation));
localAssertion.setSubject(subject);
OIOAssertion la = new OIOAssertion(localAssertion);
assertTrue(la.checkRecipient(expectedRecipient));
subConfData.setRecipient("something else");
assertFalse(la.checkRecipient(expectedRecipient));
subjectConfirmation.setMethod("not requiredBearer");
assertFalse(la.checkRecipient(expectedRecipient));
assertTrue(assertion.checkRecipient(assertionConsumerURL));
}
示例10: populateRequiredData
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
protected void populateRequiredData() {
super.populateRequiredData();
Subject subject = (Subject) target;
SubjectConfirmation subjectConfirmation = (SubjectConfirmation) buildXMLObject(new QName(
SAMLConstants.SAML20_NS, SubjectConfirmation.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX));
subject.getSubjectConfirmations().add(subjectConfirmation);
}
示例11: testMethodFailure
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
/**
* Tests Method failure.
*
* @throws ValidationException
*/
public void testMethodFailure() throws ValidationException {
SubjectConfirmation subjectConfirmation = (SubjectConfirmation) target;
subjectConfirmation.setMethod(null);
assertValidationFail("Method was null, should raise a Validation Exception");
subjectConfirmation.setMethod("");
assertValidationFail("Method was empty string, should raise a Validation Exception");
subjectConfirmation.setMethod(" ");
assertValidationFail("Method was white space, should raise a Validation Exception");
}
示例12: testSingleElementUnmarshall
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementUnmarshall() {
SubjectConfirmation subjectConfirmation = (SubjectConfirmation) unmarshallElement(singleElementFile);
String method = subjectConfirmation.getMethod();
assertEquals("Method not as expected", expectedMethod, method);
}
示例13: testSingleElementMarshall
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementMarshall() {
QName qname = new QName(SAMLConstants.SAML20_NS, SubjectConfirmation.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
SubjectConfirmation subjectConfirmation = (SubjectConfirmation) buildXMLObject(qname);
subjectConfirmation.setMethod(expectedMethod);
assertEquals(expectedDOM, subjectConfirmation);
}
示例14: testChildElementsUnmarshall
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsUnmarshall() {
SubjectConfirmation subjectConfirmation = (SubjectConfirmation) unmarshallElement(childElementsFile);
assertNotNull("Identifier elemement not present", subjectConfirmation.getNameID());
assertNotNull("SubjectConfirmationData element not present", subjectConfirmation.getSubjectConfirmationData());
}
示例15: testChildElementsMarshall
import org.opensaml.saml2.core.SubjectConfirmation; //导入依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsMarshall() {
QName qname = new QName(SAMLConstants.SAML20_NS, SubjectConfirmation.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
SubjectConfirmation subjectConfirmation = (SubjectConfirmation) buildXMLObject(qname);
QName nameIDQName = new QName(SAMLConstants.SAML20_NS, NameID.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
subjectConfirmation.setNameID((NameID) buildXMLObject(nameIDQName));
QName subjectConfirmationDataQName = new QName(SAMLConstants.SAML20_NS, SubjectConfirmationData.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
subjectConfirmation.setSubjectConfirmationData((SubjectConfirmationData) buildXMLObject(subjectConfirmationDataQName));
assertEquals(expectedChildElementsDOM, subjectConfirmation);
}