0

ユーザーを認証するために apache shiro を使用しています。ユーザー名をコンソールに出力して、ファインダー機能が正常に動作しているかどうかを確認したいのですが、ユーザーにレコードを追加したときのようです (eclipseLink ではなく SQL ステートメントを使用)。 、アプリケーションの実行時にレコードが削除されますか?)

ユーザー名で単一のユーザーを取得しようとしている方法は次のとおりです。

protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException {
    UsernamePasswordToken token = (UsernamePasswordToken) authcToken;
    Map<String, String> map = new HashMap<String, String>();
    String tempUsername = token.getUsername();
    String password = "";
    Users user;

    // Null username is invalid
    if (tempUsername == null) {
        throw new AccountException("Null usernames are not allowed by this realm.");
    }
    AuthenticationInfo info = null;
    // this will query and find the users by the specified username and then return us the single result
    user = getAuthorizedUser(Users.findUsersesByUsernameEquals(tempUsername));
    System.out.print(user.getUsername());
    System.out.println("yea the username = ");
    password = user.getPassword();
    info = buildAuthenticationInfo(tempUsername, password.toCharArray());
    return info;
}
/*Build the required authentication info; Replace with SaltAuthenticationInfo for salted passwords*/
protected AuthenticationInfo buildAuthenticationInfo(String username, char[] password) {
          return new SimpleAuthenticationInfo(username, password, getName());
}

protected Users getAuthorizedUser(TypedQuery<Users> q){
    System.out.println("working authentication");

      return q.getSingleResult(); 
}

これは、JPA を使用してユーザーを永続化して追加するのではなく、アプリケーションの外部で SQL ステートメントを作成しているためですか?

4

1 に答える 1

0

このプロパティを無効にしました<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>

これは私のテストレコードを削除し、私の問題を解決しました。

于 2011-12-21T17:41:19.913 に答える