Search in sources :

Example 1 with HttpSessionInvalidator

use of org.codice.ddf.platform.session.api.HttpSessionInvalidator in project ddf by codice.

the class LogoutRequestServiceTest method testSoapLogoutRequestBadSignature.

@Test
public void testSoapLogoutRequestBadSignature() throws Exception {
    HttpSessionInvalidator httpSessionInvalidator = mock(HttpSessionInvalidator.class);
    logoutRequestService.setHttpSessionInvalidator(httpSessionInvalidator);
    LogoutResponse logoutResponse = mock(LogoutResponse.class);
    LogoutWrapper logoutResponseWrapper = mock(LogoutWrapper.class);
    doReturn(logoutResponse).when(logoutResponseWrapper).getMessage();
    doReturn(logoutResponseWrapper).when(logoutMessage).buildLogoutResponse(anyString(), anyString(), anyString());
    logoutRequestService.setLogoutMessage(logoutMessage);
    doThrow(SignatureException.class).when(simpleSign).validateSignature(any(Signature.class), any(Document.class));
    InputStream requestStream = LogoutRequestServiceTest.class.getResourceAsStream("/SAMLSoapLogoutRequest-good.xml");
    Response response = logoutRequestService.soapLogoutRequest(requestStream, null);
    assertThat(response.getStatus(), is(Status.OK.getStatusCode()));
    verify(httpSessionInvalidator, times(0)).invalidateSession(anyString(), any());
}
Also used : LogoutWrapper(ddf.security.samlp.LogoutWrapper) Response(javax.ws.rs.core.Response) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) InputStream(java.io.InputStream) Signature(org.opensaml.xmlsec.signature.Signature) Document(org.w3c.dom.Document) HttpSessionInvalidator(org.codice.ddf.platform.session.api.HttpSessionInvalidator) Test(org.junit.Test)

Example 2 with HttpSessionInvalidator

use of org.codice.ddf.platform.session.api.HttpSessionInvalidator in project ddf by codice.

the class LogoutRequestServiceTest method testSoapLogoutRequestIssueInstantOld.

@Test
public void testSoapLogoutRequestIssueInstantOld() {
    HttpSessionInvalidator httpSessionInvalidator = mock(HttpSessionInvalidator.class);
    logoutRequestService.setHttpSessionInvalidator(httpSessionInvalidator);
    logoutRequestService.setLogoutMessage(logoutMessage);
    InputStream requestStream = LogoutRequestServiceTest.class.getResourceAsStream("/SAMLSoapLogoutRequest-good.xml");
    Response response = logoutRequestService.soapLogoutRequest(requestStream, null);
    assertThat(response.getStatus(), is(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
    verify(httpSessionInvalidator, times(0)).invalidateSession(anyString(), any());
}
Also used : Response(javax.ws.rs.core.Response) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) InputStream(java.io.InputStream) HttpSessionInvalidator(org.codice.ddf.platform.session.api.HttpSessionInvalidator) Test(org.junit.Test)

Example 3 with HttpSessionInvalidator

use of org.codice.ddf.platform.session.api.HttpSessionInvalidator in project ddf by codice.

the class LogoutRequestServiceTest method testSoapLogoutRequestNotALogout.

@Test
public void testSoapLogoutRequestNotALogout() {
    HttpSessionInvalidator httpSessionInvalidator = mock(HttpSessionInvalidator.class);
    logoutRequestService.setHttpSessionInvalidator(httpSessionInvalidator);
    logoutRequestService.setLogoutMessage(logoutMessage);
    InputStream requestStream = LogoutRequestServiceTest.class.getResourceAsStream("/SAMLSoapLogoutRequest-bad.xml");
    Response response = logoutRequestService.soapLogoutRequest(requestStream, null);
    assertThat(response.getStatus(), is(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
    verify(httpSessionInvalidator, times(0)).invalidateSession(anyString(), any());
}
Also used : Response(javax.ws.rs.core.Response) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) InputStream(java.io.InputStream) HttpSessionInvalidator(org.codice.ddf.platform.session.api.HttpSessionInvalidator) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)3 Response (javax.ws.rs.core.Response)3 HttpSessionInvalidator (org.codice.ddf.platform.session.api.HttpSessionInvalidator)3 Test (org.junit.Test)3 LogoutResponse (org.opensaml.saml.saml2.core.LogoutResponse)3 LogoutWrapper (ddf.security.samlp.LogoutWrapper)1 Signature (org.opensaml.xmlsec.signature.Signature)1 Document (org.w3c.dom.Document)1