本文整理汇总了Java中org.opensaml.core.criterion.EntityIdCriterion类的典型用法代码示例。如果您正苦于以下问题:Java EntityIdCriterion类的具体用法?Java EntityIdCriterion怎么用?Java EntityIdCriterion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityIdCriterion类属于org.opensaml.core.criterion包,在下文中一共展示了EntityIdCriterion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)));
}
示例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));
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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();
}
}
}
示例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);
}
示例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()));
}
}
示例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);
}
}
示例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);
}
示例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);
}
}