Package org.apache.shiro.authc

Examples of org.apache.shiro.authc.AuthenticationInfo


    final User blueUser = mock(User.class);
    when(blueUser.getUserId()).thenReturn("joe");
    when(redUserManager.getUser("joe")).thenReturn(redUser);
    when(blueUserManager.getUser("joe")).thenReturn(blueUser);

    final AuthenticationInfo auinfo = testSubject.getAuthenticationInfo(new RutAuthAuthenticationToken("Some-Header",
        "joe", "localhost"));

    assertThat(auinfo, notNullValue());
    assertThat(auinfo.getPrincipals().getPrimaryPrincipal().toString(), equalTo("joe"));
    assertThat(auinfo.getPrincipals().getRealmNames(), hasItems("RED", "BLUE"));
  }
View Full Code Here


    final User redUser = mock(User.class);
    when(redUser.getUserId()).thenReturn("joe");
    when(redUserManager.getUser("joe")).thenReturn(redUser);
    when(blueUserManager.getUser("joe")).thenThrow(UserNotFoundException.class);

    final AuthenticationInfo auinfo = testSubject.getAuthenticationInfo(new RutAuthAuthenticationToken("Some-Header",
        "joe", "localhost"));

    assertThat(auinfo, notNullValue());
    assertThat(auinfo.getPrincipals().getPrimaryPrincipal().toString(), equalTo("joe"));
    assertThat(auinfo.getPrincipals().getRealmNames(), hasItems("RED"));
  }
View Full Code Here

  public void testSuccessfulAuthentication()
      throws Exception
  {
    final Realm realm = this.lookup(Realm.class, "LdapAuthenticatingRealm");
    final UsernamePasswordToken upToken = new UsernamePasswordToken("brianf", "brianf123");
    final AuthenticationInfo ai = realm.getAuthenticationInfo(upToken);
    assertEquals("brianf123".toCharArray(), ai.getCredentials());
  }
View Full Code Here

  public void testAuthenticate()
      throws Exception
  {
    KenaiRealm kenaiRealm = this.getRealm();

    AuthenticationInfo info = kenaiRealm.getAuthenticationInfo(new UsernamePasswordToken(username, password));
    Assert.assertNotNull(info);
  }
View Full Code Here

  public void testSuccessfulAuthentication()
      throws Exception
  {

    final UsernamePasswordToken upToken = new UsernamePasswordToken("brianf", "brianf123");
    final AuthenticationInfo ai = realm.getAuthenticationInfo(upToken);
    assertEquals("brianf123".toCharArray(), ai.getCredentials());
  }
View Full Code Here

              + "]");
        }

        try {
          // try to login
          AuthenticationInfo info = realm.getAuthenticationInfo(token);
          // just make sure are ducks are in a row
          // return the first successful login.
          if (info != null) {
            return info;
          }
View Full Code Here

  {
    buildTestAuthenticationConfig(CUser.STATUS_ACTIVE);

    UsernamePasswordToken upToken = new UsernamePasswordToken("username", "password");

    AuthenticationInfo ai = realm.getAuthenticationInfo(upToken);

    String password = new String((char[]) ai.getCredentials());

    assertThat(this.passwordService.passwordsMatch("password", password), is(true));
  }
View Full Code Here

    configurationManager.createUser(user, clearPassword, roles);

    UsernamePasswordToken upToken = new UsernamePasswordToken("testCreateWithPassowrdEmailUserId", clearPassword);

    AuthenticationInfo ai = realm.getAuthenticationInfo(upToken);

    String password = new String((char[]) ai.getCredentials());

    assertThat(this.passwordService.passwordsMatch(clearPassword, password), is(true));
  }
View Full Code Here

    String password = "password";
    String username = "username";
    buildLegacyTestAuthenticationConfig(password);

    UsernamePasswordToken upToken = new UsernamePasswordToken(username, password);
    AuthenticationInfo ai = realm.getAuthenticationInfo(upToken);
    CUser updatedUser = this.configurationManager.readUser(username);
    String hash = new String((char[]) ai.getCredentials());

    assertThat(this.passwordService.passwordsMatch(password, hash), is(true));
    assertThat(this.passwordService.passwordsMatch(password, updatedUser.getPassword()), is(true));
  }
View Full Code Here

   * @return true if credentials match, false otherwise
   */
  private boolean isValidCredentials(UsernamePasswordToken token, CUser user) {
    boolean credentialsValid = false;

    AuthenticationInfo info = this.createAuthenticationInfo(user);
    CredentialsMatcher matcher = this.getCredentialsMatcher();
    if (matcher != null) {
      if (matcher.doCredentialsMatch(token, info)) {
        credentialsValid = true;
      }
View Full Code Here

TOP

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

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.