Search in sources :

Example 1 with RelayStates

use of ddf.security.samlp.impl.RelayStates in project ddf by codice.

the class LogoutRequestServiceTest method setup.

@Before
public void setup() throws ParserConfigurationException, SAXException, IOException {
    simpleSign = mock(SimpleSign.class);
    idpMetadata = mock(IdpMetadata.class);
    relayStates = mock(RelayStates.class);
    sessionFactory = mock(SessionFactory.class);
    request = mock(HttpServletRequest.class);
    logoutMessage = mock(LogoutMessage.class);
    encryptionService = mock(EncryptionService.class);
    session = mock(HttpSession.class);
    securityTokenHolder = mock(SecurityTokenHolder.class);
    Element issuedAssertion = readSamlAssertion().getDocumentElement();
    String assertionId = issuedAssertion.getAttributeNodeNS(null, "ID").getNodeValue();
    SecurityToken token = new SecurityToken(assertionId, issuedAssertion, null);
    when(securityTokenHolder.getSecurityToken("idp")).thenReturn(token);
    logoutRequestService = new MockLogoutRequestService(simpleSign, idpMetadata, relayStates);
    logoutRequestService.setEncryptionService(encryptionService);
    logoutRequestService.setLogOutPageTimeOut(LOGOUT_PAGE_TIMEOUT);
    logoutRequestService.setLogoutMessage(logoutMessage);
    logoutRequestService.setRequest(request);
    logoutRequestService.setSessionFactory(sessionFactory);
    logoutRequestService.init();
    when(sessionFactory.getOrCreateSession(request)).thenReturn(session);
    when(session.getAttribute(eq(SecurityConstants.SAML_ASSERTION))).thenReturn(securityTokenHolder);
    when(request.getRequestURL()).thenReturn(new StringBuffer("www.url.com/url"));
    when(idpMetadata.getSigningCertificate()).thenReturn("signingCertificate");
    when(idpMetadata.getSingleLogoutBinding()).thenReturn(SamlProtocol.REDIRECT_BINDING);
    when(idpMetadata.getSingleLogoutLocation()).thenReturn(redirectLogoutUrl);
    System.setProperty("security.audit.roles", "none");
}
Also used : SessionFactory(ddf.security.http.SessionFactory) RelayStates(ddf.security.samlp.impl.RelayStates) LogoutMessage(ddf.security.samlp.LogoutMessage) HttpSession(javax.servlet.http.HttpSession) Element(org.w3c.dom.Element) Matchers.anyString(org.mockito.Matchers.anyString) HttpServletRequest(javax.servlet.http.HttpServletRequest) SecurityToken(org.apache.cxf.ws.security.tokenstore.SecurityToken) SimpleSign(ddf.security.samlp.SimpleSign) SecurityTokenHolder(ddf.security.common.SecurityTokenHolder) EncryptionService(ddf.security.encryption.EncryptionService) Before(org.junit.Before)

Aggregations

SecurityTokenHolder (ddf.security.common.SecurityTokenHolder)1 EncryptionService (ddf.security.encryption.EncryptionService)1 SessionFactory (ddf.security.http.SessionFactory)1 LogoutMessage (ddf.security.samlp.LogoutMessage)1 SimpleSign (ddf.security.samlp.SimpleSign)1 RelayStates (ddf.security.samlp.impl.RelayStates)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpSession (javax.servlet.http.HttpSession)1 SecurityToken (org.apache.cxf.ws.security.tokenstore.SecurityToken)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Element (org.w3c.dom.Element)1