本文整理汇总了Java中org.opensaml.saml2.metadata.EntityDescriptor.setEntityID方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDescriptor.setEntityID方法的具体用法?Java EntityDescriptor.setEntityID怎么用?Java EntityDescriptor.setEntityID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opensaml.saml2.metadata.EntityDescriptor
的用法示例。
在下文中一共展示了EntityDescriptor.setEntityID方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processAttribute
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
EntityDescriptor entityDescriptor = (EntityDescriptor) samlObject;
if (attribute.getLocalName().equals(EntityDescriptor.ENTITY_ID_ATTRIB_NAME)) {
entityDescriptor.setEntityID(attribute.getValue());
} else if (attribute.getLocalName().equals(EntityDescriptor.ID_ATTRIB_NAME)) {
entityDescriptor.setID(attribute.getValue());
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
} else if (attribute.getLocalName().equals(TimeBoundSAMLObject.VALID_UNTIL_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
entityDescriptor.setValidUntil(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(CacheableSAMLObject.CACHE_DURATION_ATTRIB_NAME)) {
entityDescriptor.setCacheDuration(XMLHelper.durationToLong(attribute.getValue()));
} else {
QName attribQName = XMLHelper.getNodeQName(attribute);
if (attribute.isId()) {
entityDescriptor.getUnknownAttributes().registerID(attribQName);
}
entityDescriptor.getUnknownAttributes().put(attribQName, attribute.getValue());
}
}
示例2: generate
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public MetadataProvider generate(final SAMLConfig configuration) throws MetadataProviderException, ResourceException {
SAMLObjectBuilder<EntityDescriptor> builder = (SAMLObjectBuilder<EntityDescriptor>) builderFactory.getBuilder(EntityDescriptor.DEFAULT_ELEMENT_NAME);
EntityDescriptor descriptor = builder.buildObject();
descriptor.setID(configuration.getIdpEntityId());
descriptor.setEntityID(configuration.getIdpEntityId());
descriptor.getRoleDescriptors().add(buildIDPSSODescriptor(configuration));
MetadataMemoryProvider memoryProvider = new MetadataMemoryProvider(descriptor);
memoryProvider.initialize();
ExtendedMetadata extendedMetadata = new ExtendedMetadata();
extendedMetadata.setSigningKey(configuration.getIdpEntityId());
ExtendedMetadataDelegate idpMetadataProvider = new ExtendedMetadataDelegate(memoryProvider, extendedMetadata);
idpMetadataProvider.setMetadataRequireSignature(false);
idpMetadataProvider.initialize();
return idpMetadataProvider;
}
示例3: generateSPDescriptor
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
protected EntityDescriptor generateSPDescriptor(String baseUrl, Credential credential, List<?> parameters) {
String url = baseUrl + "/WSFedConsumer";
EntityDescriptor descriptor = SAMLUtil.buildXMLObject(EntityDescriptor.class);
descriptor.setEntityID(url);
SPSSODescriptor spDescriptor = SAMLUtil.buildXMLObject(SPSSODescriptor.class);
spDescriptor.setAuthnRequestsSigned(true);
spDescriptor.setWantAssertionsSigned(true);
KeyDescriptor signingDescriptor = SAMLUtil.buildXMLObject(KeyDescriptor.class);
signingDescriptor.setUse(UsageType.SIGNING);
KeyDescriptor encryptionDescriptor = SAMLUtil.buildXMLObject(KeyDescriptor.class);
encryptionDescriptor.setUse(UsageType.ENCRYPTION);
try {
KeyInfoGenerator gen = SecurityHelper.getKeyInfoGenerator(credential, org.opensaml.xml.Configuration.getGlobalSecurityConfiguration(), null);
signingDescriptor.setKeyInfo(gen.generate(credential));
encryptionDescriptor.setKeyInfo(gen.generate(credential));
} catch (SecurityException e1) {
throw new WrappedException(Layer.BUSINESS, e1);
}
spDescriptor.getKeyDescriptors().add(signingDescriptor);
spDescriptor.getKeyDescriptors().add(encryptionDescriptor);
spDescriptor.addSupportedProtocol("http://schemas.xmlsoap.org/ws/2006/12/federation");
spDescriptor.getAssertionConsumerServices().add(SAMLUtil.createAssertionConsumerService(url, "http://schemas.xmlsoap.org/ws/2006/12/federation", 0, true));
spDescriptor.getSingleLogoutServices().add(SAMLUtil.createSingleLogoutService(url, url, "http://schemas.xmlsoap.org/ws/2006/12/federation"));
descriptor.getRoleDescriptors().add(spDescriptor);
return descriptor;
}
示例4: getDiscoveryMetadata
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
private IdpMetadata getDiscoveryMetadata() {
EntityDescriptor ed1 = TestHelper.buildEntityDescriptor(credential);
EntityDescriptor ed2 = TestHelper.buildEntityDescriptor(credential);
ed2.setEntityID("idp2");
IdpMetadata md = new IdpMetadata(SAMLConstants.SAML20P_NS, ed1, ed2);
return md;
}
示例5: same_entity_id_must_be_merged_to_one_with_multiple_certificates
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
@Test
public void same_entity_id_must_be_merged_to_one_with_multiple_certificates() throws Exception {
EntityDescriptor ed3 = TestHelper.buildEntityDescriptor(TestHelper.getCredential());
ed3.setEntityID("ed1");
IdpMetadata md = new IdpMetadata(SAMLConstants.SAML20P_NS, ed1, ed2, ed3);
assertEquals(2, md.getEntityIDs().size());
assertEquals(2, md.getMetadata("ed1").getCertificates().size());
}
示例6: populateRequiredData
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void populateRequiredData() {
EntityDescriptor entityDescriptor = (EntityDescriptor) target;
AttributeAuthorityDescriptor attributeAuthorityDescriptor = (AttributeAuthorityDescriptor) buildXMLObject(new QName(
SAMLConstants.SAML20MD_NS, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX));
entityDescriptor.getRoleDescriptors(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME).add(attributeAuthorityDescriptor);
entityDescriptor.setEntityID("entity id");
}
示例7: testEntityIDFailure
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/**
* Tests for Entity ID failure.
*
* @throws ValidationException
*/
public void testEntityIDFailure() throws ValidationException {
EntityDescriptor entityDescriptor = (EntityDescriptor) target;
entityDescriptor.setEntityID(null);
assertValidationFail("Entity ID was null, should raise a Validation Exception.");
entityDescriptor.setEntityID("");
assertValidationFail("Entity ID was empty string, should raise a Validation Exception.");
entityDescriptor.setEntityID(" ");
assertValidationFail("Entity ID was white space, should raise a Validation Exception.");
}
示例8: testSingleElementMarshall
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementMarshall() {
QName qname = new QName(SAMLConstants.SAML20MD_NS, EntityDescriptor.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
EntityDescriptor descriptor = (EntityDescriptor) buildXMLObject(qname);
descriptor.setEntityID(expectedEntityID);
assertEquals(expectedDOM, descriptor);
}
示例9: testSingleElementOptionalAttributesMarshall
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testSingleElementOptionalAttributesMarshall() {
QName qname = new QName(SAMLConstants.SAML20MD_NS, EntityDescriptor.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
EntityDescriptor descriptor = (EntityDescriptor) buildXMLObject(qname);
descriptor.setEntityID(expectedEntityID);
descriptor.setID(expectedID);
descriptor.setValidUntil(expectedValidUntil);
descriptor.setCacheDuration(expectedCacheDuration);
assertEquals(expectedOptionalAttributesDOM, descriptor);
}
示例10: generateIdPDescriptor
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
private EntityDescriptor generateIdPDescriptor(String stsEntityId, String stsLocation, String stsLogoutLocation, byte[] stsKeystore) {
EntityDescriptor descriptor = SAMLUtil.buildXMLObject(EntityDescriptor.class);
descriptor.setEntityID(stsEntityId);
IDPSSODescriptor desc = SAMLUtil.buildXMLObject(IDPSSODescriptor.class);
desc.addSupportedProtocol("http://schemas.xmlsoap.org/ws/2006/12/federation");
KeyDescriptor signingDescriptor = SAMLUtil.buildXMLObject(KeyDescriptor.class);
signingDescriptor.setUse(UsageType.SIGNING);
KeyDescriptor encryptionDescriptor = SAMLUtil.buildXMLObject(KeyDescriptor.class);
encryptionDescriptor.setUse(UsageType.ENCRYPTION);
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(stsKeystore));
BasicX509Credential credential = new BasicX509Credential();
credential.setEntityCertificate(cert);
KeyInfoGenerator gen = SecurityHelper.getKeyInfoGenerator(credential, org.opensaml.xml.Configuration.getGlobalSecurityConfiguration(), null);
signingDescriptor.setKeyInfo(gen.generate(credential));
encryptionDescriptor.setKeyInfo(gen.generate(credential));
} catch (SecurityException e1) {
throw new WrappedException(Layer.BUSINESS, e1);
} catch (CertificateException e) {
throw new WrappedException(Layer.BUSINESS, e);
}
desc.getKeyDescriptors().add(signingDescriptor);
desc.getKeyDescriptors().add(encryptionDescriptor);
SingleSignOnService sso = SAMLUtil.buildXMLObject(SingleSignOnService.class);
sso.setBinding("http://schemas.xmlsoap.org/ws/2006/12/federation");
sso.setLocation(stsLocation);
desc.getSingleSignOnServices().add(sso);
//TODO: Check that the location should be the same
SingleLogoutService slo = SAMLUtil.buildXMLObject(SingleLogoutService.class);
slo.setBinding("http://schemas.xmlsoap.org/ws/2006/12/federation");
slo.setLocation(stsLogoutLocation);
desc.getSingleLogoutServices().add(slo);
descriptor.getRoleDescriptors().add(desc);
return descriptor;
}
示例11: generateSPDescriptor
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
protected EntityDescriptor generateSPDescriptor(String baseUrl, String entityId, Credential credential, String orgName, String orgUrl, String email, boolean enableArtifact, boolean enableRedirect, boolean enableSoap, boolean enablePostSLO, boolean supportOCESAttributes) {
EntityDescriptor descriptor = SAMLUtil.buildXMLObject(EntityDescriptor.class);
descriptor.setEntityID(entityId);
SPSSODescriptor spDescriptor = SAMLUtil.buildXMLObject(SPSSODescriptor.class);
spDescriptor.setAuthnRequestsSigned(true);
spDescriptor.setWantAssertionsSigned(true);
ContactPerson contact = SAMLUtil.buildXMLObject(ContactPerson.class);
contact.getEmailAddresses().add(SAMLUtil.createEmail(email));
contact.setCompany(SAMLUtil.createCompany(orgName));
contact.setType(ContactPersonTypeEnumeration.TECHNICAL);
descriptor.getContactPersons().add(contact);
descriptor.setOrganization(SAMLUtil.createOrganization(orgName, orgName, orgUrl));
KeyDescriptor signingDescriptor = SAMLUtil.buildXMLObject(KeyDescriptor.class);
signingDescriptor.setUse(UsageType.SIGNING);
KeyDescriptor encryptionDescriptor = SAMLUtil.buildXMLObject(KeyDescriptor.class);
encryptionDescriptor.setUse(UsageType.ENCRYPTION);
try {
KeyInfoGenerator gen = SecurityHelper.getKeyInfoGenerator(credential, org.opensaml.xml.Configuration.getGlobalSecurityConfiguration(), null);
signingDescriptor.setKeyInfo(gen.generate(credential));
encryptionDescriptor.setKeyInfo(gen.generate(credential));
} catch (SecurityException e1) {
throw new WrappedException(Layer.BUSINESS, e1);
}
spDescriptor.getKeyDescriptors().add(signingDescriptor);
spDescriptor.getKeyDescriptors().add(encryptionDescriptor);
spDescriptor.addSupportedProtocol(SAMLConstants.SAML20P_NS);
spDescriptor.getAssertionConsumerServices().add(SAMLUtil.createAssertionConsumerService(baseUrl + "/SAMLAssertionConsumer", SAMLConstants.SAML2_POST_BINDING_URI, 0, true));
if (enableArtifact) {
spDescriptor.getAssertionConsumerServices().add(SAMLUtil.createAssertionConsumerService(baseUrl + "/SAMLAssertionConsumer", SAMLConstants.SAML2_ARTIFACT_BINDING_URI, 1, false));
}
if (enableRedirect) {
spDescriptor.getAssertionConsumerServices().add(SAMLUtil.createAssertionConsumerService(baseUrl + "/SAMLAssertionConsumer", SAMLConstants.SAML2_REDIRECT_BINDING_URI, 2, false));
}
spDescriptor.getSingleLogoutServices().add(SAMLUtil.createSingleLogoutService(baseUrl + "/LogoutServiceHTTPRedirect", baseUrl + "/LogoutServiceHTTPRedirectResponse", SAMLConstants.SAML2_REDIRECT_BINDING_URI));
if (enableSoap) {
spDescriptor.getSingleLogoutServices().add(SAMLUtil.createSingleLogoutService(baseUrl + "/LogoutServiceSOAP", null, SAMLConstants.SAML2_SOAP11_BINDING_URI));
}
if(enablePostSLO) {
spDescriptor.getSingleLogoutServices().add(SAMLUtil.createSingleLogoutService(baseUrl + "/LogoutServiceHTTPPost", baseUrl + "/LogoutServiceHTTPRedirectResponse", SAMLConstants.SAML2_POST_BINDING_URI));
}
NameIDFormat x509SubjectNameIDFormat = SAMLUtil.createNameIDFormat(OIOSAMLConstants.NAMEIDFORMAT_X509SUBJECTNAME);
List<NameIDFormat> nameIDFormats = spDescriptor.getNameIDFormats();
nameIDFormats.add(x509SubjectNameIDFormat);
if (enableArtifact) {
spDescriptor.getArtifactResolutionServices().add(SAMLUtil.createArtifactResolutionService(baseUrl + "/SAMLAssertionConsumer"));
}
if (supportOCESAttributes) {
addAttributeConsumerService(spDescriptor, entityId);
}
descriptor.getRoleDescriptors().add(spDescriptor);
return descriptor;
}
示例12: testChildElementsMarshall
import org.opensaml.saml2.metadata.EntityDescriptor; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void testChildElementsMarshall() {
QName qname = new QName(SAMLConstants.SAML20MD_NS, EntityDescriptor.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
EntityDescriptor descriptor = (EntityDescriptor) buildXMLObject(qname);
descriptor.setID(expectedID);
descriptor.setEntityID(expectedEntityID);
QName extensionsQName = new QName(SAMLConstants.SAML20MD_NS, Extensions.LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
descriptor.setExtensions((Extensions) buildXMLObject(extensionsQName));
descriptor.setSignature( buildSignatureSkeleton() );
QName idpSSOQName = new QName(SAMLConstants.SAML20MD_NS, IDPSSODescriptor.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
QName spSSOQName = new QName(SAMLConstants.SAML20MD_NS, SPSSODescriptor.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
QName authnAuthQName = new QName(SAMLConstants.SAML20MD_NS, AuthnAuthorityDescriptor.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
QName pdpQName = new QName(SAMLConstants.SAML20MD_NS, PDPDescriptor.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
QName affilQName = new QName(SAMLConstants.SAML20MD_NS, AffiliationDescriptor.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
descriptor.getRoleDescriptors(IDPSSODescriptor.DEFAULT_ELEMENT_NAME).add((IDPSSODescriptor) buildXMLObject(idpSSOQName));
descriptor.getRoleDescriptors(SPSSODescriptor.DEFAULT_ELEMENT_NAME).add((SPSSODescriptor) buildXMLObject(spSSOQName));
descriptor.getRoleDescriptors(SPSSODescriptor.DEFAULT_ELEMENT_NAME).add((SPSSODescriptor) buildXMLObject(spSSOQName));
descriptor.getRoleDescriptors(AuthnAuthorityDescriptor.DEFAULT_ELEMENT_NAME).add((AuthnAuthorityDescriptor) buildXMLObject(authnAuthQName));
descriptor.getRoleDescriptors(PDPDescriptor.DEFAULT_ELEMENT_NAME).add((PDPDescriptor) buildXMLObject(pdpQName));
descriptor.getRoleDescriptors(IDPSSODescriptor.DEFAULT_ELEMENT_NAME).add((IDPSSODescriptor) buildXMLObject(idpSSOQName));
descriptor.getRoleDescriptors(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME).add((AttributeAuthorityDescriptor) buildXMLObject(AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME));
descriptor.getRoleDescriptors(SPSSODescriptor.DEFAULT_ELEMENT_NAME).add((SPSSODescriptor) buildXMLObject(spSSOQName));
descriptor.getRoleDescriptors(AuthnAuthorityDescriptor.DEFAULT_ELEMENT_NAME).add((AuthnAuthorityDescriptor) buildXMLObject(authnAuthQName));
descriptor.getRoleDescriptors(PDPDescriptor.DEFAULT_ELEMENT_NAME).add((PDPDescriptor) buildXMLObject(pdpQName));
descriptor.setAffiliationDescriptor((AffiliationDescriptor) buildXMLObject(affilQName));
QName orgQName = new QName(SAMLConstants.SAML20MD_NS, Organization.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
descriptor.setOrganization((Organization) buildXMLObject(orgQName));
QName contactQName = new QName(SAMLConstants.SAML20MD_NS, ContactPerson.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
descriptor.getContactPersons().add((ContactPerson) buildXMLObject(contactQName));
QName addMDQName = new QName(SAMLConstants.SAML20MD_NS, AdditionalMetadataLocation.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20MD_PREFIX);
for (int i = 0; i < 3; i++) {
descriptor.getAdditionalMetadataLocations().add((AdditionalMetadataLocation) buildXMLObject(addMDQName));
}
assertEquals(expectedChildElementsDOM, descriptor);
}