use of org.opensaml.saml.saml2.metadata.EntityDescriptor in project ddf by codice.
the class AssertionConsumerService method retrieveMetadata.
@GET
@Path("/metadata")
@Produces("application/xml")
public Response retrieveMetadata() throws WSSecurityException, CertificateEncodingException {
X509Certificate issuerCert = findCertificate(systemCrypto.getSignatureAlias(), systemCrypto.getSignatureCrypto());
X509Certificate encryptionCert = findCertificate(systemCrypto.getEncryptionAlias(), systemCrypto.getEncryptionCrypto());
String hostname = SystemBaseUrl.getHost();
String port = SystemBaseUrl.getPort();
String rootContext = SystemBaseUrl.getRootContext();
String entityId = String.format("https://%s:%s%s/saml", hostname, port, rootContext);
String logoutLocation = String.format("https://%s:%s%s/saml/logout", hostname, port, rootContext);
String assertionConsumerServiceLocation = String.format("https://%s:%s%s/saml/sso", hostname, port, rootContext);
EntityDescriptor entityDescriptor = SamlProtocol.createSpMetadata(entityId, Base64.getEncoder().encodeToString(issuerCert.getEncoded()), Base64.getEncoder().encodeToString(encryptionCert.getEncoded()), logoutLocation, assertionConsumerServiceLocation, assertionConsumerServiceLocation);
Document doc = DOMUtils.createDocument();
doc.appendChild(doc.createElement("root"));
return Response.ok(DOM2Writer.nodeToString(OpenSAMLUtil.toDom(entityDescriptor, doc, false))).build();
}
use of org.opensaml.saml.saml2.metadata.EntityDescriptor in project ddf by codice.
the class SamlProtocolTest method testCreateIdpMetadata.
@Test
public void testCreateIdpMetadata() {
EntityDescriptor entityDescriptor = SamlProtocol.createIdpMetadata("myid", "mysigningcert", "myencryptioncert", Arrays.asList("mynameid"), "redirectlocation", "postlocation", "logoutlocation");
assertEquals("myid", entityDescriptor.getEntityID());
assertEquals("mysigningcert", entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getKeyDescriptors().get(0).getKeyInfo().getX509Datas().get(0).getX509Certificates().get(0).getValue());
assertEquals("myencryptioncert", entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getKeyDescriptors().get(1).getKeyInfo().getX509Datas().get(0).getX509Certificates().get(0).getValue());
assertEquals("mynameid", entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getNameIDFormats().get(0).getFormat());
assertEquals("redirectlocation", entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getSingleSignOnServices().get(0).getLocation());
assertEquals("postlocation", entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getSingleSignOnServices().get(1).getLocation());
assertEquals("logoutlocation", entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getSingleLogoutServices().get(0).getLocation());
}
Aggregations