Examples of SAMLMessageContext


Examples of org.springframework.security.saml.context.SAMLMessageContext

     *
     * @throws Exception error
     */
    @Test
    public void testAuthenticate() throws Exception {
        SAMLMessageContext context = new SAMLMessageContext();
        context.setCommunicationProfileId(SAMLConstants.SAML2_WEBSSO_PROFILE_URI);

        SAMLAuthenticationToken token = new SAMLAuthenticationToken(context);
        SAMLCredential result = new SAMLCredential(nameID, assertion, "IDP", "testSP");

        expect(consumer.processAuthenticationResponse(context)).andReturn(result);
View Full Code Here

Examples of org.springframework.security.saml.context.SAMLMessageContext

     *
     * @throws Exception error
     */
    @Test
    public void testAuthenticateUserDetails() throws Exception {
        SAMLMessageContext context = new SAMLMessageContext();
        context.setCommunicationProfileId(SAMLConstants.SAML2_WEBSSO_PROFILE_URI);

        SAMLUserDetailsService details = createMock(SAMLUserDetailsService.class);
        provider.setUserDetails(details);

        SAMLAuthenticationToken token = new SAMLAuthenticationToken(context);
View Full Code Here

Examples of org.springframework.security.saml.context.SAMLMessageContext

     *
     * @throws Exception error
     */
    @Test(expected = AuthenticationServiceException.class)
    public void testAuthenticateException() throws Exception {
        SAMLMessageContext context = new SAMLMessageContext();

        SAMLAuthenticationToken token = new SAMLAuthenticationToken(context);
        SAMLCredential result = new SAMLCredential(nameID, assertion, "IDP", "localSP");

        expect(consumer.processAuthenticationResponse(context)).andThrow(new SAMLException("Error"));
View Full Code Here

Examples of org.springframework.security.saml.context.SAMLMessageContext

    @Test
    public void testPOSTResponseParsing() throws Exception {

        prepareHttpRequest("message/SAMLResponse.xml", "POST", "http://localhost:8080/spring-security-saml2-webapp/saml/SSO", "text/html");
        replayMock();
        SAMLMessageContext context = processor.retrieveMessage(samlContext);
        verifyMock();

        assertNotNull(context.getInboundSAMLMessage());
        assertTrue(context.getInboundSAMLMessage() instanceof Response);
        assertEquals("s22520705f2c89536ee66a2c4c92f2832ce9cdc019", context.getInboundSAMLMessageId());
        assertEquals("http://localhost:8080/opensso", context.getPeerEntityId());
    }
View Full Code Here

Examples of org.springframework.security.saml.context.SAMLMessageContext

     * @throws Exception error
     */
    @Test
    public void testIDPSelection_metadataURL() throws Exception {

        SAMLMessageContext context = new SAMLMessageContext();
        ExtendedMetadata metadata = new ExtendedMetadata();
        metadata.setIdpDiscoveryEnabled(true);
        metadata.setIdpDiscoveryURL("http://test.fi/idpDisco/");
        context.setLocalExtendedMetadata(metadata);
        context.setLocalEntityId("localId");

        context.setInboundMessageTransport(new HttpServletRequestAdapter(request));
        context.setOutboundMessageTransport(new HttpServletResponseAdapter(response, false));

        response.sendRedirect("http://test.fi/idpDisco/?entityID=localId&returnIDParam=idp");

        replayMock();
        entryPoint.initializeDiscovery(context);
View Full Code Here

Examples of org.springframework.security.saml.context.SAMLMessageContext

     * @throws Exception error
     */
    @Test(expected = IllegalArgumentException.class)
    public void testIDPSelection_invalidDiscoURL() throws Exception {

        SAMLMessageContext context = new SAMLMessageContext();
        ExtendedMetadata metadata = new ExtendedMetadata();
        metadata.setIdpDiscoveryEnabled(true);
        metadata.setIdpDiscoveryURL("test.fi/idpDisco/");
        context.setLocalExtendedMetadata(metadata);
        context.setLocalEntityId("localId");

        context.setInboundMessageTransport(new HttpServletRequestAdapter(request));
        context.setOutboundMessageTransport(new HttpServletResponseAdapter(response, false));

        replayMock();
        entryPoint.initializeDiscovery(context);
        verifyMock();

View Full Code Here

Examples of org.springframework.security.saml.context.SAMLMessageContext

     * @throws Exception error
     */
    @Test
    public void testInitialProfileOptions() throws Exception {

        WebSSOProfileOptions ssoProfileOptions = entryPoint.getProfileOptions(new SAMLMessageContext(), null);
        assertEquals(new Integer(2), ssoProfileOptions.getProxyCount());
        assertTrue(ssoProfileOptions.isIncludeScoping());
        assertFalse(ssoProfileOptions.getForceAuthN());
        assertFalse(ssoProfileOptions.getPassive());
        assertNull(ssoProfileOptions.getBinding());
View Full Code Here

Examples of org.springframework.security.saml.context.SAMLMessageContext

        // Set default values
        entryPoint.setDefaultProfileOptions(defaultOptions);

        // Check that default values are used
        WebSSOProfileOptions ssoProfileOptions = entryPoint.getProfileOptions(new SAMLMessageContext(), null);
        assertEquals(new Integer(0), ssoProfileOptions.getProxyCount());
        assertFalse(ssoProfileOptions.isIncludeScoping());
        assertFalse(ssoProfileOptions.getForceAuthN());
        assertFalse(ssoProfileOptions.getPassive());
        assertEquals(SAMLConstants.SAML2_REDIRECT_BINDING_URI, ssoProfileOptions.getBinding());

        // Check that value can't be altered after being set
        defaultOptions.setIncludeScoping(true);
        ssoProfileOptions = entryPoint.getProfileOptions(new SAMLMessageContext(), null);
        assertFalse(ssoProfileOptions.isIncludeScoping());

        // Check that default values can be cleared
        entryPoint.setDefaultProfileOptions(null);
        ssoProfileOptions = entryPoint.getProfileOptions(new SAMLMessageContext(), null);
        assertTrue(ssoProfileOptions.isIncludeScoping());       

        verifyMock();

    }
View Full Code Here

Examples of org.springframework.security.saml.context.SAMLMessageContext

        if (!supports(authentication.getClass())) {
            throw new IllegalArgumentException("Only SAMLAuthenticationToken is supported, " + authentication.getClass() + " was attempted");
        }

        SAMLAuthenticationToken token = (SAMLAuthenticationToken) authentication;
        SAMLMessageContext context = token.getCredentials();
        SAMLCredential credential;

        try {
            if (SAMLConstants.SAML2_WEBSSO_PROFILE_URI.equals(context.getCommunicationProfileId())) {
                credential = consumer.processAuthenticationResponse(context);
            } else if (SAMLConstants.SAML2_HOK_WEBSSO_PROFILE_URI.equals(context.getCommunicationProfileId())) {
                credential = hokConsumer.processAuthenticationResponse(context);
            } else {
                throw new SAMLException("Unsupported profile encountered in the context " + context.getCommunicationProfileId());
            }
        } catch (SAMLRuntimeException e) {
            log.debug("Error validating SAML message", e);
            samlLogger.log(SAMLConstants.AUTH_N_RESPONSE, SAMLConstants.FAILURE, context, e);
            throw new AuthenticationServiceException("Error validating SAML message", e);
View Full Code Here

Examples of org.springframework.security.saml.context.SAMLMessageContext

                    // Notify session participants using SAML Single Logout profile
                    SAMLCredential credential = (SAMLCredential) auth.getCredentials();
                    request.setAttribute(SAMLConstants.LOCAL_ENTITY_ID, credential.getLocalEntityID());
                    request.setAttribute(SAMLConstants.PEER_ENTITY_ID, credential.getRemoteEntityID());
                    SAMLMessageContext context = contextProvider.getLocalAndPeerEntity(request, response);
                    profile.sendLogoutRequest(context, credential);
                    samlLogger.log(SAMLConstants.LOGOUT_REQUEST, SAMLConstants.SUCCESS, context);

                } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.