Package org.apache.openejb.core.security.jaas

Examples of org.apache.openejb.core.security.jaas.UsernamePasswordCallbackHandler


    public UUID login(String realmName, String username, String password) throws LoginException {
        if (realmName == null){
            realmName = getRealmName();
        }
        LoginContext context = new LoginContext(realmName, new UsernamePasswordCallbackHandler(username, password));
        context.login();

        Subject subject = context.getSubject();

        return registerSubject(subject);
View Full Code Here


  }

    @Test
    public void testLogin() throws LoginException {
        LoginContext context = new LoginContext("SQLLogin",
        new UsernamePasswordCallbackHandler("jonathan", "secret"));
        context.login();

        Subject subject = context.getSubject();

        assertEquals("Should have three principals", 3,
View Full Code Here

    }

    @Test(expected = FailedLoginException.class)
    public void testBadUseridLogin() throws LoginException {
        LoginContext context = new LoginContext("SQLLogin",
        new UsernamePasswordCallbackHandler("nobody", "secret"));
        context.login();
    }
View Full Code Here

    }

    @Test(expected = FailedLoginException.class)
    public void testBadPWLogin() throws LoginException {
        LoginContext context = new LoginContext("SQLLogin",
        new UsernamePasswordCallbackHandler("jonathan", "badpass"));
        context.login();
    }
View Full Code Here

        }
        //System.out.println("Path to login config: " + path);
    }

    public void testLogin() throws LoginException {
        LoginContext context = new LoginContext("PropertiesLogin", new UsernamePasswordCallbackHandler("jonathan", "secret"));
        context.login();

        Subject subject = context.getSubject();

        assertEquals("Should have three principals", 3, subject.getPrincipals().size());
View Full Code Here

        assertEquals("Should have zero principals", 0, subject.getPrincipals().size());
    }

    public void testBadUseridLogin() throws Exception {
        LoginContext context = new LoginContext("PropertiesLogin", new UsernamePasswordCallbackHandler("nobody", "secret"));
        try {
            context.login();
            fail("Should have thrown a FailedLoginException");
        } catch (FailedLoginException doNothing) {
        }
View Full Code Here

        }

    }

    public void testBadPWLogin() throws Exception {
        LoginContext context = new LoginContext("PropertiesLogin", new UsernamePasswordCallbackHandler("jonathan", "badpass"));
        try {
            context.login();
            fail("Should have thrown a FailedLoginException");
        } catch (FailedLoginException doNothing) {
        }
View Full Code Here

    public UUID login(String realmName, String username, String password) throws LoginException {
        if (realmName == null){
            realmName = getRealmName();
        }
        LoginContext context = new LoginContext(realmName, new UsernamePasswordCallbackHandler(username, password));
        context.login();

        Subject subject = context.getSubject();

        UUID token =  registerSubject(subject);
View Full Code Here

    @Override
    public UUID login(String realmName, final String username, final String password) throws LoginException {
        if (realmName == null) {
            realmName = getRealmName();
        }
        final LoginContext context = new LoginContext(realmName, new UsernamePasswordCallbackHandler(username, password));
        context.login();

        final Subject subject = context.getSubject();

        final UUID token = registerSubject(subject);
View Full Code Here

        return beans;
    }

    @Test
    public void testLogin() throws LoginException {
        final LoginContext context = new LoginContext("CDI", new UsernamePasswordCallbackHandler("foo", ""));
        context.login();

        final Subject subject = context.getSubject();

        assertEquals(1, subject.getPrincipals().size());
View Full Code Here

TOP

Related Classes of org.apache.openejb.core.security.jaas.UsernamePasswordCallbackHandler

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.