DefaultAuthentication.java 1.91 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();
KingRainbow44's avatar
KingRainbow44 committed
20
21
22
23
24
25
26
27
28
29
    
    @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.
    }
30

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

    @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
51
52
53
54
55

    @Override
    public ExternalAuthenticator getExternalAuthenticator() {
        return this.externalAuthenticator;
    }
KingRainbow44's avatar
KingRainbow44 committed
56
}