Package org.picketlink.identity.federation.core.wstrust.auth

Examples of org.picketlink.identity.federation.core.wstrust.auth.STSValidatingLoginModule


    public void testLoginWithValidToken() throws Exception {
        // Make the validateToken() method return true.
        when(stsClient.validateToken(any(Element.class))).thenReturn(true);

        final STSValidatingLoginModule loginModule = new FakeSTSValidatingLoginModule(stsClient);
        final CallbackHandler callbackHandler = new TestCallbackHandler(Util.createSamlToken());
        final Subject subject = new Subject();

        loginModule.initialize(subject, callbackHandler, null, getAllOptions());

        // Simulate Phase 1
        assertTrue(loginModule.login());

        // Simulate Phase 2
        assertTrue(loginModule.commit());

        final Set<SamlCredential> samlCredentials = subject.<SamlCredential> getPublicCredentials(SamlCredential.class);
        assertEquals(1, samlCredentials.size());
    }
View Full Code Here


    public void testLoginWithInValidToken() throws Exception {
        // Make the validateToken() method return false.
        when(stsClient.validateToken(any(Element.class))).thenReturn(false);

        final STSValidatingLoginModule loginModule = new FakeSTSValidatingLoginModule(stsClient);
        final CallbackHandler callbackHandler = new TestCallbackHandler(Util.createSamlToken());

        loginModule.initialize(new Subject(), callbackHandler, null, getAllOptions());

        try {
            // Simulate Phase 1
            loginModule.login();
            fail("login should have thrown a LoginException!");
        } catch (final Exception e) {
            assertTrue(e instanceof LoginException);
        }
    }
View Full Code Here

    public void testStackedModules() throws Exception {
        // Make the validateToken() method return true.
        when(stsClient.validateToken(any(Element.class))).thenReturn(true);

        final STSValidatingLoginModule loginModule = new FakeSTSValidatingLoginModule(stsClient);
        final Element token = Util.createSamlToken();

        final Subject subject = new Subject();

        final Map<String, Object> sharedState = new HashMap<String, Object>();

        loginModule.initialize(subject, null, sharedState, getAllOptions());
        // Simlulate that a previous LM stored a security token in the shared state.
        loginModule.setSharedToken(token);

        // Simulate Phase 1
        assertTrue(loginModule.login());

        // Simulate Phase 2
        assertTrue(loginModule.commit());

        final Set<SamlCredential> samlCredentials = subject.<SamlCredential> getPublicCredentials(SamlCredential.class);
        assertEquals(1, samlCredentials.size());
    }
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.core.wstrust.auth.STSValidatingLoginModule

Copyright © 2018 www.massapicom. 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.