Examples of UsernamePasswordAuthentication


Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

    return (TEST_USERNAME.equals(username) || anonUser.getName().equals(username)) ? true : false;
  }

  public User authenticate(Authentication authentication) throws AuthenticationFailedException {
    if(UsernamePasswordAuthentication.class.isAssignableFrom(authentication.getClass())) {
      UsernamePasswordAuthentication upAuth = (UsernamePasswordAuthentication) authentication;

      if(TEST_USERNAME.equals(upAuth.getUsername()) && TEST_PASSWORD.equals(upAuth.getPassword())) {
        return testUser;
      }

      if(anonUser.getName().equals(upAuth.getUsername())) {
        return anonUser;
      }
    } else if(AnonymousAuthentication.class.isAssignableFrom(authentication.getClass())) {
      return anonUser;
    }
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

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

*
*/
public class UsernamePasswordAuthenticationTest extends TestCase {

    public void testConstructor() {
        UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication(
                "user", "pass");

        assertEquals("user", auth.getUsername());
        assertEquals("pass", auth.getPassword());
    }
View Full Code Here

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

        assertEquals("user", auth.getUsername());
        assertEquals("pass", auth.getPassword());
    }

    public void testConstructorNullUsername() {
        UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication(
                null, "pass");

        assertNull(auth.getUsername());
        assertEquals("pass", auth.getPassword());
    }
View Full Code Here

Examples of org.apache.ftpserver.usermanager.UsernamePasswordAuthentication

        assertNull(auth.getUsername());
        assertEquals("pass", auth.getPassword());
    }

    public void testConstructorNullPassword() {
        UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication(
                "user", null);

        assertEquals("user", auth.getUsername());
        assertNull(auth.getPassword());
    }
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
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.