本文整理汇总了Java中org.opensaml.core.criterion.EntityIdCriterion类的典型用法代码示例。如果您正苦于以下问题:Java EntityIdCriterion类的具体用法?Java EntityIdCriterion怎么用?Java EntityIdCriterion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityIdCriterion类属于org.opensaml.core.criterion包,在下文中一共展示了EntityIdCriterion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getSingleSignOn
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
public URI getSingleSignOn(String entityId) {
EntityDescriptor idpEntityDescriptor;
try {
CriteriaSet criteria = new CriteriaSet(new EntityIdCriterion(entityId));
idpEntityDescriptor = metadataProvider.resolveSingle(criteria);
} catch (ResolverException e) {
LOG.error(format("Exception when accessing metadata: {0}", e));
throw propagate(e);
}
if(idpEntityDescriptor!=null) {
final IDPSSODescriptor idpssoDescriptor = idpEntityDescriptor.getIDPSSODescriptor(SAMLConstants.SAML20P_NS);
final List<SingleSignOnService> singleSignOnServices = idpssoDescriptor.getSingleSignOnServices();
if (singleSignOnServices.isEmpty()) {
LOG.error(format("No singleSignOnServices present for IDP entityId: {0}", entityId));
} else {
if (singleSignOnServices.size() > 1) {
LOG.warn(format("More than one singleSignOnService present: {0} for {1}", singleSignOnServices.size(), entityId));
}
return URI.create(singleSignOnServices.get(0).getLocation());
}
}
throw ApplicationException.createUnauditedException(ExceptionType.NOT_FOUND, UUID.randomUUID(), new RuntimeException(format("no entity descriptor for IDP: {0}", entityId)));
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:27,代码来源:IdpSingleSignOnServiceHelper.java
示例2: getSingleSignOn
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Test
public void getSingleSignOn() throws Exception {
// Given
SingleSignOnServiceBuilder singleSignOnServiceBuilder = new SingleSignOnServiceBuilder();
SingleSignOnService singleSignOnService = singleSignOnServiceBuilder.buildObject();
singleSignOnService.setLocation("http://the-sso-location");
IDPSSODescriptorBuilder idpssoDescriptorBuilder = new IDPSSODescriptorBuilder();
IDPSSODescriptor idpssoDescriptor = idpssoDescriptorBuilder.buildObject();
idpssoDescriptor.getSingleSignOnServices().add(singleSignOnService);
idpssoDescriptor.addSupportedProtocol(SAMLConstants.SAML20P_NS);
EntityDescriptorBuilder entityDescriptorBuilder = new EntityDescriptorBuilder();
EntityDescriptor entityDescriptor = entityDescriptorBuilder.buildObject();
entityDescriptor.setEntityID("the-entity-id");
entityDescriptor.getRoleDescriptors().add(idpssoDescriptor);
when(metadataResolver.resolveSingle(new CriteriaSet(new EntityIdCriterion(entityDescriptor.getEntityID())))).thenReturn(entityDescriptor);
// When
URI singleSignOnUri = service.getSingleSignOn(entityDescriptor.getEntityID());
// Then
assertThat(singleSignOnUri.toString(), equalTo(singleSignOnService.getLocation()));
verify(metadataResolver).resolveSingle(any(CriteriaSet.class));
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:27,代码来源:CountrySingleSignOnServiceHelperTest.java
示例3: validateAll
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
public void validateAll() {
try {
Iterable<EntityDescriptor> entityDescriptors = metadataResolver.resolve(new CriteriaSet(new EntityIdCriterion(hubFederationId)));
entityDescriptors.forEach(entityDescriptor -> {
String entityID = entityDescriptor.getEntityID();
if (hubEntityId.equals(entityDescriptor.getEntityID())) {
metadataCertificatesRepository.getHubEncryptionCertificates(entityID);
metadataCertificatesRepository.getHubSigningCertificates(entityID);
} else {
metadataCertificatesRepository.getIdpSigningCertificates(entityID);
}
});
} catch (ResolverException e) {
throw new InvalidSamlMetadataException("Metadata could not be read from the metadata service", e);
}
}
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:17,代码来源:MetadataCertificateValidator.java
示例4: setUp
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
entityId = "http://issuer";
when(msaConfiguration.getEntityId()).thenReturn(entityId);
when(msaConfiguration.getMatchingServiceAdapterExternalUrl()).thenReturn(URI.create("http://localhost"));
when(certificateStore.getEncryptionCertificates()).thenReturn(asList());
when(msaMetadataResolver.resolveSingle(new CriteriaSet(new EntityIdCriterion(TestEntityIds.HUB_ENTITY_ID)))).thenReturn(new EntityDescriptorFactory().hubEntityDescriptor());
when(matchingServiceAdapterConfiguration.getHubSSOUri()).thenReturn(URI.create(hubSsoEndPoint));
when(matchingServiceAdapterConfiguration.shouldRepublishHubCertificates()).thenReturn(false);
entityDescriptorElementTransformer = new CoreTransformersFactory().getXmlObjectToElementTransformer();
keyDescriptorsUnmarshaller = new KeyDescriptorsUnmarshaller(new OpenSamlXmlObjectFactory());
matchingServiceAdapterMetadataRepository = new MatchingServiceAdapterMetadataRepository(
msaConfiguration,
keyDescriptorsUnmarshaller,
entityDescriptorElementTransformer,
certificateStore,
msaMetadataResolver,
matchingServiceAdapterConfiguration,
TestEntityIds.HUB_ENTITY_ID);
}
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:23,代码来源:MatchingServiceAdapterMetadataRepositoryTest.java
示例5: shouldBeAbleToLoadMSAMetadataUsingMetadataResolver
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Test
public void shouldBeAbleToLoadMSAMetadataUsingMetadataResolver() throws Exception {
when(matchingServiceAdapterConfiguration.shouldRepublishHubCertificates()).thenReturn(true);
Document matchingServiceAdapterMetadata = matchingServiceAdapterMetadataRepository.getMatchingServiceAdapterMetadata();
String metadata = XmlUtils.writeToString(matchingServiceAdapterMetadata);
StringBackedMetadataResolver stringBackedMetadataResolver = new StringBackedMetadataResolver(metadata);
BasicParserPool pool = new BasicParserPool();
pool.initialize();
stringBackedMetadataResolver.setParserPool(pool);
stringBackedMetadataResolver.setId("Some ID");
stringBackedMetadataResolver.initialize();
assertThat(stringBackedMetadataResolver.resolveSingle(new CriteriaSet(new EntityIdCriterion(entityId))).getEntityID()).isEqualTo(entityId);
assertThat(stringBackedMetadataResolver.resolveSingle(new CriteriaSet(new EntityIdCriterion(TestEntityIds.HUB_ENTITY_ID))).getEntityID()).isEqualTo(TestEntityIds.HUB_ENTITY_ID);
}
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:18,代码来源:MatchingServiceAdapterMetadataRepositoryTest.java
示例6: getEntityDescriptorForEntityId
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Override
public EntityDescriptor getEntityDescriptorForEntityId(final String entityId) {
try {
final CriteriaSet criterions = new CriteriaSet(new EntityIdCriterion(entityId));
if (this.metadataResolver != null) {
return metadataResolver.resolveSingle(criterions);
}
} catch (final Exception ex) {
throw new RuntimeException(ex.getMessage(), ex);
}
return null;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:AbstractMetadataResolverAdapter.java
示例7: get
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
private static Optional<SamlRegisteredServiceServiceProviderMetadataFacade> get(final SamlRegisteredServiceCachingMetadataResolver resolver,
final SamlRegisteredService registeredService,
final String entityID,
final CriteriaSet criterions) {
LOGGER.info("Adapting SAML metadata for CAS service [{}] issued by [{}]",
registeredService.getName(), entityID);
try {
criterions.add(new BindingCriterion(Collections.singletonList(SAMLConstants.SAML2_POST_BINDING_URI)));
criterions.add(new EntityIdCriterion(entityID));
LOGGER.info("Locating metadata for entityID [{}] with binding [{}] by attempting to run through the metadata chain...",
entityID, SAMLConstants.SAML2_POST_BINDING_URI);
final ChainingMetadataResolver chainingMetadataResolver = resolver.resolve(registeredService);
LOGGER.info("Resolved metadata chain for service [{}]. Filtering the chain by entity ID [{}] and binding [{}]",
registeredService.getServiceId(), entityID, SAMLConstants.SAML2_POST_BINDING_URI);
final EntityDescriptor entityDescriptor = chainingMetadataResolver.resolveSingle(criterions);
if (entityDescriptor == null) {
LOGGER.debug("Cannot find entity [{}] in metadata provider.", entityID);
return Optional.empty();
}
LOGGER.debug("Located EntityDescriptor in metadata for [{}]", entityID);
final SPSSODescriptor ssoDescriptor = entityDescriptor.getSPSSODescriptor(SAMLConstants.SAML20P_NS);
if (ssoDescriptor != null) {
LOGGER.debug("Located SPSSODescriptor in metadata for [{}]. Metadata is valid until [{}]",
entityID, ssoDescriptor.getValidUntil());
return Optional.of(new SamlRegisteredServiceServiceProviderMetadataFacade(ssoDescriptor, entityDescriptor, chainingMetadataResolver));
}
LOGGER.warn("Could not locate SPSSODescriptor in the metadata for [{}]", entityID);
return Optional.empty();
} catch (final Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:35,代码来源:SamlRegisteredServiceServiceProviderMetadataFacade.java
示例8: getEntityDescriptorForEntityId
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Override
public EntityDescriptor getEntityDescriptorForEntityId(final String entityId) {
try {
final CriteriaSet criterions = new CriteriaSet(new EntityIdCriterion(entityId));
if (this.metadataResolver != null) {
return this.metadataResolver.resolveSingle(criterions);
}
} catch (final Exception ex) {
throw Throwables.propagate(ex);
}
return null;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:14,代码来源:AbstractMetadataResolverAdapter.java
示例9: getMetadataAsAServiceProvider
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
public EntityDescriptor getMetadataAsAServiceProvider() {
try {
CriteriaSet criteria = new CriteriaSet(new EntityIdCriterion(hubEntityId));
return Optional.ofNullable(metadataResolver.resolveSingle(criteria))
.map(this::copyEntityDescriptor)
.map(this::addValidUntilTime)
.orElseThrow(() -> new HubEntityNotFoundException("The hub was not found in metadata"));
} catch (ResolverException e) {
throw Throwables.propagate(e);
}
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:12,代码来源:HubAsSpMetadataHandler.java
示例10: getSingleSignOn
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
public URI getSingleSignOn(String entityId) {
EidasMetadataResolver metadataResolver = new EidasMetadataResolver(new Timer(), client, URI.create(entityId));
try {
EntityDescriptor idpEntityDescriptor;
try {
CriteriaSet criteria = new CriteriaSet(new EntityIdCriterion(entityId));
idpEntityDescriptor = metadataResolver.resolveSingle(criteria);
} catch (ResolverException e) {
LOG.error(format("Exception when accessing metadata: {0}", e));
throw propagate(e);
}
if (idpEntityDescriptor != null) {
final IDPSSODescriptor idpssoDescriptor = idpEntityDescriptor.getIDPSSODescriptor(SAMLConstants.SAML20P_NS);
final List<SingleSignOnService> singleSignOnServices = idpssoDescriptor.getSingleSignOnServices();
if (singleSignOnServices.isEmpty()) {
LOG.error(format("No singleSignOnServices present for IDP entityId: {0}", entityId));
} else {
if (singleSignOnServices.size() > 1) {
LOG.warn(format("More than one singleSignOnService present: {0} for {1}", singleSignOnServices.size(), entityId));
}
return URI.create(singleSignOnServices.get(0).getLocation());
}
}
throw ApplicationException.createUnauditedException(ExceptionType.NOT_FOUND, UUID.randomUUID(), new RuntimeException(format("no entity descriptor for IDP: {0}", entityId)));
} finally {
if (metadataResolver != null) {
metadataResolver.destroy();
}
}
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:34,代码来源:CountrySingleSignOnServiceHelper.java
示例11: setUp
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Before
public void setUp() throws ResolverException, MarshallingException, SignatureException {
IdaSamlBootstrap.bootstrap();
CriteriaSet criteria = new CriteriaSet(new EntityIdCriterion(idpEntityId));
EntityDescriptor idpEntityDescriptor = anEntityDescriptor().withIdpSsoDescriptor(anIdpSsoDescriptor().withSingleSignOnService(anEndpoint().withLocation(idpSSOUri.toASCIIString()).buildSingleSignOnService()).build()).build();
when(metadataProvider.resolveSingle(eq(criteria))).thenReturn(idpEntityDescriptor);
when(metadataProvider.resolveSingle(not(eq(criteria)))).thenReturn(null);
idpSingleSignOnServiceHelper = new IdpSingleSignOnServiceHelper(metadataProvider);
}
开发者ID:alphagov,项目名称:verify-hub,代码行数:11,代码来源:IdpSingleSignOnServiceHelperTest.java
示例12: check
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Override
protected Result check() throws Exception {
try {
CriteriaSet criteria = new CriteriaSet(new EntityIdCriterion(expectedEntityId));
EntityDescriptor entityDescriptor = metadataResolver.resolveSingle(criteria);
if (entityDescriptor != null) {
return healthy();
}
return unhealthy(getMessage("No exception was thrown"));
} catch (Exception e) {
return unhealthy(getMessage(e.getMessage()));
}
}
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:14,代码来源:MetadataHealthCheck.java
示例13: getEncryptionPublicKey
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
public PublicKey getEncryptionPublicKey() {
try {
CriteriaSet criteria = new CriteriaSet(new EntityIdCriterion(entityId));
return Optional.ofNullable(metadataResolver.resolveSingle(criteria))
.flatMap(this::getPublicKeys)
.orElseThrow(this::missingEntityIdException);
} catch (ResolverException e) {
throw new RuntimeException(e);
}
}
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:11,代码来源:MetadataPublicKeyExtractor.java
示例14: addContext
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
protected final void addContext(final SAML2MetadataResolver entityId, final BaseContext parentContext,
final QName elementName) {
final EntityDescriptor entityDescriptor;
final RoleDescriptor roleDescriptor;
try {
final CriteriaSet set = new CriteriaSet();
set.add(new EntityIdCriterion(entityId.getEntityId()));
entityDescriptor = this.metadata.resolveSingle(set);
if (entityDescriptor == null) {
throw new SAMLException("Cannot find entity " + entityId + " in metadata provider");
}
final List<RoleDescriptor> list = entityDescriptor.getRoleDescriptors(elementName,
SAMLConstants.SAML20P_NS);
roleDescriptor = CommonHelper.isNotEmpty(list) ? list.get(0) : null;
if (roleDescriptor == null) {
throw new SAMLException("Cannot find entity " + entityId + " or role "
+ elementName + " in metadata provider");
}
} catch (final ResolverException e) {
throw new SAMLException("An error occured while getting IDP descriptors", e);
}
final SAMLMetadataContext mdCtx = parentContext.getSubcontext(SAMLMetadataContext.class, true);
mdCtx.setEntityDescriptor(entityDescriptor);
mdCtx.setRoleDescriptor(roleDescriptor);
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:29,代码来源:SAML2ContextProvider.java
示例15: getEntityDescriptorElement
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Override
public final XMLObject getEntityDescriptorElement() {
try {
return resolve().resolveSingle(new CriteriaSet(new EntityIdCriterion(this.idpEntityId)));
} catch (final ResolverException e) {
throw new SAMLException("Error initializing idpMetadataProvider", e);
}
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:SAML2IdentityProviderMetadataResolver.java
示例16: getEntityDescriptorElement
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Override
public XMLObject getEntityDescriptorElement() {
try {
return resolve().resolveSingle(new CriteriaSet(new EntityIdCriterion(getEntityId())));
} catch (final ResolverException e) {
throw new SAMLException("Error initializing idpMetadataProvider", e);
}
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:SAML2ServiceProviderMetadataResolver.java
示例17: getCredential
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Override
public final Credential getCredential() {
try {
final CriteriaSet cs = new CriteriaSet();
final EntityIdCriterion criteria = new EntityIdCriterion(this.privateKey);
cs.add(criteria);
final X509Credential creds = (X509Credential) this.credentialResolver.resolveSingle(cs);
return creds;
} catch (final ResolverException e) {
throw new SAMLException("Can't obtain SP private key", e);
}
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:13,代码来源:KeyStoreCredentialProvider.java
示例18: findByEntityId
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Override
public Optional<EntityDescriptor> findByEntityId(String entityId) {
try {
return Optional.ofNullable(metadataResolver.resolveSingle(new CriteriaSet(new EntityIdCriterion(entityId))));
} catch (ResolverException e) {
return Optional.empty();
}
}
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:9,代码来源:ResolverBackedMetadataRepository.java
示例19: getEntityDescriptor
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
private EntityDescriptor getEntityDescriptor(String entityId) {
try {
return metadataResolver.resolveSingle(new CriteriaSet(new EntityIdCriterion(entityId)));
} catch (ResolverException e) {
throw new InvalidSamlMetadataException("Metadata could not be read from the metadata service", e);
}
}
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:8,代码来源:MetadataCertificatesRepository.java
示例20: shouldGenerateValidMetadataFromLocalConfiguration
import org.opensaml.core.criterion.EntityIdCriterion; //导入依赖的package包/类
@Test
public void shouldGenerateValidMetadataFromLocalConfiguration() throws Exception {
HTTPMetadataResolver httpMetadataResolver = new HTTPMetadataResolver(new Timer(), HttpClientBuilder.create().build(),
"http://localhost:" + applicationRule.getLocalPort() + "/matching-service/SAML2/metadata");
BasicParserPool basicParserPool = new BasicParserPool();
basicParserPool.initialize();
httpMetadataResolver.setParserPool(basicParserPool);
httpMetadataResolver.setId("test id");
httpMetadataResolver.initialize();
httpMetadataResolver.refresh();
EntityDescriptor descriptor = httpMetadataResolver.resolveSingle(new CriteriaSet(new EntityIdCriterion(TEST_RP_MS)));
AttributeAuthorityDescriptor attributeAuthorityDescriptor = descriptor.getAttributeAuthorityDescriptor(SAMLConstants.SAML20P_NS);
Map<UsageType, List<KeyDescriptor>> keysByUsage = attributeAuthorityDescriptor.getKeyDescriptors().stream()
.collect(groupingBy(KeyDescriptor::getUse));
assertThat(keysByUsage.get(UsageType.SIGNING)).hasSize(2);
assertThat(keysByUsage.get(UsageType.ENCRYPTION)).hasSize(1);
assertThat(getCertificateNames(keysByUsage, UsageType.SIGNING)).contains(MSA_SIGNING_PRIMARY, MSA_SIGNING_SECONDARY);
assertThat(getCertificateNames(keysByUsage, UsageType.ENCRYPTION)).contains(MSA_ENCRYPTION_PRIMARY);
IDPSSODescriptor idpssoDescriptor = descriptor.getIDPSSODescriptor(SAMLConstants.SAML20P_NS);
assertThat(idpssoDescriptor).isNotNull();
assertThat(idpssoDescriptor.getSingleSignOnServices()).hasSize(1);
keysByUsage = idpssoDescriptor.getKeyDescriptors().stream().collect(groupingBy(KeyDescriptor::getUse));
assertThat(keysByUsage.get(UsageType.SIGNING)).hasSize(2);
assertThat(getCertificateNames(keysByUsage, UsageType.SIGNING)).contains(MSA_SIGNING_PRIMARY, MSA_SIGNING_SECONDARY);
}
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:33,代码来源:MatchingServiceAdapterMetadataAppRuleTest.java
注:本文中的org.opensaml.core.criterion.EntityIdCriterion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论