2

私はログイン ページを wicket by Java で作成していますが、できるだけ一般的に書きたいので、C++ で Function Pointer として有名な関数をクラスに渡す必要があります。クラスは次のとおりです。

class LoginForm extends Form
{

    public LoginForm(String id,TextField username,TextField password,WebResponse webResponse)
    {
        super(id);
    }

    @Override
    public void onSubmit()
    {
        String password = Login.this.getPassword();
        String userId = Login.this.getUserId();
        String role = authenticate(userId, password);
        if (role != null)
        {
            if (Login.this.getSave())
            {
                utilities.CreateCookie("Username", userId, false, 1209600, (WebResponse) getRequestCycle().getResponse());
                utilities.CreateCookie("Password", password, false, 1209600, (WebResponse) getRequestCycle().getResponse());
            }
            User loggedInUser = new User(userId, role);
            WiaSession session = (WiaSession) getSession();
            session.setUser(loggedInUser);
            if (!continueToOriginalDestination())
            {
                setResponsePage(UserHome.class);
            }
        }
        else
        {
            wrongUserPass.setVisible(true);
        }
    }
}

その関数はどこで認証されますか?

4

3 に答える 3

9

authenticateメソッドを定義する Interface を渡すだけです。

void DoSomething(IAuthenticationProvider authProvider) {
    // ...
    authProvider.authenticate();
}
于 2009-07-22T06:30:00.750 に答える
1

内部クラスを使用できます

于 2009-07-22T06:28:07.150 に答える