Search in sources :

Example 1 with SystemCrypto

use of ddf.security.samlp.SystemCrypto in project ddf by codice.

the class TestAttributeQueryClaimsHandler method setUp.

@Before
public void setUp() throws IOException {
    signatureProperties = mock(Object.class);
    encryptionProperties = mock(Object.class);
    service = mock(Service.class);
    dispatch = (Dispatch<StreamSource>) mock(Dispatch.class);
    encryptionService = mock(EncryptionService.class);
    systemCrypto = new SystemCrypto("encryption.properties", "signature.properties", encryptionService);
    simpleSign = new SimpleSign(systemCrypto);
    supportedClaims = new ArrayList<>();
    supportedClaims.add("Role");
    supportedClaims.add("NameIdentifier");
    supportedClaims.add("Email");
    AttributeQueryClaimsHandlerTest attributeQueryClaimsHandler = new AttributeQueryClaimsHandlerTest();
    spyAttributeQueryClaimsHandler = spy(attributeQueryClaimsHandler);
    spyAttributeQueryClaimsHandler.setWsdlLocation("wsdlLocation");
    spyAttributeQueryClaimsHandler.setServiceName("serviceName");
    spyAttributeQueryClaimsHandler.setPortName("portName");
    spyAttributeQueryClaimsHandler.setSimpleSign(simpleSign);
    spyAttributeQueryClaimsHandler.setSupportedClaims(supportedClaims);
    spyAttributeQueryClaimsHandler.setExternalAttributeStoreUrl(EXTERNAL_ATTRIBUTE_STORE);
    spyAttributeQueryClaimsHandler.setIssuer(ISSUER);
    spyAttributeQueryClaimsHandler.setDestination(DESTINATION);
    spyAttributeQueryClaimsHandler.setAttributeMapLocation(getClass().getClassLoader().getResource("attributeMap.properties").getPath());
    spyAttributeQueryClaimsHandler.setSignatureProperties(signatureProperties);
    spyAttributeQueryClaimsHandler.setEncryptionProperties(encryptionProperties);
    doReturn(service).when(spyAttributeQueryClaimsHandler).createService();
    doReturn(dispatch).when(spyAttributeQueryClaimsHandler).createDispatcher(service);
    cannedResponse = Resources.toString(Resources.getResource(getClass(), "/SAMLResponse.xml"), Charsets.UTF_8);
}
Also used : SimpleSign(ddf.security.samlp.SimpleSign) SystemCrypto(ddf.security.samlp.SystemCrypto) EncryptionService(ddf.security.encryption.EncryptionService) StreamSource(javax.xml.transform.stream.StreamSource) Service(javax.xml.ws.Service) EncryptionService(ddf.security.encryption.EncryptionService) XMLObject(org.opensaml.core.xml.XMLObject) Before(org.junit.Before)

Example 2 with SystemCrypto

use of ddf.security.samlp.SystemCrypto in project ddf by codice.

the class TestAttributeQueryClient method setUp.

@Before
public void setUp() throws IOException {
    dispatch = mock(Dispatch.class);
    encryptionService = mock(EncryptionService.class);
    systemCrypto = new SystemCrypto("encryption.properties", "signature.properties", encryptionService);
    SimpleSign simpleSign = new SimpleSign(systemCrypto);
    spySimpleSign = spy(simpleSign);
    attributeQueryClient = new AttributeQueryClient(dispatch, spySimpleSign, EXTERNAL_ATTRIBUTE_STORE, ISSUER, DESTINATION);
    attributeQueryClient.setDispatch(dispatch);
    attributeQueryClient.setSimpleSign(spySimpleSign);
    attributeQueryClient.setExternalAttributeStoreUrl(EXTERNAL_ATTRIBUTE_STORE);
    attributeQueryClient.setIssuer(ISSUER);
    attributeQueryClient.setDestination(DESTINATION);
    cannedResponse = Resources.toString(Resources.getResource(getClass(), "/SAMLResponse.xml"), Charsets.UTF_8);
}
Also used : SimpleSign(ddf.security.samlp.SimpleSign) SystemCrypto(ddf.security.samlp.SystemCrypto) EncryptionService(ddf.security.encryption.EncryptionService) Dispatch(javax.xml.ws.Dispatch) Before(org.junit.Before)

Example 3 with SystemCrypto

use of ddf.security.samlp.SystemCrypto in project ddf by codice.

the class AssertionConsumerServiceTest method setUp.

@Before
public void setUp() throws Exception {
    encryptionService = mock(EncryptionService.class);
    systemCrypto = new SystemCrypto("encryption.properties", "signature.properties", encryptionService);
    simpleSign = new SimpleSign(systemCrypto);
    relayStates = (RelayStates<String>) mock(RelayStates.class);
    when(relayStates.encode("fubar")).thenReturn(RELAY_STATE_VAL);
    when(relayStates.decode(RELAY_STATE_VAL)).thenReturn(LOCATION);
    loginFilter = mock(javax.servlet.Filter.class);
    sessionFactory = mock(SessionFactory.class);
    httpRequest = mock(HttpServletRequest.class);
    when(httpRequest.getRequestURL()).thenReturn(new StringBuffer("fubar"));
    when(httpRequest.isSecure()).thenReturn(true);
    idpMetadata = new IdpMetadata();
    assertionConsumerService = new AssertionConsumerService(simpleSign, idpMetadata, systemCrypto, relayStates);
    assertionConsumerService.setRequest(httpRequest);
    assertionConsumerService.setLoginFilter(loginFilter);
    assertionConsumerService.setSessionFactory(sessionFactory);
    cannedResponse = Resources.toString(Resources.getResource(getClass(), "/SAMLResponse.xml"), Charsets.UTF_8);
    String metadata = Resources.toString(Resources.getResource(getClass(), "/IDPmetadata.xml"), Charsets.UTF_8);
    deflatedSamlResponse = Resources.toString(Resources.getResource(getClass(), "/DeflatedSAMLResponse.txt"), Charsets.UTF_8);
    idpMetadata.setMetadata(metadata);
}
Also used : SessionFactory(ddf.security.http.SessionFactory) HttpServletRequest(javax.servlet.http.HttpServletRequest) SimpleSign(ddf.security.samlp.SimpleSign) SystemCrypto(ddf.security.samlp.SystemCrypto) Filter(javax.servlet.Filter) EncryptionService(ddf.security.encryption.EncryptionService) Before(org.junit.Before)

Aggregations

EncryptionService (ddf.security.encryption.EncryptionService)3 SimpleSign (ddf.security.samlp.SimpleSign)3 SystemCrypto (ddf.security.samlp.SystemCrypto)3 Before (org.junit.Before)3 SessionFactory (ddf.security.http.SessionFactory)1 Filter (javax.servlet.Filter)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Dispatch (javax.xml.ws.Dispatch)1 Service (javax.xml.ws.Service)1 XMLObject (org.opensaml.core.xml.XMLObject)1