本文整理汇总了Java中org.opensaml.saml2.metadata.EntityDescriptor.getEntityID方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDescriptor.getEntityID方法的具体用法?Java EntityDescriptor.getEntityID怎么用?Java EntityDescriptor.getEntityID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.saml2.metadata.EntityDescriptor
的用法示例。
在下文中一共展示了EntityDescriptor.getEntityID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSingleElementOptionalAttributesUnmarshall
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesUnmarshall() {
EntityDescriptor descriptor = (EntityDescriptor) unmarshallElement(singleElementOptionalAttributesFile);
String entityID = descriptor.getEntityID();
assertEquals("entityID attribute has a value of " + entityID + ", expected a value of " + expectedEntityID,
expectedEntityID, entityID);
String id = descriptor.getID();
assertEquals("ID attribute has a value of " + id + ", expected a value of " + expectedID, expectedID, id);
long duration = descriptor.getCacheDuration().longValue();
assertEquals("cacheDuration attribute has a value of " + duration + ", expected a value of "
+ expectedCacheDuration, expectedCacheDuration, duration);
DateTime validUntil = descriptor.getValidUntil();
assertEquals("validUntil attribute value did not match expected value", 0, expectedValidUntil
.compareTo(validUntil));
}
示例2: marshallAttributes
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlElement, Element domElement) {
EntityDescriptor entityDescriptor = (EntityDescriptor) samlElement;
// Set the entityID attribute
if (entityDescriptor.getEntityID() != null) {
domElement.setAttributeNS(null, EntityDescriptor.ENTITY_ID_ATTRIB_NAME, entityDescriptor.getEntityID());
}
// Set the ID attribute
if (entityDescriptor.getID() != null) {
domElement.setAttributeNS(null, EntityDescriptor.ID_ATTRIB_NAME, entityDescriptor.getID());
domElement.setIdAttributeNS(null, EntityDescriptor.ID_ATTRIB_NAME, true);
}
// Set the validUntil attribute
if (entityDescriptor.getValidUntil() != null) {
log.debug("Writting validUntil attribute to EntityDescriptor DOM element");
String validUntilStr = Configuration.getSAMLDateFormatter().print(entityDescriptor.getValidUntil());
domElement.setAttributeNS(null, TimeBoundSAMLObject.VALID_UNTIL_ATTRIB_NAME, validUntilStr);
}
// Set the cacheDuration attribute
if (entityDescriptor.getCacheDuration() != null) {
log.debug("Writting cacheDuration attribute to EntityDescriptor DOM element");
String cacheDuration = XMLHelper.longToDuration(entityDescriptor.getCacheDuration());
domElement.setAttributeNS(null, CacheableSAMLObject.CACHE_DURATION_ATTRIB_NAME, cacheDuration);
}
Attr attribute;
for (Entry<QName, String> entry : entityDescriptor.getUnknownAttributes().entrySet()) {
attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
attribute.setValue(entry.getValue());
domElement.setAttributeNodeNS(attribute);
if (Configuration.isIDAttribute(entry.getKey())
|| entityDescriptor.getUnknownAttributes().isIDAttribute(entry.getKey())) {
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
}
}
}
示例3: testSingleElementUnmarshall
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementUnmarshall() {
EntityDescriptor descriptor = (EntityDescriptor) unmarshallElement(singleElementFile);
String entityID = descriptor.getEntityID();
assertEquals("entityID attribute has a value of " + entityID + ", expected a value of " + expectedEntityID,
expectedEntityID, entityID);
Long duration = descriptor.getCacheDuration();
assertNull("cacheDuration attribute has a value of " + duration + ", expected no value", duration);
DateTime validUntil = descriptor.getValidUntil();
assertNull("validUntil attribute has a value of " + validUntil + ", expected no value", validUntil);
}
示例4: fromMetadata
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/**
* Constructs an SAML client using XML metadata obtained from the identity provider. <p> When
* using Okta as an identity provider, it is possible to pass null to relyingPartyIdentifier and
* assertionConsumerServiceUrl; they will be inferred from the metadata provider XML.
*
* @param relyingPartyIdentifier the identifier for the relying party.
* @param assertionConsumerServiceUrl the url where the identity provider will post back the
* SAML response.
* @param metadata the XML metadata obtained from the identity provider.
* @return The created {@link SamlClient}.
* @throws SamlException thrown if any error occur while loading the metadata information.
*/
public static SamlClient fromMetadata(
String relyingPartyIdentifier, String assertionConsumerServiceUrl, Reader metadata)
throws SamlException {
ensureOpenSamlIsInitialized();
MetadataProvider metadataProvider = createMetadataProvider(metadata);
EntityDescriptor entityDescriptor = getEntityDescriptor(metadataProvider);
IDPSSODescriptor idpSsoDescriptor = getIDPSSODescriptor(entityDescriptor);
SingleSignOnService postBinding = getPostBinding(idpSsoDescriptor);
List<X509Certificate> x509Certificates = getCertificates(idpSsoDescriptor);
boolean isOkta = entityDescriptor.getEntityID().contains(".okta.com");
if (relyingPartyIdentifier == null) {
// Okta's own toolkit uses the entity ID as a relying party identifier, so if we
// detect that the IDP is Okta let's tolerate a null value for this parameter.
if (isOkta) {
relyingPartyIdentifier = entityDescriptor.getEntityID();
} else {
throw new IllegalArgumentException("relyingPartyIdentifier");
}
}
if (assertionConsumerServiceUrl == null && isOkta) {
// Again, Okta's own toolkit uses this value for the assertion consumer url, which
// kinda makes no sense since this is supposed to be a url pointing to a server
// outside Okta, but it probably just straight ignores this and use the one from
// it's own config anyway.
assertionConsumerServiceUrl = postBinding.getLocation();
}
String identityProviderUrl = postBinding.getLocation();
String responseIssuer = entityDescriptor.getEntityID();
return new SamlClient(
relyingPartyIdentifier,
assertionConsumerServiceUrl,
identityProviderUrl,
responseIssuer,
x509Certificates);
}