use of org.apereo.cas.support.saml.services.idp.metadata.SamlMetadataDocument in project cas by apereo.
the class RestSamlRegisteredServiceMetadataResolverTests method setup.
@Before
@SneakyThrows
public void setup() {
final SamlMetadataDocument doc = new SamlMetadataDocument();
doc.setId(1);
doc.setName("SAML Document");
doc.setSignature(null);
doc.setValue(IOUtils.toString(new ClassPathResource("sp-metadata.xml").getInputStream(), StandardCharsets.UTF_8));
final String data = MAPPER.writeValueAsString(doc);
this.webServer = new MockWebServer(8078, new ByteArrayResource(data.getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_XML_VALUE);
this.webServer.start();
}
use of org.apereo.cas.support.saml.services.idp.metadata.SamlMetadataDocument in project cas by apereo.
the class JpaSamlRegisteredServiceMetadataResolverTests method verifyResolver.
@Test
public void verifyResolver() throws Exception {
final ClassPathResource res = new ClassPathResource("samlsp-metadata.xml");
final SamlMetadataDocument md = new SamlMetadataDocument();
md.setName("SP");
md.setValue(IOUtils.toString(res.getInputStream(), StandardCharsets.UTF_8));
resolver.saveOrUpdate(md);
final SamlRegisteredService service = new SamlRegisteredService();
service.setName("SAML Service");
service.setServiceId("https://carmenwiki.osu.edu/shibboleth");
service.setDescription("Testing");
service.setMetadataLocation("jdbc://");
assertTrue(resolver.supports(service));
final Collection<MetadataResolver> resolvers = resolver.resolve(service);
assertTrue(resolvers.size() == 1);
}
use of org.apereo.cas.support.saml.services.idp.metadata.SamlMetadataDocument in project cas by apereo.
the class MongoDbSamlRegisteredServiceMetadataResolverTests method setup.
@Before
public void setup() throws Exception {
final MongoDbSamlMetadataProperties mongo = casProperties.getAuthn().getSamlIdp().getMetadata().getMongo();
final ClassPathResource res = new ClassPathResource("sp-metadata.xml");
final SamlMetadataDocument md = new SamlMetadataDocument();
md.setName("SP");
md.setValue(IOUtils.toString(res.getInputStream(), StandardCharsets.UTF_8));
mongoDbSamlMetadataResolverTemplate.save(md, mongo.getCollection());
}
use of org.apereo.cas.support.saml.services.idp.metadata.SamlMetadataDocument in project cas by apereo.
the class RestSamlRegisteredServiceMetadataResolver method resolve.
@Override
public Collection<MetadataResolver> resolve(final SamlRegisteredService service) {
try {
final RestSamlMetadataProperties rest = samlIdPProperties.getMetadata().getRest();
final HttpResponse response = HttpUtils.execute(rest.getUrl(), rest.getMethod(), rest.getBasicAuthUsername(), rest.getBasicAuthPassword(), CollectionUtils.wrap("entityId", service.getServiceId()), CollectionUtils.wrap("Content-Type", MediaType.APPLICATION_XML_VALUE));
if (response != null && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
final SamlMetadataDocument doc = MAPPER.readValue(response.getEntity().getContent(), SamlMetadataDocument.class);
final MetadataResolver resolver = buildMetadataResolverFrom(service, doc);
return CollectionUtils.wrapList(resolver);
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return null;
}
Aggregations