Class FreeMarkerAccountProvider
- java.lang.Object
-
- org.keycloak.forms.account.freemarker.FreeMarkerAccountProvider
-
- All Implemented Interfaces:
AccountProvider
,Provider
public class FreeMarkerAccountProvider extends Object implements AccountProvider
- Author:
- Stian Thorgersen
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object>
attributes
protected List<Event>
events
protected boolean
eventsEnabled
protected FreeMarkerProvider
freeMarker
protected javax.ws.rs.core.HttpHeaders
headers
protected boolean
identityProviderEnabled
protected String
idTokenHint
protected List<FormMessage>
messages
protected MessageType
messageType
protected boolean
passwordSet
protected boolean
passwordUpdateSupported
protected javax.ws.rs.core.MultivaluedMap<String,String>
profileFormData
protected RealmModel
realm
protected String[]
referrer
protected KeycloakSession
session
protected List<UserSessionModel>
sessions
protected String
stateChecker
protected javax.ws.rs.core.Response.Status
status
protected javax.ws.rs.core.UriInfo
uriInfo
protected UserModel
user
-
Constructor Summary
Constructors Constructor Description FreeMarkerAccountProvider(KeycloakSession session)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
javax.ws.rs.core.Response
createResponse(AccountPages page)
protected String
formatMessage(FormMessage message, Properties messagesBundle, Locale locale)
protected Theme
getTheme()
Get Theme used for page rendering.protected void
handleMessages(Locale locale, Properties messagesBundle, Map<String,Object> attributes)
Handle messages to be shown on the page - set them to template attributesprotected Properties
handleThemeResources(Theme theme, Locale locale, Map<String,Object> attributes)
Load message bundle and place it intomsg
template attribute.protected javax.ws.rs.core.Response
processTemplate(Theme theme, AccountPages page, Map<String,Object> attributes, Locale locale)
Process FreeMarker template and prepare Response.AccountProvider
setAttribute(String key, String value)
AccountProvider
setError(javax.ws.rs.core.Response.Status status, String message, Object... parameters)
AccountProvider
setErrors(javax.ws.rs.core.Response.Status status, List<FormMessage> messages)
AccountProvider
setEvents(List<Event> events)
AccountProvider
setFeatures(boolean identityProviderEnabled, boolean eventsEnabled, boolean passwordUpdateSupported, boolean authorizationSupported)
AccountProvider
setHttpHeaders(javax.ws.rs.core.HttpHeaders httpHeaders)
AccountProvider
setIdTokenHint(String idTokenHint)
protected void
setMessage(MessageType type, String message, Object... parameters)
AccountProvider
setPasswordSet(boolean passwordSet)
AccountProvider
setProfileFormData(javax.ws.rs.core.MultivaluedMap<String,String> formData)
AccountProvider
setRealm(RealmModel realm)
AccountProvider
setReferrer(String[] referrer)
AccountProvider
setSessions(List<UserSessionModel> sessions)
AccountProvider
setStateChecker(String stateChecker)
AccountProvider
setSuccess(String message, Object... parameters)
AccountProvider
setUriInfo(javax.ws.rs.core.UriInfo uriInfo)
AccountProvider
setUser(UserModel user)
AccountProvider
setWarning(String message, Object... parameters)
-
-
-
Field Detail
-
user
protected UserModel user
-
status
protected javax.ws.rs.core.Response.Status status
-
realm
protected RealmModel realm
-
referrer
protected String[] referrer
-
stateChecker
protected String stateChecker
-
idTokenHint
protected String idTokenHint
-
sessions
protected List<UserSessionModel> sessions
-
identityProviderEnabled
protected boolean identityProviderEnabled
-
eventsEnabled
protected boolean eventsEnabled
-
passwordUpdateSupported
protected boolean passwordUpdateSupported
-
passwordSet
protected boolean passwordSet
-
session
protected KeycloakSession session
-
freeMarker
protected FreeMarkerProvider freeMarker
-
headers
protected javax.ws.rs.core.HttpHeaders headers
-
uriInfo
protected javax.ws.rs.core.UriInfo uriInfo
-
messages
protected List<FormMessage> messages
-
messageType
protected MessageType messageType
-
-
Constructor Detail
-
FreeMarkerAccountProvider
public FreeMarkerAccountProvider(KeycloakSession session)
-
-
Method Detail
-
setUriInfo
public AccountProvider setUriInfo(javax.ws.rs.core.UriInfo uriInfo)
- Specified by:
setUriInfo
in interfaceAccountProvider
-
setHttpHeaders
public AccountProvider setHttpHeaders(javax.ws.rs.core.HttpHeaders httpHeaders)
- Specified by:
setHttpHeaders
in interfaceAccountProvider
-
createResponse
public javax.ws.rs.core.Response createResponse(AccountPages page)
- Specified by:
createResponse
in interfaceAccountProvider
-
getTheme
protected Theme getTheme() throws IOException
Get Theme used for page rendering.- Returns:
- theme for page rendering, never null
- Throws:
IOException
- in case of Theme loading problem
-
handleThemeResources
protected Properties handleThemeResources(Theme theme, Locale locale, Map<String,Object> attributes)
Load message bundle and place it intomsg
template attribute. Also load Theme properties and place them intoproperties
template attribute.- Parameters:
theme
- actual Theme to load bundle fromlocale
- to load bundle forattributes
- template attributes to add resources to- Returns:
- message bundle for other use
-
handleMessages
protected void handleMessages(Locale locale, Properties messagesBundle, Map<String,Object> attributes)
Handle messages to be shown on the page - set them to template attributes- Parameters:
locale
- to be used for message text loadingmessagesBundle
- to be used for message text loadingattributes
- template attributes to messages related info to- See Also:
messageType
,messages
-
processTemplate
protected javax.ws.rs.core.Response processTemplate(Theme theme, AccountPages page, Map<String,Object> attributes, Locale locale)
Process FreeMarker template and prepare Response. Some fields are used for rendering also.- Parameters:
theme
- to be used (provided bygetTheme()
)page
- to be renderedattributes
- pushed to the templatelocale
- to be used- Returns:
- Response object to be returned to the browser, never null
-
setPasswordSet
public AccountProvider setPasswordSet(boolean passwordSet)
- Specified by:
setPasswordSet
in interfaceAccountProvider
-
setMessage
protected void setMessage(MessageType type, String message, Object... parameters)
-
formatMessage
protected String formatMessage(FormMessage message, Properties messagesBundle, Locale locale)
-
setErrors
public AccountProvider setErrors(javax.ws.rs.core.Response.Status status, List<FormMessage> messages)
- Specified by:
setErrors
in interfaceAccountProvider
-
setError
public AccountProvider setError(javax.ws.rs.core.Response.Status status, String message, Object... parameters)
- Specified by:
setError
in interfaceAccountProvider
-
setSuccess
public AccountProvider setSuccess(String message, Object... parameters)
- Specified by:
setSuccess
in interfaceAccountProvider
-
setWarning
public AccountProvider setWarning(String message, Object... parameters)
- Specified by:
setWarning
in interfaceAccountProvider
-
setUser
public AccountProvider setUser(UserModel user)
- Specified by:
setUser
in interfaceAccountProvider
-
setProfileFormData
public AccountProvider setProfileFormData(javax.ws.rs.core.MultivaluedMap<String,String> formData)
- Specified by:
setProfileFormData
in interfaceAccountProvider
-
setRealm
public AccountProvider setRealm(RealmModel realm)
- Specified by:
setRealm
in interfaceAccountProvider
-
setReferrer
public AccountProvider setReferrer(String[] referrer)
- Specified by:
setReferrer
in interfaceAccountProvider
-
setEvents
public AccountProvider setEvents(List<Event> events)
- Specified by:
setEvents
in interfaceAccountProvider
-
setSessions
public AccountProvider setSessions(List<UserSessionModel> sessions)
- Specified by:
setSessions
in interfaceAccountProvider
-
setStateChecker
public AccountProvider setStateChecker(String stateChecker)
- Specified by:
setStateChecker
in interfaceAccountProvider
-
setIdTokenHint
public AccountProvider setIdTokenHint(String idTokenHint)
- Specified by:
setIdTokenHint
in interfaceAccountProvider
-
setFeatures
public AccountProvider setFeatures(boolean identityProviderEnabled, boolean eventsEnabled, boolean passwordUpdateSupported, boolean authorizationSupported)
- Specified by:
setFeatures
in interfaceAccountProvider
-
setAttribute
public AccountProvider setAttribute(String key, String value)
- Specified by:
setAttribute
in interfaceAccountProvider
-
-