org.keycloak.forms.account.freemarker

## 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 and Description
    --- | ---
    `protected Map<String,Object>` | `attributes`
    `protected List<Event>` | `events`
    `protected boolean` | `eventsEnabled`
    `protected FreeMarkerUtil` | `freeMarker`
    `protected javax.ws.rs.core.HttpHeaders` | `headers`
    `protected boolean` | `identityProviderEnabled`
    `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 and Description
    `FreeMarkerAccountProvider(KeycloakSession session, FreeMarkerUtil freeMarker)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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 attributes
    `protected Properties` | `handleThemeResources(Theme theme, Locale locale, Map<String,Object> attributes)` Load message bundle and place it into `msg` 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)`
    `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)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### user

          protected UserModel user

    - #### profileFormData

          protected javax.ws.rs.core.MultivaluedMap<String,String> profileFormData

    - #### status

          protected javax.ws.rs.core.Response.Status status

    - #### realm

          protected RealmModel realm

    - #### referrer

          protected String[] referrer

    - #### events

          protected List<Event> events

    - #### stateChecker

          protected String stateChecker

    - #### 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 FreeMarkerUtil freeMarker

    - #### headers

          protected javax.ws.rs.core.HttpHeaders headers

    - #### attributes

          protected Map<String,Object> attributes

    - #### uriInfo

          protected javax.ws.rs.core.UriInfo uriInfo

    - #### messages

          protected List<FormMessage> messages

    - #### messageType

          protected MessageType messageType

  - ### Constructor Detail

    - #### FreeMarkerAccountProvider

          public FreeMarkerAccountProvider(KeycloakSession session,
                                           FreeMarkerUtil freeMarker)

  - ### Method Detail

    - #### setUriInfo

          public AccountProvider setUriInfo(javax.ws.rs.core.UriInfo uriInfo)

      Specified by:
        `setUriInfo` in interface `AccountProvider`

    - #### setHttpHeaders

          public AccountProvider setHttpHeaders(javax.ws.rs.core.HttpHeaders httpHeaders)

      Specified by:
        `setHttpHeaders` in interface `AccountProvider`

    - #### createResponse

          public javax.ws.rs.core.Response createResponse(AccountPages page)

      Specified by:
        `createResponse` in interface `AccountProvider`

    - #### 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 into `msg` template attribute. Also load Theme properties and place them into `properties` template attribute.
      Parameters:
        `theme` - actual Theme to load bundle from
        `locale` - to load bundle for
        `attributes` - 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 loading
        `messagesBundle` - to be used for message text loading
        `attributes` - 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 by `getTheme()`)
        `page` - to be rendered
        `attributes` - pushed to the template
        `locale` - to be used
      Returns:
        Response object to be returned to the browser, never null

    - #### setPasswordSet

          public AccountProvider setPasswordSet(boolean passwordSet)

      Specified by:
        `setPasswordSet` in interface `AccountProvider`

    - #### 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 interface `AccountProvider`

    - #### setError

          public AccountProvider setError(javax.ws.rs.core.Response.Status status,
                                          String message,
                                          Object... parameters)

      Specified by:
        `setError` in interface `AccountProvider`

    - #### setSuccess

          public AccountProvider setSuccess(String message,
                                            Object... parameters)

      Specified by:
        `setSuccess` in interface `AccountProvider`

    - #### setWarning

          public AccountProvider setWarning(String message,
                                            Object... parameters)

      Specified by:
        `setWarning` in interface `AccountProvider`

    - #### setUser

          public AccountProvider setUser(UserModel user)

      Specified by:
        `setUser` in interface `AccountProvider`

    - #### setProfileFormData

          public AccountProvider setProfileFormData(javax.ws.rs.core.MultivaluedMap<String,String> formData)

      Specified by:
        `setProfileFormData` in interface `AccountProvider`

    - #### setRealm

          public AccountProvider setRealm(RealmModel realm)

      Specified by:
        `setRealm` in interface `AccountProvider`

    - #### setReferrer

          public AccountProvider setReferrer(String[] referrer)

      Specified by:
        `setReferrer` in interface `AccountProvider`

    - #### setEvents

          public AccountProvider setEvents(List<Event> events)

      Specified by:
        `setEvents` in interface `AccountProvider`

    - #### setSessions

          public AccountProvider setSessions(List<UserSessionModel> sessions)

      Specified by:
        `setSessions` in interface `AccountProvider`

    - #### setStateChecker

          public AccountProvider setStateChecker(String stateChecker)

      Specified by:
        `setStateChecker` in interface `AccountProvider`

    - #### setFeatures

          public AccountProvider setFeatures(boolean identityProviderEnabled,
                                             boolean eventsEnabled,
                                             boolean passwordUpdateSupported,
                                             boolean authorizationSupported)

      Specified by:
        `setFeatures` in interface `AccountProvider`

    - #### setAttribute

          public AccountProvider setAttribute(String key,
                                              String value)

      Specified by:
        `setAttribute` in interface `AccountProvider`

    - #### close

          public void close()

      Specified by:
        `close` in interface `Provider`

Copyright © 2021 JBoss by Red Hat. All rights reserved.