Package javax.security.auth.login

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


    public void testNullUserLogin() throws Exception {
        LoginContext context = new LoginContext(SIMPLE_REALM, new UsernamePasswordCallback(null, "starcraft"));

        try {
            context.login();
            fail("Should not allow this login with null username");
        } catch (LoginException e) {
        }
    }
View Full Code Here


    public void testBadUserLogin() throws Exception {
        LoginContext context = new LoginContext(SIMPLE_REALM, new UsernamePasswordCallback("bad", "starcraft"));
   
        try {
            context.login();
            fail("Should not allow this login with bad username");
        } catch (LoginException e) {
        }
    }
View Full Code Here

    public void testNullPasswordLogin() throws Exception {
        LoginContext context = new LoginContext(SIMPLE_REALM, new UsernamePasswordCallback("alan", null));

        try {
            context.login();
            fail("Should not allow this login with null password");
        } catch (LoginException e) {
        }
    }
View Full Code Here

    public void testBadPasswordLogin() throws Exception {
        LoginContext context = new LoginContext(SIMPLE_REALM, new UsernamePasswordCallback("alan", "bad"));

        try {
            context.login();
            fail("Should not allow this login with bad password");
        } catch (LoginException e) {
        }
    }
View Full Code Here

    }

    public void testNoPrincipalsAddedOnFailure() throws Exception {
        LoginContext context = new LoginContext(COMPLEX_REALM, new UsernamePasswordCallback("alan", "bad"));

        context.login();
        Subject subject = context.getSubject();
        assertTrue("expected non-null subject", subject != null);
        assertEquals("Principals added upon failed login", 0, subject.getPrincipals().size());
        context.logout();
    }
View Full Code Here

    }

    public void testLogoutWithReadOnlySubject() throws Exception {
        LoginContext context = new LoginContext(SIMPLE_REALM, new UsernamePasswordCallback("alan", "starcraft"));

        context.login();
        Subject subject = context.getSubject();

        assertTrue("expected non-null subject", subject != null);

        subject.setReadOnly();
View Full Code Here

    }

    public void testLogin() throws Exception {
        LoginContext context = new LoginContext(COMPLEX_REALM, new UsernamePasswordCallback(username, password));

        context.login();
        Subject subject = context.getSubject();

        assertTrue("expected non-null subject", subject != null);
        assertEquals("Principals", 0, subject.getPrincipals().size());
        assertEquals("Private credentials", 1, subject.getPrivateCredentials().size());
View Full Code Here

    }

    public void testNullUserLogin() throws Exception {
        LoginContext context = new LoginContext(COMPLEX_REALM, new UsernamePasswordCallback(null, password));

        context.login();
        Subject subject = context.getSubject();

        assertTrue("expected non-null subject", subject != null);
        assertEquals("Principals", 0, subject.getPrincipals().size());
        assertEquals("Private credentials", 0, subject.getPrivateCredentials().size());
View Full Code Here

    }

    public void testNullPasswordLogin() throws Exception {
        LoginContext context = new LoginContext(COMPLEX_REALM, new UsernamePasswordCallback(username, null));

        context.login();
        Subject subject = context.getSubject();

        assertTrue("expected non-null subject", subject != null);
        assertEquals("Principals", 0, subject.getPrincipals().size());
        assertEquals("Private credentials", 0, subject.getPrivateCredentials().size());
View Full Code Here

    }

    public void testLogoutWithReadOnlySubject() throws Exception {
        LoginContext context = new LoginContext(COMPLEX_REALM, new UsernamePasswordCallback(username, password));

        context.login();
        Subject subject = context.getSubject();

        assertTrue("expected non-null subject", subject != null);

        subject.setReadOnly();
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.