Package javax.security.auth.login

Examples of javax.security.auth.login.LoginContext.logout()


        try {
            String[] response = entryBean.doubleWhoAmI();
            assertEquals("user1", response[0]);
            assertEquals("user1", response[1]);
        } finally {
            lc.logout();
        }
    }

    @Test
    public void testAuthentication_TwoBeans_ReAuth() throws Exception {
View Full Code Here


        try {
            String[] response = entryBean.doubleWhoAmI("user2", "password2");
            assertEquals("user1", response[0]);
            assertEquals("user2", response[1]);
        } finally {
            lc.logout();
        }
    }

    // TODO - Similar test with first bean @RunAs - does it make sense to also manually switch?
    @Test
View Full Code Here

        try {
            entryBean.doubleWhoAmI("user2", "wrong_password");
            fail("Expected EJBAccessException due to bad password not thrown. (EJB 3.1 FR 17.6.9)");
        } catch (EJBAccessException ignored) {
        } finally {
            lc.logout();
        }
    }

    @Test
    public void testAuthenticatedCall() throws Exception {
View Full Code Here

        try {
            assertTrue(entryBean.doIHaveRole("Users"));
            assertTrue(entryBean.doIHaveRole("Role1"));
            assertFalse(entryBean.doIHaveRole("Role2"));
        } finally {
            lc.logout();
        }
    }

    @Test
    public void testICIR_TwoBeans() throws Exception {
View Full Code Here

            response = entryBean.doubleDoIHaveRole("Role2");
            assertFalse(response[0]);
            assertFalse(response[1]);
        } finally {
            lc.logout();
        }
    }

    @Test
    public void testICIR_TwoBeans_ReAuth() throws Exception {
View Full Code Here

            response = entryBean.doubleDoIHaveRole("Role2", "user2", "password2");
            assertFalse(response[0]);
            assertTrue(response[1]);
        } finally {
            lc.logout();
        }
    }

    @Test
    public void testICIR_ViaServlet() throws Exception {
View Full Code Here

                Assert.fail("Call to toBeInvokedByRole2() was expected to fail");
            } catch (EJBAccessException ejbae) {
                // expected
            }
        } finally {
            lc.logout();
        }

        // login as user2 and test
        lc = Util.getCLMLoginContext("user2", "password2");
        lc.login();
View Full Code Here

                Assert.fail("Call to toBeInvokedOnlyByRole1() was expected to fail");
            } catch (EJBAccessException ejbae) {
                // expected
            }
        } finally {
            lc.logout();
        }


    }
}
View Full Code Here

        try {
            String[] response = entryBean.doubleWhoAmI();
            assertEquals("user1", response[0]);
            assertEquals("anonymous", response[1]); //Unless a run-as-principal configuration has been done, you cannot expect a principal
        } finally {
            lc.logout();
        }
    }

    @Test
    public void testRunAsICIR_TwoBeans() throws Exception {
View Full Code Here

            response = entryBean.doubleDoIHaveRole("Role2");
            assertFalse(response[0]);
            assertTrue(response[1]);
        } finally {
            lc.logout();
        }

        lc = Util.getCLMLoginContext("user2", "password2");
        lc.login();
        try {
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.