Search in sources :

Example 16 with EntityDescriptor

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();
}
Also used : EntityDescriptor(org.opensaml.saml.saml2.metadata.EntityDescriptor) Document(org.w3c.dom.Document) X509Certificate(java.security.cert.X509Certificate) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 17 with EntityDescriptor

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());
}
Also used : EntityDescriptor(org.opensaml.saml.saml2.metadata.EntityDescriptor) Test(org.junit.Test)

Aggregations

EntityDescriptor (org.opensaml.saml.saml2.metadata.EntityDescriptor)13 SPSSODescriptor (org.opensaml.saml.saml2.metadata.SPSSODescriptor)6 IOException (java.io.IOException)3 SamlRegisteredServiceCachingMetadataResolver (org.apereo.cas.support.saml.services.idp.metadata.cache.SamlRegisteredServiceCachingMetadataResolver)3 Document (org.w3c.dom.Document)3 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 NoSuchFileException (java.nio.file.NoSuchFileException)2 Path (java.nio.file.Path)2 X509Certificate (java.security.cert.X509Certificate)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 EntityIdCriterion (org.opensaml.core.criterion.EntityIdCriterion)2 BindingCriterion (org.opensaml.saml.criterion.BindingCriterion)2 ChainingMetadataResolver (org.opensaml.saml.metadata.resolver.ChainingMetadataResolver)2 AssertionConsumerService (org.opensaml.saml.saml2.metadata.AssertionConsumerService)2 KeyDescriptor (org.opensaml.saml.saml2.metadata.KeyDescriptor)2 SingleLogoutService (org.opensaml.saml.saml2.metadata.SingleLogoutService)2