本文整理汇总了Java中org.opensaml.saml2.core.SubjectConfirmationData类的典型用法代码示例。如果您正苦于以下问题:Java SubjectConfirmationData类的具体用法?Java SubjectConfirmationData怎么用?Java SubjectConfirmationData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubjectConfirmationData类属于org.opensaml.saml2.core包,在下文中一共展示了SubjectConfirmationData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processChildElement
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的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);
}
}
示例2: processAttribute
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
SubjectConfirmationData subjectCD = (SubjectConfirmationData) samlObject;
if (attribute.getLocalName().equals(SubjectConfirmationData.NOT_BEFORE_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
subjectCD.setNotBefore(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(SubjectConfirmationData.NOT_ON_OR_AFTER_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
subjectCD.setNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(SubjectConfirmationData.RECIPIENT_ATTRIB_NAME)) {
subjectCD.setRecipient(attribute.getValue());
} else if (attribute.getLocalName().equals(SubjectConfirmationData.IN_RESPONSE_TO_ATTRIB_NAME)) {
subjectCD.setInResponseTo(attribute.getValue());
} else if (attribute.getLocalName().equals(SubjectConfirmationData.ADDRESS_ATTRIB_NAME)) {
subjectCD.setAddress(attribute.getValue());
} else {
QName attribQName = XMLHelper.getNodeQName(attribute);
if (attribute.isId()) {
subjectCD.getUnknownAttributes().registerID(attribQName);
}
subjectCD.getUnknownAttributes().put(attribQName, attribute.getValue());
}
}
示例3: checkRecipient
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的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: testSingleElementOptionalAttributesUnmarshall
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesUnmarshall() {
SubjectConfirmationData subjectCD = (SubjectConfirmationData) unmarshallElement(singleElementOptionalAttributesFile);
DateTime notBefore = subjectCD.getNotBefore();
assertEquals("NotBefore was " + notBefore + ", expected " + expectedNotBefore, expectedNotBefore, notBefore);
DateTime notOnOrAfter = subjectCD.getNotOnOrAfter();
assertEquals("NotOnOrAfter was " + notOnOrAfter + ", expected " + expectedNotOnOrAfter, expectedNotOnOrAfter,
notOnOrAfter);
String recipient = subjectCD.getRecipient();
assertEquals("Recipient was " + recipient + ", expected " + expectedRecipient, expectedRecipient, recipient);
String inResponseTo = subjectCD.getInResponseTo();
assertEquals("InResponseTo was " + inResponseTo + ", expected " + expectedInResponseTo, expectedInResponseTo,
inResponseTo);
String address = subjectCD.getAddress();
assertEquals("Address was " + address + ", expected " + expectedAddress, expectedAddress, address);
}
示例5: getSAMLBuilder
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的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;
}
示例6: processChildElement
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
SubjectConfirmation sc = (SubjectConfirmation) parentObject;
if (childObject instanceof SubjectConfirmationData) {
sc.setSubjectConfirmationData((SubjectConfirmationData) childObject);
} else {
super.processChildElement(parentObject, childObject);
}
}
示例7: marshallAttributes
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
SubjectConfirmationData subjectCD = (SubjectConfirmationData) samlObject;
if (subjectCD.getNotBefore() != null) {
String notBeforeStr = Configuration.getSAMLDateFormatter().print(subjectCD.getNotBefore());
domElement.setAttributeNS(null, SubjectConfirmationData.NOT_BEFORE_ATTRIB_NAME, notBeforeStr);
}
if (subjectCD.getNotOnOrAfter() != null) {
String notOnOrAfterStr = Configuration.getSAMLDateFormatter().print(subjectCD.getNotOnOrAfter());
domElement.setAttributeNS(null, SubjectConfirmationData.NOT_ON_OR_AFTER_ATTRIB_NAME, notOnOrAfterStr);
}
if (subjectCD.getRecipient() != null) {
domElement.setAttributeNS(null, SubjectConfirmationData.RECIPIENT_ATTRIB_NAME, subjectCD.getRecipient());
}
if (subjectCD.getInResponseTo() != null) {
domElement.setAttributeNS(null, SubjectConfirmationData.IN_RESPONSE_TO_ATTRIB_NAME, subjectCD
.getInResponseTo());
}
if (subjectCD.getAddress() != null) {
domElement.setAttributeNS(null, SubjectConfirmationData.ADDRESS_ATTRIB_NAME, subjectCD.getAddress());
}
Attr attribute;
for (Entry<QName, String> entry : subjectCD.getUnknownAttributes().entrySet()) {
attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
attribute.setValue(entry.getValue());
domElement.setAttributeNodeNS(attribute);
if (Configuration.isIDAttribute(entry.getKey())
|| subjectCD.getUnknownAttributes().isIDAttribute(entry.getKey())) {
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
}
}
}
示例8: processChildElement
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject)
throws UnmarshallingException {
SubjectConfirmationData subjectCD = (SubjectConfirmationData) parentSAMLObject;
subjectCD.getUnknownXMLObjects().add(childSAMLObject);
}
示例9: getConfirmationTime
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的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;
}
示例10: createSubject
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的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;
}
示例11: checkRecipient
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的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));
}
示例12: testChildElementsMarshall
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的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);
}
示例13: testChildElementsWithEncryptedIDMarshall
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
/** {@inheritDoc}
* @throws XMLParserException */
public void testChildElementsWithEncryptedIDMarshall() throws XMLParserException {
QName qname = new QName(SAMLConstants.SAML20_NS, SubjectConfirmation.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
SubjectConfirmation subjectConfirmation = (SubjectConfirmation) buildXMLObject(qname);
QName encryptedIDQName = new QName(SAMLConstants.SAML20_NS, EncryptedID.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
subjectConfirmation.setEncryptedID((EncryptedID) buildXMLObject(encryptedIDQName));
QName subjectConfirmationDataQName = new QName(SAMLConstants.SAML20_NS, SubjectConfirmationData.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
subjectConfirmation.setSubjectConfirmationData((SubjectConfirmationData) buildXMLObject(subjectConfirmationDataQName));
Document expectedChildElementsWithEncryptedID = parser.parse(SubjectConfirmationTest.class
.getResourceAsStream(childElementsWithEncryptedIDFile));
assertEquals(expectedChildElementsWithEncryptedID, subjectConfirmation);
}
示例14: testSingleElementUnmarshall
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementUnmarshall() {
SubjectConfirmationData subjectCD = (SubjectConfirmationData) unmarshallElement(singleElementFile);
DateTime notBefore = subjectCD.getNotBefore();
assertEquals("NotBefore was " + notBefore + ", expected " + expectedNotBefore, expectedNotBefore, notBefore);
}
示例15: testSingleElementMarshall
import org.opensaml.saml2.core.SubjectConfirmationData; //导入依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementMarshall() {
QName qname = new QName(SAMLConstants.SAML20_NS, SubjectConfirmationData.DEFAULT_ELEMENT_LOCAL_NAME,
SAMLConstants.SAML20_PREFIX);
SubjectConfirmationData subjectCD = (SubjectConfirmationData) buildXMLObject(qname);
subjectCD.setNotBefore(expectedNotBefore);
assertEquals(expectedDOM, subjectCD);
}