Search in sources :

Example 1 with POST_BINDING

use of ddf.security.samlp.impl.SamlProtocol.POST_BINDING 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", "soaplocation", "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("logoutlocation", entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getSingleLogoutServices().get(0).getLocation());
    List<SingleSignOnService> ssoServices = entityDescriptor.getIDPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getSingleSignOnServices();
    assertTrue(ssoServices.stream().filter(service -> service.getBinding().equals(REDIRECT_BINDING) && service.getLocation().equals("redirectlocation")).findFirst().isPresent());
    assertTrue(ssoServices.stream().filter(service -> service.getBinding().equals(POST_BINDING) && service.getLocation().equals("postlocation")).findFirst().isPresent());
    assertTrue(ssoServices.stream().filter(service -> service.getBinding().equals(SOAP_BINDING) && service.getLocation().equals("soaplocation")).findFirst().isPresent());
    assertNotNull(entityDescriptor.getCacheDuration());
}
Also used : AttributeQuery(org.opensaml.saml.saml2.core.AttributeQuery) Arrays(java.util.Arrays) AssertionConsumerService(org.opensaml.saml.saml2.metadata.AssertionConsumerService) Assert.assertNotNull(org.junit.Assert.assertNotNull) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) Assert.assertTrue(org.junit.Assert.assertTrue) POST_BINDING(ddf.security.samlp.impl.SamlProtocol.POST_BINDING) Test(org.junit.Test) PAOS_BINDING(ddf.security.samlp.impl.SamlProtocol.PAOS_BINDING) SOAP_BINDING(ddf.security.samlp.impl.SamlProtocol.SOAP_BINDING) LogoutRequest(org.opensaml.saml.saml2.core.LogoutRequest) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) WSSecurityException(org.apache.wss4j.common.ext.WSSecurityException) SingleSignOnService(org.opensaml.saml.saml2.metadata.SingleSignOnService) REDIRECT_BINDING(ddf.security.samlp.impl.SamlProtocol.REDIRECT_BINDING) LogoutWrapper(ddf.security.samlp.LogoutWrapper) EntityDescriptor(org.opensaml.saml.saml2.metadata.EntityDescriptor) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Response(org.opensaml.saml.saml2.core.Response) EntityDescriptor(org.opensaml.saml.saml2.metadata.EntityDescriptor) SingleSignOnService(org.opensaml.saml.saml2.metadata.SingleSignOnService) Test(org.junit.Test)

Example 2 with POST_BINDING

use of ddf.security.samlp.impl.SamlProtocol.POST_BINDING in project ddf by codice.

the class SamlProtocolTest method testCreateSpMetadata.

@Test
public void testCreateSpMetadata() {
    EntityDescriptor entityDescriptor = SamlProtocol.createSpMetadata("myid", "mysigningcert", "myencryptioncert", Arrays.asList("mynameid"), "logoutlocation", "redirectlocation", "postlocation", "paoslocation");
    assertEquals("myid", entityDescriptor.getEntityID());
    assertEquals("mysigningcert", entityDescriptor.getSPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getKeyDescriptors().get(0).getKeyInfo().getX509Datas().get(0).getX509Certificates().get(0).getValue());
    assertEquals("myencryptioncert", entityDescriptor.getSPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getKeyDescriptors().get(1).getKeyInfo().getX509Datas().get(0).getX509Certificates().get(0).getValue());
    assertEquals("mynameid", entityDescriptor.getSPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getNameIDFormats().get(0).getFormat());
    assertEquals("logoutlocation", entityDescriptor.getSPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getSingleLogoutServices().get(0).getLocation());
    List<AssertionConsumerService> acServices = entityDescriptor.getSPSSODescriptor(SamlProtocol.SUPPORTED_PROTOCOL).getAssertionConsumerServices();
    assertTrue(acServices.stream().filter(service -> service.getBinding().equals(REDIRECT_BINDING) && service.getLocation().equals("redirectlocation")).findFirst().isPresent());
    assertTrue(acServices.stream().filter(service -> service.getBinding().equals(POST_BINDING) && service.getLocation().equals("postlocation")).findFirst().isPresent());
    assertTrue(acServices.stream().filter(service -> service.getBinding().equals(PAOS_BINDING) && service.getLocation().equals("paoslocation")).findFirst().isPresent());
    assertNotNull(entityDescriptor.getCacheDuration());
}
Also used : AttributeQuery(org.opensaml.saml.saml2.core.AttributeQuery) Arrays(java.util.Arrays) AssertionConsumerService(org.opensaml.saml.saml2.metadata.AssertionConsumerService) Assert.assertNotNull(org.junit.Assert.assertNotNull) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) Assert.assertTrue(org.junit.Assert.assertTrue) POST_BINDING(ddf.security.samlp.impl.SamlProtocol.POST_BINDING) Test(org.junit.Test) PAOS_BINDING(ddf.security.samlp.impl.SamlProtocol.PAOS_BINDING) SOAP_BINDING(ddf.security.samlp.impl.SamlProtocol.SOAP_BINDING) LogoutRequest(org.opensaml.saml.saml2.core.LogoutRequest) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) WSSecurityException(org.apache.wss4j.common.ext.WSSecurityException) SingleSignOnService(org.opensaml.saml.saml2.metadata.SingleSignOnService) REDIRECT_BINDING(ddf.security.samlp.impl.SamlProtocol.REDIRECT_BINDING) LogoutWrapper(ddf.security.samlp.LogoutWrapper) EntityDescriptor(org.opensaml.saml.saml2.metadata.EntityDescriptor) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Response(org.opensaml.saml.saml2.core.Response) EntityDescriptor(org.opensaml.saml.saml2.metadata.EntityDescriptor) AssertionConsumerService(org.opensaml.saml.saml2.metadata.AssertionConsumerService) Test(org.junit.Test)

Aggregations

LogoutWrapper (ddf.security.samlp.LogoutWrapper)2 PAOS_BINDING (ddf.security.samlp.impl.SamlProtocol.PAOS_BINDING)2 POST_BINDING (ddf.security.samlp.impl.SamlProtocol.POST_BINDING)2 REDIRECT_BINDING (ddf.security.samlp.impl.SamlProtocol.REDIRECT_BINDING)2 SOAP_BINDING (ddf.security.samlp.impl.SamlProtocol.SOAP_BINDING)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 List (java.util.List)2 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertNotNull (org.junit.Assert.assertNotNull)2 Assert.assertNull (org.junit.Assert.assertNull)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Test (org.junit.Test)2 AttributeQuery (org.opensaml.saml.saml2.core.AttributeQuery)2 LogoutRequest (org.opensaml.saml.saml2.core.LogoutRequest)2 LogoutResponse (org.opensaml.saml.saml2.core.LogoutResponse)2 Response (org.opensaml.saml.saml2.core.Response)2 AssertionConsumerService (org.opensaml.saml.saml2.metadata.AssertionConsumerService)2 EntityDescriptor (org.opensaml.saml.saml2.metadata.EntityDescriptor)2