R - The type of the authentication request the class can handlepublic abstract class ExternalKenmeiApiAuthenticator<R extends AuthenticationRequest> extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
JSON_PARAM_EMAIL
json parameter for the email of the user
|
static String |
JSON_PARAM_FIRST_NAME
json parameter for the first name
|
static String |
JSON_PARAM_LANG
json parameter for the language code
|
static String |
JSON_PARAM_LAST_NAME
json parameter for the last name
|
static String |
JSON_PARAM_LOGIN
json parameter for the login
|
static String |
JSON_PARAM_NAME
json parameter for the combined name
|
protected static String |
JSON_PARAM_USER_FOUND
json parameter for the user found flag.
|
| Constructor and Description |
|---|
ExternalKenmeiApiAuthenticator(String name,
boolean httpClientReusable) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertFieldsExist(org.codehaus.jackson.node.ObjectNode jsonNode,
String... fieldNames)
Test whether a provided JSON object has all the given members and throw an exception if not.
|
ExternalUserVO |
authenticate(R authenticationRequest)
Does the authentication.
|
protected void |
configureHttpClient(org.apache.http.impl.client.AbstractHttpClient httpClient,
R authenticationRequest)
Hook to be overwritten to configure the http client prior to executing a method.
|
protected abstract org.apache.http.client.methods.HttpRequestBase |
createMethod(R authenticationRequest,
boolean isQuerying) |
protected abstract ExternalUserVO |
createUserVO()
Creates a prepared value object.
|
protected abstract void |
extractUserData(org.codehaus.jackson.node.ObjectNode jsonUser,
ExternalUserVO userVO)
Copies user data from a JSON object to a value object.
|
protected abstract String |
getAuthenticationApiUrl() |
protected boolean |
isValidJsonUser(org.codehaus.jackson.node.ObjectNode jsonUser)
Can be used to validate the received user after receiving it from the foreign system.
|
protected ExternalUserVO |
prepareDefaultUserVO()
Creates a prepared value object with all update options set to true.
|
ExternalUserVO |
queryUserData(R authenticationRequest)
Queries the external system for data about a user
|
protected abstract void |
validateRetrievedUser(R authenticationRequest,
ExternalUserVO retrievedVO)
Method is called after an authentication call has been made.
|
public static final String JSON_PARAM_EMAIL
public static final String JSON_PARAM_LAST_NAME
public static final String JSON_PARAM_FIRST_NAME
public static final String JSON_PARAM_NAME
public static final String JSON_PARAM_LOGIN
public static final String JSON_PARAM_LANG
protected static final String JSON_PARAM_USER_FOUND
public ExternalKenmeiApiAuthenticator(String name, boolean httpClientReusable)
name - name for logginghttpClientReusable - true if the client can be reused. If true #configureHttpClient(HttpClient)
is NOT called.protected void assertFieldsExist(org.codehaus.jackson.node.ObjectNode jsonNode,
String... fieldNames)
jsonNode - the JSON objectfieldNames - the names of the members the object has to haveorg.springframework.security.authentication.AuthenticationServiceException - in case one of the fields is missingpublic ExternalUserVO authenticate(R authenticationRequest)
authenticationRequest - the context holding all the parametersorg.springframework.security.authentication.BadCredentialsException - Thrown, when the provided credentials are wrong.org.springframework.security.authentication.AuthenticationServiceException - Thrown, when something else is wrong connecting the server.UnknownHostAuthenticationServiceException - Thrown on any "physical" communication problem with the foreign server.protected void configureHttpClient(org.apache.http.impl.client.AbstractHttpClient httpClient,
R authenticationRequest)
httpClientReusable is false.httpClient - the client to configureauthenticationRequest - the external auth for the currrent requestprotected abstract org.apache.http.client.methods.HttpRequestBase createMethod(R authenticationRequest, boolean isQuerying)
authenticationRequest - the authentication requestisQuerying - true if the request is not an authentication one but to get the user data of a
specific userprotected abstract ExternalUserVO createUserVO()
protected abstract void extractUserData(org.codehaus.jackson.node.ObjectNode jsonUser,
ExternalUserVO userVO)
throws org.springframework.security.authentication.AuthenticationServiceException
jsonUser - the JSON objectuserVO - the value objectorg.springframework.security.authentication.AuthenticationServiceException - in case the JSON object did not contain the required membersprotected abstract String getAuthenticationApiUrl()
protected boolean isValidJsonUser(org.codehaus.jackson.node.ObjectNode jsonUser)
jsonUser - The retrieved user as Json objectprotected ExternalUserVO prepareDefaultUserVO()
public ExternalUserVO queryUserData(R authenticationRequest)
authenticationRequest - the authentication requestprotected abstract void validateRetrievedUser(R authenticationRequest, ExternalUserVO retrievedVO)
authenticationRequest - the requestretrievedVO - the retrieved userCopyright © 2019 Communote team. All rights reserved.