私はapache shiroを使用してユーザーを認証していますが、私のファインダー機能が正常に動作しているかどうかを確認するために私は(アプリケーションの実行時にレコードが削除され、SQL文を使用していないEclipseLinkの?)ユーザーにレコードを追加EclipseLink JPAユーザー名/パスワード検索でアプリを実行するとレコードが削除される
ここで私は、ユーザー名で単一のユーザーを取得しようとしている方法です:
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文を書き込むためですか?
あなたの質問は何も分かりません。おそらく何が起こるかを説明し、最高のログを含めるようにしてください。 – James
私はこれをやり終えると、正常に動作していることがわかりましたが、テーブルを破棄して実行ごとに作成するプロパティが設定されていました。 – Warz