Created the ResponderAuthentication to authenticate a specific request

This commit is contained in:
mathias 2021-10-01 18:52:32 +02:00
parent 5b7e4e3de0
commit 66825c9a0e
No known key found for this signature in database
GPG Key ID: 8950DF62139C852A

View File

@ -0,0 +1,30 @@
package de.gnmyt.autoresponder.authentication;
import com.sun.net.httpserver.BasicAuthenticator;
public class ResponderAuthentication extends BasicAuthenticator {
private final AuthenticationDetails details;
/**
* Constructor of the {@link ResponderAuthentication}
*
* @param details Your authentication details from the {@link de.gnmyt.autoresponder.SimpleAutoResponder}
*/
public ResponderAuthentication(AuthenticationDetails details) {
super("/");
this.details = details;
}
/**
* Checks the credentials of the request
*
* @param username The name of the user from the request
* @param password The password of the user from the request
* @return <code>true</code> if the provided credentials are correct, otherwise <code>false</code>
*/
@Override
public boolean checkCredentials(String username, String password) {
return details.getUsername().equals(username) && details.getPassword().equals(password);
}
}