io.muserver.rest.UserPassAuthenticator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mu-server Show documentation
Show all versions of mu-server Show documentation
A simple but powerful web server framework
package io.muserver.rest;
import javax.ws.rs.core.SecurityContext;
import java.security.Principal;
/**
* An authenticator used by {@link BasicAuthSecurityFilter} which can look up a user based on a username and password.
*/
public interface UserPassAuthenticator {
/**
* Looks up a user.
* It is required that the user object implements the Principal interface, so if you have custom classes for
* users you may need to wrap them to include this.
* You can later get the principle from a {@link javax.ws.rs.core.SecurityContext} (using the @Context
* annotation on a REST method) and cast {@link SecurityContext#getUserPrincipal()} to your custom class.
* @param username The username
* @param password The password
* @return The user, or null
if the credentials are invalid.
*/
Principal authenticate(String username, String password);
}