Whitelist для RejectAuthProvider

This commit is contained in:
Gravit 2018-12-26 16:41:11 +07:00
parent 0862e3c541
commit 4c1fae008f
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -1,6 +1,8 @@
package ru.gravit.launchserver.auth.provider;
import ru.gravit.launchserver.auth.AuthException;
import ru.gravit.utils.helper.SecurityHelper;
public final class RejectAuthProvider extends AuthProvider {
public RejectAuthProvider() {
}
@ -10,9 +12,20 @@ public RejectAuthProvider(String message) {
}
private String message;
private String[] whitelist;
@Override
public AuthProviderResult auth(String login, String password, String ip) throws AuthException {
if(whitelist != null)
{
for(String username : whitelist)
{
if(login.equals(username))
{
return new AuthProviderResult(login, SecurityHelper.randomStringToken());
}
}
}
return authError(message);
}