use of org.apereo.cas.support.saml.services.idp.metadata.SamlIdPMetadataDocument in project cas by apereo.
the class FileSystemSamlIdPMetadataLocator method fetchInternal.
@SneakyThrows
@Override
protected SamlIdPMetadataDocument fetchInternal(final Optional<SamlRegisteredService> registeredService) {
val doc = new SamlIdPMetadataDocument();
doc.setMetadata(IOUtils.toString(resolveMetadata(registeredService).getInputStream(), StandardCharsets.UTF_8));
doc.setEncryptionCertificate(IOUtils.toString(getEncryptionCertificate(registeredService).getInputStream(), StandardCharsets.UTF_8));
doc.setEncryptionKey(IOUtils.toString(resolveEncryptionKey(registeredService).getInputStream(), StandardCharsets.UTF_8));
doc.setSigningCertificate(IOUtils.toString(resolveSigningCertificate(registeredService).getInputStream(), StandardCharsets.UTF_8));
doc.setSigningKey(IOUtils.toString(resolveSigningKey(registeredService).getInputStream(), StandardCharsets.UTF_8));
doc.setAppliesTo(SamlIdPMetadataGenerator.getAppliesToFor(registeredService));
return doc;
}
use of org.apereo.cas.support.saml.services.idp.metadata.SamlIdPMetadataDocument in project cas by apereo.
the class RestfulSamlIdPMetadataGeneratorWithArtifactsTests method setup.
@BeforeAll
public static void setup() throws Exception {
val document = new SamlIdPMetadataDocument(1000, "CAS", IOUtils.toString(new ClassPathResource("metadata/idp-metadata.xml").getInputStream(), StandardCharsets.UTF_8), IOUtils.toString(new ClassPathResource("metadata/idp-signing.crt").getInputStream(), StandardCharsets.UTF_8), IOUtils.toString(new ClassPathResource("metadata/idp-signing.key").getInputStream(), StandardCharsets.UTF_8), IOUtils.toString(new ClassPathResource("metadata/idp-encryption.crt").getInputStream(), StandardCharsets.UTF_8), IOUtils.toString(new ClassPathResource("metadata/idp-encryption.key").getInputStream(), StandardCharsets.UTF_8));
val entity = MAPPER.writeValueAsString(document);
val resource = new ByteArrayResource(entity.getBytes(StandardCharsets.UTF_8), "Output");
SERVER = new MockWebServer(9443, resource, HttpStatus.OK);
SERVER.start();
}
use of org.apereo.cas.support.saml.services.idp.metadata.SamlIdPMetadataDocument in project cas by apereo.
the class RestfulSamlIdPMetadataGeneratorTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
var document = new SamlIdPMetadataDocument();
var entity = MAPPER.writeValueAsString(document);
try (val webServer = new MockWebServer(9453, new ByteArrayResource(entity.getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.OK)) {
webServer.start();
assertNotNull(samlIdPMetadataGenerator.generate(Optional.empty()));
}
document.setEncryptionCertificate(UUID.randomUUID().toString());
document.setSigningKey(UUID.randomUUID().toString());
document.setSigningCertificate(UUID.randomUUID().toString());
document.setEncryptionKey(UUID.randomUUID().toString());
document.setMetadata(UUID.randomUUID().toString());
entity = MAPPER.writeValueAsString(document);
try (val webServer = new MockWebServer(9453, new ByteArrayResource(entity.getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.OK)) {
webServer.start();
val service = new SamlRegisteredService();
service.setName("TestShib");
service.setId(1000);
assertNotNull(samlIdPMetadataGenerator.generate(Optional.of(service)));
}
try (val webServer = new MockWebServer(9453, new ByteArrayResource("___".getBytes(StandardCharsets.UTF_8), "Output"), HttpStatus.OK)) {
webServer.start();
assertNotNull(samlIdPMetadataGenerator.generate(Optional.empty()));
}
}
use of org.apereo.cas.support.saml.services.idp.metadata.SamlIdPMetadataDocument in project cas by apereo.
the class RestfulSamlIdPMetadataLocatorTests method setup.
@BeforeAll
public static void setup() throws Exception {
val document = new SamlIdPMetadataDocument(1000, "CAS", IOUtils.toString(new ClassPathResource("metadata/idp-metadata.xml").getInputStream(), StandardCharsets.UTF_8), IOUtils.toString(new ClassPathResource("metadata/idp-signing.crt").getInputStream(), StandardCharsets.UTF_8), IOUtils.toString(new ClassPathResource("metadata/idp-signing.key").getInputStream(), StandardCharsets.UTF_8), IOUtils.toString(new ClassPathResource("metadata/idp-encryption.crt").getInputStream(), StandardCharsets.UTF_8), IOUtils.toString(new ClassPathResource("metadata/idp-encryption.key").getInputStream(), StandardCharsets.UTF_8));
val entity = MAPPER.writeValueAsString(document);
val resource = new ByteArrayResource(entity.getBytes(StandardCharsets.UTF_8), "Output");
SERVER = new MockWebServer(9433, resource, HttpStatus.OK);
SERVER.start();
}
use of org.apereo.cas.support.saml.services.idp.metadata.SamlIdPMetadataDocument in project cas by apereo.
the class RedisSamlIdPMetadataLocator method fetchInternal.
@Override
public SamlIdPMetadataDocument fetchInternal(final Optional<SamlRegisteredService> registeredService) {
val appliesTo = SamlIdPMetadataGenerator.getAppliesToFor(registeredService);
val keys = redisTemplate.keys(CAS_PREFIX + appliesTo + ":*", this.scanCount);
return keys.findFirst().map(key -> redisTemplate.boundValueOps(key).get()).orElse(null);
}
Aggregations