Examples of UsernamePasswordAuthentication


Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

                Authentication auth;
                if (anonymous) {
                    auth = new AnonymousAuthentication(userMetadata);
                } else {
                    auth = new UsernamePasswordAuthentication(userName,
                            password, userMetadata);
                }

                authenticatedUser = userManager.authenticate(auth);
            } catch (AuthenticationFailedException e) {
View Full Code Here

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

        userManager = createUserManagerFactory().createUserManager();
    }

    public void testAuthenticate() throws Exception {
        assertNotNull(userManager
                .authenticate(new UsernamePasswordAuthentication("user1", "pw1")));
    }
View Full Code Here

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

                .authenticate(new UsernamePasswordAuthentication("user1", "pw1")));
    }

    public void testAuthenticateWrongPassword() throws Exception {
        try {
            userManager.authenticate(new UsernamePasswordAuthentication(
                    "user1", "foo"));
            fail("Must throw AuthenticationFailedException");
        } catch (AuthenticationFailedException e) {
            // ok
        }
View Full Code Here

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

        }
    }

    public void testAuthenticateUnknownUser() throws Exception {
        try {
            userManager.authenticate(new UsernamePasswordAuthentication("foo",
                    "foo"));
            fail("Must throw AuthenticationFailedException");
        } catch (AuthenticationFailedException e) {
            // ok
        }
View Full Code Here

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

        }
    }

    public void testAuthenticateEmptyPassword() throws Exception {
        assertNotNull(userManager
                .authenticate(new UsernamePasswordAuthentication("user3", "")));
    }
View Full Code Here

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

                .authenticate(new UsernamePasswordAuthentication("user3", "")));
    }

    public void testAuthenticateNullPassword() throws Exception {
        assertNotNull(userManager
                .authenticate(new UsernamePasswordAuthentication("user3", null)));
    }
View Full Code Here

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

    public static class FooAuthentication implements Authentication {
    }

    public void testAuthenticateNullUser() throws Exception {
        try {
            userManager.authenticate(new UsernamePasswordAuthentication(null,
                    "foo"));
            fail("Must throw AuthenticationFailedException");
        } catch (AuthenticationFailedException e) {
            // ok
        }
View Full Code Here

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

        assertEquals(getMaxLoginNumber(user), getMaxLoginNumber(actualUser));
        assertEquals(getMaxLoginPerIP(user), getMaxLoginPerIP(actualUser));
        assertEquals(getMaxUploadRate(user), getMaxUploadRate(actualUser));
       
        // verify the password
        assertNotNull(userManager.authenticate(new UsernamePasswordAuthentication("newuser", "newpw")));

        try {
            userManager.authenticate(new UsernamePasswordAuthentication("newuser", "dummy"));
            fail("Must throw AuthenticationFailedException");
        } catch(AuthenticationFailedException e) {
            // ok
        }

        // save without updating the users password (password==null)
        userManager.save(user);

        assertNotNull(userManager.authenticate(new UsernamePasswordAuthentication("newuser", "newpw")));
        try {
            userManager.authenticate(new UsernamePasswordAuthentication("newuser", "dummy"));
            fail("Must throw AuthenticationFailedException");
        } catch(AuthenticationFailedException e) {
            // ok
        }

              
        // save and update the users password
        user.setPassword("newerpw");
        userManager.save(user);
       
        assertNotNull(userManager.authenticate(new UsernamePasswordAuthentication("newuser", "newerpw")));

        try {
            userManager.authenticate(new UsernamePasswordAuthentication("newuser", "newpw"));
            fail("Must throw AuthenticationFailedException");
        } catch(AuthenticationFailedException e) {
            // ok
        }
View Full Code Here

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

        assertEquals(getMaxLoginNumber(user), getMaxLoginNumber(actualUser));
        assertEquals(getMaxLoginPerIP(user), getMaxLoginPerIP(actualUser));
        assertEquals(getMaxUploadRate(user), getMaxUploadRate(actualUser));
       
        // verify the password
        assertNotNull(newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "newpw")));

        try {
            newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "dummy"));
            fail("Must throw AuthenticationFailedException");
        } catch(AuthenticationFailedException e) {
            // ok
        }

        // save without updating the users password (password==null)
        userManager.save(user);

        newUserManager = createUserManagerFactory().createUserManager();
        assertNotNull(newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "newpw")));
        try {
            newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "dummy"));
            fail("Must throw AuthenticationFailedException");
        } catch(AuthenticationFailedException e) {
            // ok
        }

              
        // save and update the users password
        user.setPassword("newerpw");
        userManager.save(user);
       
        newUserManager = createUserManagerFactory().createUserManager();
        assertNotNull(newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "newerpw")));

        try {
            newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "newpw"));
            fail("Must throw AuthenticationFailedException");
        } catch(AuthenticationFailedException e) {
            // ok
        }
View Full Code Here

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

     * User authentication.
     */
    public User authenticate(Authentication authentication)
            throws AuthenticationFailedException {
        if (authentication instanceof UsernamePasswordAuthentication) {
            UsernamePasswordAuthentication upauth = (UsernamePasswordAuthentication) authentication;

            String user = upauth.getUsername();
            String password = upauth.getPassword();

            if (user == null) {
                throw new AuthenticationFailedException("Authentication failed");
            }

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.