DefaultAuthentication.java 2.11 KB
Newer Older
KingRainbow44's avatar
KingRainbow44 committed
1
2
package emu.grasscutter.auth;

3
import emu.grasscutter.Grasscutter;
KingRainbow44's avatar
KingRainbow44 committed
4
import emu.grasscutter.auth.DefaultAuthenticators.*;
5
import emu.grasscutter.game.Account;
KingRainbow44's avatar
KingRainbow44 committed
6
7
8
import emu.grasscutter.server.http.objects.ComboTokenResJson;
import emu.grasscutter.server.http.objects.LoginResultJson;

9
10
import static emu.grasscutter.utils.Language.translate;

KingRainbow44's avatar
KingRainbow44 committed
11
12
13
14
15
16
17
18
/**
 * The default Grasscutter authentication implementation.
 * Allows all users to access any account.
 */
public final class DefaultAuthentication implements AuthenticationSystem {
    private final Authenticator<LoginResultJson> passwordAuthenticator = new PasswordAuthenticator();
    private final Authenticator<LoginResultJson> tokenAuthenticator = new TokenAuthenticator();
    private final Authenticator<ComboTokenResJson> sessionKeyAuthenticator = new SessionKeyAuthenticator();
KingRainbow44's avatar
KingRainbow44 committed
19
    private final ExternalAuthenticator externalAuthenticator = new ExternalAuthentication();
20
    private final OAuthAuthenticator oAuthAuthenticator = new OAuthAuthentication();
KingRainbow44's avatar
KingRainbow44 committed
21
22
23
24
25
26
27
28
29
30
    
    @Override
    public void createAccount(String username, String password) {
        // Unhandled. The default authenticator doesn't store passwords.
    }

    @Override
    public void resetPassword(String username) {
        // Unhandled. The default authenticator doesn't store passwords.
    }
31

32
    @Override
33
    public Account verifyUser(String details) {
Luke H-W's avatar
Luke H-W committed
34
        Grasscutter.getLogger().info(translate("messages.dispatch.authentication.default_unable_to_verify"));
35
        return null;
36
    }
KingRainbow44's avatar
KingRainbow44 committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

    @Override
    public Authenticator<LoginResultJson> getPasswordAuthenticator() {
        return this.passwordAuthenticator;
    }

    @Override
    public Authenticator<LoginResultJson> getTokenAuthenticator() {
        return this.tokenAuthenticator;
    }

    @Override
    public Authenticator<ComboTokenResJson> getSessionKeyAuthenticator() {
        return this.sessionKeyAuthenticator;
    }
KingRainbow44's avatar
KingRainbow44 committed
52
53
54
55
56

    @Override
    public ExternalAuthenticator getExternalAuthenticator() {
        return this.externalAuthenticator;
    }
57
58
59
60
61

    @Override
    public OAuthAuthenticator getOAuthAuthenticator() {
        return this.oAuthAuthenticator;
    }
KingRainbow44's avatar
KingRainbow44 committed
62
}