use of org.opensaml.core.criterion.EntityIdCriterion in project cas by apereo.
the class SamlIdPMetadataResolverTests method verifyOperation.
@RepeatedTest(2)
public void verifyOperation() throws Exception {
val criteria = new CriteriaSet(new EntityIdCriterion(casProperties.getAuthn().getSamlIdp().getCore().getEntityId()));
val result1 = casSamlIdPMetadataResolver.resolve(criteria);
assertFalse(Iterables.isEmpty(result1));
val result2 = casSamlIdPMetadataResolver.resolve(criteria);
assertFalse(Iterables.isEmpty(result2));
assertEquals(Iterables.size(result1), Iterables.size(result2));
}
use of org.opensaml.core.criterion.EntityIdCriterion in project cas by apereo.
the class SamlIdPMetadataResolverTests method verifyOperationEmpty.
@RepeatedTest(2)
public void verifyOperationEmpty() throws Exception {
val criteria = new CriteriaSet(new EntityIdCriterion("https://example.com"));
val result = casSamlIdPMetadataResolver.resolve(criteria);
assertTrue(Iterables.isEmpty(result));
}
use of org.opensaml.core.criterion.EntityIdCriterion in project cas by apereo.
the class SamlIdPUtilsTests method verifyMetadataForAllServices.
@Test
public void verifyMetadataForAllServices() throws Exception {
val service = getSamlRegisteredServiceForTestShib();
servicesManager.save(service);
val md = SamlIdPUtils.getMetadataResolverForAllSamlServices(servicesManager, service.getServiceId(), samlRegisteredServiceCachingMetadataResolver);
assertNotNull(md);
val criteriaSet = new CriteriaSet();
criteriaSet.add(new EntityIdCriterion(service.getServiceId()));
criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
criteriaSet.add(new BindingCriterion(CollectionUtils.wrap(SAMLConstants.SAML2_POST_BINDING_URI)));
val it = md.resolve(criteriaSet).iterator();
assertTrue(it.hasNext());
assertEquals(service.getServiceId(), it.next().getEntityID());
}
use of org.opensaml.core.criterion.EntityIdCriterion in project cas by apereo.
the class SamlRegisteredServiceMetadataExpirationPolicy method getCacheDurationForServiceProvider.
/**
* Gets cache duration for service provider.
*
* @param service the service
* @param chainingMetadataResolver the chaining metadata resolver
* @return the cache duration for service provider
*/
protected long getCacheDurationForServiceProvider(final SamlRegisteredService service, final MetadataResolver chainingMetadataResolver) {
try {
if (StringUtils.isBlank(service.getServiceId())) {
LOGGER.warn("Unable to determine duration for SAML service [{}] with no entity id", service.getName());
return -1;
}
val set = new CriteriaSet();
set.add(new EntityIdCriterion(service.getServiceId()));
set.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
val entitySp = chainingMetadataResolver.resolveSingle(set);
if (entitySp != null && entitySp.getCacheDuration() != null) {
LOGGER.debug("Located cache duration [{}] specified in SP metadata for [{}]", entitySp.getCacheDuration(), entitySp.getEntityID());
return TimeUnit.MILLISECONDS.toNanos(entitySp.getCacheDuration().toMillis());
}
set.clear();
set.add(new EntityIdCriterion(service.getServiceId()));
val entity = chainingMetadataResolver.resolveSingle(set);
if (entity != null && entity.getCacheDuration() != null) {
LOGGER.debug("Located cache duration [{}] specified in entity metadata for [{}]", entity.getCacheDuration(), entity.getEntityID());
return TimeUnit.MILLISECONDS.toNanos(entity.getCacheDuration().toMillis());
}
} catch (final Exception e) {
LOGGER.debug(e.getMessage(), e);
}
return -1;
}
use of org.opensaml.core.criterion.EntityIdCriterion in project cas by apereo.
the class SamlRegisteredServiceCacheKeyTests method verifyCacheKeyDynamicMetadata.
@Test
public void verifyCacheKeyDynamicMetadata() {
val criteriaSet = new CriteriaSet();
val entityIdCriterion = new EntityIdCriterion("https://carmenwiki.osu.edu/shibboleth");
criteriaSet.add(entityIdCriterion);
criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
val service = new SamlRegisteredService();
service.setName("Example");
service.setId(1000);
service.setServiceId(".+");
service.setMetadataLocation("https://mdq.something.net/entities/{0}");
val result1 = new SamlRegisteredServiceCacheKey(service, criteriaSet);
assertNotNull(result1.getId());
assertNotNull(result1.toString());
assertEquals(entityIdCriterion.getEntityId(), result1.getCacheKey());
val result2 = new SamlRegisteredServiceCacheKey(service, criteriaSet);
assertEquals(result1, result2);
}
Aggregations