DefaultAuthentication.java 1.88 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
5
6
7
import emu.grasscutter.auth.DefaultAuthenticators.*;
import emu.grasscutter.server.http.objects.ComboTokenResJson;
import emu.grasscutter.server.http.objects.LoginResultJson;

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

KingRainbow44's avatar
KingRainbow44 committed
10
11
12
13
14
15
16
17
/**
 * 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
18
    private final ExternalAuthenticator externalAuthenticator = new ExternalAuthentication();
KingRainbow44's avatar
KingRainbow44 committed
19
20
21
22
23
24
25
26
27
28
    
    @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.
    }
29
30
31
32
33
34
    
    @Override
    public boolean verifyUser(String details) {
        Grasscutter.getLogger().info(translate("dispatch.authentication.default_unable_to_verify"));
        return false;
    }
KingRainbow44's avatar
KingRainbow44 committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

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

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