Class RestAuthenticator
- java.lang.Object
-
- org.pac4j.core.util.InitializableObject
-
- org.pac4j.core.profile.definition.ProfileDefinitionAware<RestProfile>
-
- org.pac4j.http.credentials.authenticator.RestAuthenticator
-
- All Implemented Interfaces:
Authenticator<UsernamePasswordCredentials>
public class RestAuthenticator extends ProfileDefinitionAware<RestProfile> implements Authenticator<UsernamePasswordCredentials>
Authenticates against a REST API. The username/password are passed as a basic auth via a POST request, the JSON response is a user profile.- Since:
- 2.1.0
- Author:
- Jerome Leleu
-
-
Constructor Summary
Constructors Constructor Description RestAuthenticator()RestAuthenticator(String url)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbuildProfile(UsernamePasswordCredentials credentials, String body)protected StringcallRestApi(String username, String password)Return the body from the REST API, passing the username/pasword auth.com.fasterxml.jackson.databind.ObjectMappergetMapper()StringgetUrl()protected voidinternalInit()voidsetMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)voidsetUrl(String url)StringtoString()voidvalidate(UsernamePasswordCredentials credentials, WebContext context)-
Methods inherited from class org.pac4j.core.profile.definition.ProfileDefinitionAware
defaultProfileDefinition, getProfileDefinition, setProfileDefinition
-
Methods inherited from class org.pac4j.core.util.InitializableObject
init, isInitialized
-
-
-
-
Constructor Detail
-
RestAuthenticator
public RestAuthenticator()
-
RestAuthenticator
public RestAuthenticator(String url)
-
-
Method Detail
-
internalInit
protected void internalInit()
- Specified by:
internalInitin classInitializableObject
-
validate
public void validate(UsernamePasswordCredentials credentials, WebContext context)
- Specified by:
validatein interfaceAuthenticator<UsernamePasswordCredentials>
-
buildProfile
protected void buildProfile(UsernamePasswordCredentials credentials, String body)
-
callRestApi
protected String callRestApi(String username, String password)
Return the body from the REST API, passing the username/pasword auth. To be overridden using another HTTP client if necessary.- Parameters:
username- the usernamepassword- the password- Returns:
- the response body
-
getUrl
public String getUrl()
-
setUrl
public void setUrl(String url)
-
getMapper
public com.fasterxml.jackson.databind.ObjectMapper getMapper()
-
setMapper
public void setMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
-
-