Search in sources :

Example 16 with EntityIdCriterion

use of org.opensaml.core.criterion.EntityIdCriterion in project cas by apereo.

the class SamlRegisteredServiceCacheKeyTests method verifyCacheKeyByMetadataLocation.

@Test
public void verifyCacheKeyByMetadataLocation() {
    val entityId = "https://carmenwiki.osu.edu/shibboleth";
    val criteriaSet = new CriteriaSet();
    criteriaSet.add(new EntityIdCriterion(entityId));
    criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
    val service = new SamlRegisteredService();
    service.setName("Example");
    service.setId(1000);
    service.setServiceId(".+");
    service.setMetadataLocation("classpath:sample-sp.xml");
    val results = new SamlRegisteredServiceCacheKey(service, criteriaSet);
    assertNotNull(results.getId());
    assertNotNull(results.getRegisteredService());
    assertNotNull(results.getCriteriaSet());
    assertEquals(results.getCacheKey(), service.getMetadataLocation());
}
Also used : lombok.val(lombok.val) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) EntityIdCriterion(org.opensaml.core.criterion.EntityIdCriterion) EntityRoleCriterion(org.opensaml.saml.criterion.EntityRoleCriterion) Test(org.junit.jupiter.api.Test)

Example 17 with EntityIdCriterion

use of org.opensaml.core.criterion.EntityIdCriterion in project cas by apereo.

the class FileSystemResourceMetadataResolverTests method verifyResolverWithDirectory.

@Test
public void verifyResolverWithDirectory() throws Exception {
    val resolver = new FileSystemResourceMetadataResolver(PROPERTIES, openSamlConfigBean);
    val service = new SamlRegisteredService();
    val file = new FileSystemResource("src/test/resources/md-dir").getFile().getCanonicalPath();
    service.setMetadataLocation(file);
    val resolvers = resolver.resolve(service);
    assertFalse(resolvers.isEmpty());
    val directoryResolver = resolvers.iterator().next();
    val criteriaSet = new CriteriaSet();
    criteriaSet.add(new EntityIdCriterion("https://idp.example.net/idp/shibboleth"));
    criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
    assertNotNull(directoryResolver.resolve(criteriaSet));
}
Also used : lombok.val(lombok.val) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) EntityIdCriterion(org.opensaml.core.criterion.EntityIdCriterion) EntityRoleCriterion(org.opensaml.saml.criterion.EntityRoleCriterion) FileSystemResource(org.springframework.core.io.FileSystemResource) Test(org.junit.jupiter.api.Test)

Example 18 with EntityIdCriterion

use of org.opensaml.core.criterion.EntityIdCriterion in project cas by apereo.

the class InMemoryResourceMetadataResolverTests method verifyInvalidExpiredMetadataResourceIsOkay.

@Test
public void verifyInvalidExpiredMetadataResourceIsOkay() throws Exception {
    val resolver = new InMemoryResourceMetadataResolver(new ClassPathResource("metadata/metadata-expired.xml"), configBean);
    resolver.setRequireValidMetadata(false);
    resolver.setId(UUID.randomUUID().toString());
    resolver.initialize();
    val criteriaSet = new CriteriaSet();
    criteriaSet.add(new EntityIdCriterion("urn:app.e2ma.net"));
    criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
    val resolved = resolver.resolve(criteriaSet);
    assertFalse(Iterables.isEmpty(resolved));
}
Also used : lombok.val(lombok.val) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) EntityIdCriterion(org.opensaml.core.criterion.EntityIdCriterion) EntityRoleCriterion(org.opensaml.saml.criterion.EntityRoleCriterion) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 19 with EntityIdCriterion

use of org.opensaml.core.criterion.EntityIdCriterion in project cas by apereo.

the class InMemoryResourceMetadataResolverTests method verifyExpiredValidUntilMetadataResource.

@Test
public void verifyExpiredValidUntilMetadataResource() throws Exception {
    val resolver = new InMemoryResourceMetadataResolver(new ClassPathResource("metadata/metadata-expired.xml"), configBean);
    resolver.setId(UUID.randomUUID().toString());
    resolver.initialize();
    val criteriaSet = new CriteriaSet();
    criteriaSet.add(new EntityIdCriterion("urn:app.e2ma.net"));
    criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
    val resolved = resolver.resolve(criteriaSet);
    assertTrue(Iterables.isEmpty(resolved));
}
Also used : lombok.val(lombok.val) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) EntityIdCriterion(org.opensaml.core.criterion.EntityIdCriterion) EntityRoleCriterion(org.opensaml.saml.criterion.EntityRoleCriterion) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 20 with EntityIdCriterion

use of org.opensaml.core.criterion.EntityIdCriterion in project verify-hub by alphagov.

the class IdpSingleSignOnServiceHelperTest method setUp.

@BeforeEach
public void setUp() throws ResolverException, MarshallingException, SignatureException {
    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);
}
Also used : EntityDescriptor(org.opensaml.saml.saml2.metadata.EntityDescriptor) EntityDescriptorBuilder.anEntityDescriptor(uk.gov.ida.saml.core.test.builders.metadata.EntityDescriptorBuilder.anEntityDescriptor) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) EntityIdCriterion(org.opensaml.core.criterion.EntityIdCriterion) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

EntityIdCriterion (org.opensaml.core.criterion.EntityIdCriterion)44 CriteriaSet (net.shibboleth.utilities.java.support.resolver.CriteriaSet)39 EntityRoleCriterion (org.opensaml.saml.criterion.EntityRoleCriterion)30 lombok.val (lombok.val)25 Test (org.junit.jupiter.api.Test)9 UsageCriterion (org.opensaml.security.criteria.UsageCriterion)9 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)7 EntityDescriptor (org.opensaml.saml.saml2.metadata.EntityDescriptor)7 ArrayList (java.util.ArrayList)5 File (java.io.File)4 SamlException (org.apereo.cas.support.saml.SamlException)4 ProtocolCriterion (org.opensaml.saml.criterion.ProtocolCriterion)4 IDPSSODescriptor (org.opensaml.saml.saml2.metadata.IDPSSODescriptor)4 SAMLSignatureProfileValidator (org.opensaml.saml.security.impl.SAMLSignatureProfileValidator)4 ResolverException (net.shibboleth.utilities.java.support.resolver.ResolverException)3 SamlIdPMetadataCredentialResolver (org.apereo.cas.support.saml.idp.metadata.locator.SamlIdPMetadataCredentialResolver)3 SamlIdPSamlRegisteredServiceCriterion (org.apereo.cas.support.saml.idp.metadata.locator.SamlIdPSamlRegisteredServiceCriterion)3 BasicProviderKeyInfoCredentialResolver (org.opensaml.xmlsec.keyinfo.impl.BasicProviderKeyInfoCredentialResolver)3 DEREncodedKeyValueProvider (org.opensaml.xmlsec.keyinfo.impl.provider.DEREncodedKeyValueProvider)3 DSAKeyValueProvider (org.opensaml.xmlsec.keyinfo.impl.provider.DSAKeyValueProvider)3