Package org.apache.shiro.authc

Examples of org.apache.shiro.authc.AuthenticationToken


  }

  private AuthenticationToken createAuthenticationToken(ServletRequest request, ServletResponse response) {
    for (AuthenticationTokenFactory factory : factories) {
      try {
        AuthenticationToken token = factory.createToken(request, response);
        if (token != null) {
          getLogger().debug("Token '{}' created by {}", token, factory);
          return token;
        }
      }
View Full Code Here


  @Test
  public void testValidAuthentication()
      throws Exception
  {
    SecuritySystem plexusSecurity = this.lookup(SecuritySystem.class);
    AuthenticationToken token = new UsernamePasswordToken("admin-simple", "admin123");
    AuthenticationInfo authInfo = plexusSecurity.authenticate(token);

    // check
    Assert.assertNotNull(authInfo);
  }
View Full Code Here

  @Test
  public void testInvalidPasswordAuthentication()
      throws Exception
  {
    SecuritySystem plexusSecurity = this.lookup(SecuritySystem.class);
    AuthenticationToken token = new UsernamePasswordToken("admin-simple", "INVALID");

    try {
      plexusSecurity.authenticate(token);
    }
    catch (AuthenticationException e) {
View Full Code Here

  @Test
  public void testInvalidUserAuthentication()
      throws Exception
  {
    SecuritySystem plexusSecurity = this.lookup(SecuritySystem.class);
    AuthenticationToken token = new UsernamePasswordToken("INVALID", "INVALID");

    try {
      plexusSecurity.authenticate(token);
    }
    catch (AuthenticationException e) {
View Full Code Here

        HttpServletResponse response = createMock(HttpServletResponse.class);
       
        replay(request);
        replay(response);
       
    AuthenticationToken token = testFilter.createToken(request, response);
    assertNotNull(token);
    assertTrue("Token is not a username and password token.", token instanceof UsernamePasswordToken);
    assertEquals("", token.getPrincipal());
   
    verify(request);
    verify(response);
    }
View Full Code Here

        HttpServletResponse response = createMock(HttpServletResponse.class);
       
        replay(request);
        replay(response);
       
    AuthenticationToken token = testFilter.createToken(request, response);
    assertNotNull(token);
    assertTrue("Token is not a username and password token.", token instanceof UsernamePasswordToken);
    assertEquals("", token.getPrincipal());
   
    verify(request);
    verify(response);
    }
View Full Code Here

        HttpServletResponse response = createMock(HttpServletResponse.class);
       
        replay(request);
        replay(response);
       
    AuthenticationToken token = testFilter.createToken(request, response);
    assertNotNull(token);
    assertTrue("Token is not a username and password token.", token instanceof UsernamePasswordToken);
   
    UsernamePasswordToken upToken = (UsernamePasswordToken) token;
    assertEquals("pedro", upToken.getUsername());
View Full Code Here

        HttpServletResponse response = createMock(HttpServletResponse.class);

        replay(request);
        replay(response);

    AuthenticationToken token = testFilter.createToken(request, response);
    assertNotNull(token);
    assertTrue("Token is not a username and password token.", token instanceof UsernamePasswordToken);

    UsernamePasswordToken upToken = (UsernamePasswordToken) token;
    assertEquals("pedro", upToken.getUsername());
View Full Code Here

    public static final String PERMISSIVE = "permissive";

    //TODO - complete JavaDoc

    protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception {
        AuthenticationToken token = createToken(request, response);
        if (token == null) {
            String msg = "createToken method implementation returned null. A valid non-null AuthenticationToken " +
                    "must be created in order to execute a login attempt.";
            throw new IllegalStateException(msg);
        }
View Full Code Here

    }

    @Test
    public void testConfigure() {
        final MockRealm mockRealm = createMock(MockRealm.class);
        AuthenticationToken authToken = createMock(AuthenticationToken.class);
        AuthenticationInfo info = new SimpleAuthenticationInfo("mockUser", "password", "mockRealm");

        expect(mockRealm.supports(authToken)).andReturn(true);
        expect(mockRealm.getAuthenticationInfo(authToken)).andReturn(info);
View Full Code Here

TOP

Related Classes of org.apache.shiro.authc.AuthenticationToken

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.