Class FreeMarkerLoginFormsProvider
java.lang.Object
org.keycloak.forms.login.freemarker.FreeMarkerLoginFormsProvider
- All Implemented Interfaces:
LoginFormsProvider
,Provider
- Author:
- Stian Thorgersen
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected URI
protected AuthenticationSessionModel
authenticationSession can be null for some renderings, mainly error pagesprotected ClientModel
protected List<AuthorizationDetails>
protected AuthenticationFlowContext
protected boolean
protected String
protected FreeMarkerProvider
protected List<FormMessage>
protected MessageType
protected RealmModel
protected KeycloakSession
protected jakarta.ws.rs.core.Response.Status
protected jakarta.ws.rs.core.UriInfo
protected UserModel
Fields inherited from interface org.keycloak.forms.login.LoginFormsProvider
IDENTITY_PROVIDER_BROKER_CONTEXT, REGISTRATION_DISABLED, UPDATE_PROFILE_CONTEXT_ATTR, USERNAME_HIDDEN
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddError
(FormMessage errorMessage) void
Adds a script to the html headeraddSuccess
(FormMessage errorMessage) Add a success message to the formvoid
close()
jakarta.ws.rs.core.Response
protected void
createCommonAttributes
(Theme theme, Locale locale, Properties messagesBundle, jakarta.ws.rs.core.UriBuilder baseUriBuilder, LoginFormsPages page) Create common attributes used in all templates.jakarta.ws.rs.core.Response
createErrorPage
(jakarta.ws.rs.core.Response.Status status) jakarta.ws.rs.core.Response
createForm
(String form) jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
protected jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
jakarta.ws.rs.core.Response
protected String
formatMessage
(FormMessage message) protected String
formatMessage
(FormMessage message, Properties messagesBundle, Locale locale) protected String
getMessage
(String message) protected Theme
getTheme()
Get Theme used for page rendering.protected void
handleMessages
(Locale locale, Properties messagesBundle) Handle messages to be shown on the page - set them to template attributesprotected Properties
handleThemeResources
(Theme theme, Locale locale) Load message bundle and place it intomsg
template attribute.protected jakarta.ws.rs.core.UriBuilder
prepareBaseUriBuilder
(boolean resetRequestUriParams) Prepare base uri builder for later useprotected jakarta.ws.rs.core.Response
processTemplate
(Theme theme, String templateName, Locale locale) Process FreeMarker template and prepare Response.setAccessRequest
(List<AuthorizationDetails> clientScopesRequested) setActionUri
(URI actionUri) setAttribute
(String name, Object value) setAuthContext
(AuthenticationFlowContext context) setAuthenticationSession
(AuthenticationSessionModel authenticationSession) setClientSessionCode
(String accessCode) Used when authenticationSession was already removed for this browser session and hence we don't have any authenticationSession or user data.Set one global error message.setErrors
(List<FormMessage> messages) Set multiple error messages.setExecution
(String execution) setFormData
(jakarta.ws.rs.core.MultivaluedMap<String, String> formData) setMessage
(MessageType type, String message, Object... parameters) setResponseHeader
(String headerName, String headerValue) setStatus
(jakarta.ws.rs.core.Response.Status status) setSuccess
(String message, Object... parameters)
-
Field Details
-
accessCode
-
status
protected jakarta.ws.rs.core.Response.Status status -
clientScopesRequested
-
httpResponseHeaders
-
actionUri
-
execution
-
context
-
messages
-
messageType
-
formData
-
detachedAuthSession
protected boolean detachedAuthSession -
session
-
authenticationSession
authenticationSession can be null for some renderings, mainly error pages -
realm
-
client
-
uriInfo
protected jakarta.ws.rs.core.UriInfo uriInfo -
freeMarker
-
user
-
attributes
-
-
Constructor Details
-
FreeMarkerLoginFormsProvider
-
-
Method Details
-
addScript
Description copied from interface:LoginFormsProvider
Adds a script to the html header- Specified by:
addScript
in interfaceLoginFormsProvider
-
createResponse
- Specified by:
createResponse
in interfaceLoginFormsProvider
-
createResponse
-
createForm
- Specified by:
createForm
in interfaceLoginFormsProvider
-
prepareBaseUriBuilder
protected jakarta.ws.rs.core.UriBuilder prepareBaseUriBuilder(boolean resetRequestUriParams) Prepare base uri builder for later use- Parameters:
resetRequestUriParams
- - for some reason Resteasy 2.3.7 doesn't like query params and form params with the same name and will null out the code form param, so we have to reset them for some pages- Returns:
- base uri builder
-
getTheme
Get Theme used for page rendering.- Returns:
- theme for page rendering, never null
- Throws:
IOException
- in case of Theme loading problem
-
handleThemeResources
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 for- Returns:
- message bundle for other use
-
handleMessages
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 loading- See Also:
-
getMessage
- Specified by:
getMessage
in interfaceLoginFormsProvider
-
createCommonAttributes
protected void createCommonAttributes(Theme theme, Locale locale, Properties messagesBundle, jakarta.ws.rs.core.UriBuilder baseUriBuilder, LoginFormsPages page) Create common attributes used in all templates.- Parameters:
theme
- actual Theme used (provided bygetTheme()
)locale
- actual localemessagesBundle
- actual message bundle (provided byhandleThemeResources()
)baseUriBuilder
- actual base uri builder (provided byprepareBaseUriBuilder()
)page
- in case if common page is rendered, is null if called fromcreateForm()
-
processTemplate
protected jakarta.ws.rs.core.Response processTemplate(Theme theme, String templateName, Locale locale) Process FreeMarker template and prepare Response. Some fields are used for rendering also.- Parameters:
theme
- to be used (provided bygetTheme()
)templateName
- name of the template to be renderedlocale
- to be used- Returns:
- Response object to be returned to the browser, never null
-
createLoginUsernamePassword
public jakarta.ws.rs.core.Response createLoginUsernamePassword()- Specified by:
createLoginUsernamePassword
in interfaceLoginFormsProvider
-
createLoginUsername
public jakarta.ws.rs.core.Response createLoginUsername()- Specified by:
createLoginUsername
in interfaceLoginFormsProvider
-
createLoginPassword
public jakarta.ws.rs.core.Response createLoginPassword()- Specified by:
createLoginPassword
in interfaceLoginFormsProvider
-
createPasswordReset
public jakarta.ws.rs.core.Response createPasswordReset()- Specified by:
createPasswordReset
in interfaceLoginFormsProvider
-
createOtpReset
public jakarta.ws.rs.core.Response createOtpReset()- Specified by:
createOtpReset
in interfaceLoginFormsProvider
-
createLoginTotp
public jakarta.ws.rs.core.Response createLoginTotp()- Specified by:
createLoginTotp
in interfaceLoginFormsProvider
-
createLoginRecoveryAuthnCode
public jakarta.ws.rs.core.Response createLoginRecoveryAuthnCode()- Specified by:
createLoginRecoveryAuthnCode
in interfaceLoginFormsProvider
-
createLoginWebAuthn
public jakarta.ws.rs.core.Response createLoginWebAuthn()- Specified by:
createLoginWebAuthn
in interfaceLoginFormsProvider
-
createRegistration
public jakarta.ws.rs.core.Response createRegistration()- Specified by:
createRegistration
in interfaceLoginFormsProvider
-
createInfoPage
public jakarta.ws.rs.core.Response createInfoPage()- Specified by:
createInfoPage
in interfaceLoginFormsProvider
-
createUpdateProfilePage
public jakarta.ws.rs.core.Response createUpdateProfilePage()- Specified by:
createUpdateProfilePage
in interfaceLoginFormsProvider
-
createIdpLinkConfirmLinkPage
public jakarta.ws.rs.core.Response createIdpLinkConfirmLinkPage()- Specified by:
createIdpLinkConfirmLinkPage
in interfaceLoginFormsProvider
-
createIdpLinkConfirmOverrideLinkPage
public jakarta.ws.rs.core.Response createIdpLinkConfirmOverrideLinkPage()- Specified by:
createIdpLinkConfirmOverrideLinkPage
in interfaceLoginFormsProvider
-
createLoginExpiredPage
public jakarta.ws.rs.core.Response createLoginExpiredPage()- Specified by:
createLoginExpiredPage
in interfaceLoginFormsProvider
-
createIdpLinkEmailPage
public jakarta.ws.rs.core.Response createIdpLinkEmailPage()- Specified by:
createIdpLinkEmailPage
in interfaceLoginFormsProvider
-
createErrorPage
public jakarta.ws.rs.core.Response createErrorPage(jakarta.ws.rs.core.Response.Status status) - Specified by:
createErrorPage
in interfaceLoginFormsProvider
-
createWebAuthnErrorPage
public jakarta.ws.rs.core.Response createWebAuthnErrorPage()- Specified by:
createWebAuthnErrorPage
in interfaceLoginFormsProvider
-
createOAuthGrant
public jakarta.ws.rs.core.Response createOAuthGrant()- Specified by:
createOAuthGrant
in interfaceLoginFormsProvider
-
createSelectAuthenticator
public jakarta.ws.rs.core.Response createSelectAuthenticator()- Specified by:
createSelectAuthenticator
in interfaceLoginFormsProvider
-
createOAuth2DeviceVerifyUserCodePage
public jakarta.ws.rs.core.Response createOAuth2DeviceVerifyUserCodePage()- Specified by:
createOAuth2DeviceVerifyUserCodePage
in interfaceLoginFormsProvider
-
createCode
public jakarta.ws.rs.core.Response createCode()- Specified by:
createCode
in interfaceLoginFormsProvider
-
createX509ConfirmPage
public jakarta.ws.rs.core.Response createX509ConfirmPage()- Specified by:
createX509ConfirmPage
in interfaceLoginFormsProvider
-
createSamlPostForm
public jakarta.ws.rs.core.Response createSamlPostForm()- Specified by:
createSamlPostForm
in interfaceLoginFormsProvider
-
createFrontChannelLogoutPage
public jakarta.ws.rs.core.Response createFrontChannelLogoutPage()- Specified by:
createFrontChannelLogoutPage
in interfaceLoginFormsProvider
-
createLogoutConfirmPage
public jakarta.ws.rs.core.Response createLogoutConfirmPage()- Specified by:
createLogoutConfirmPage
in interfaceLoginFormsProvider
-
setMessage
- Specified by:
setMessage
in interfaceLoginFormsProvider
-
getFirstMessageUnformatted
-
formatMessage
-
formatMessage
-
setError
Description copied from interface:LoginFormsProvider
Set one global error message.- Specified by:
setError
in interfaceLoginFormsProvider
- Parameters:
message
- key of messageparameters
- to be formatted into message
-
setErrors
Description copied from interface:LoginFormsProvider
Set multiple error messages.- Specified by:
setErrors
in interfaceLoginFormsProvider
- Parameters:
messages
- to be set
-
addError
- Specified by:
addError
in interfaceLoginFormsProvider
-
addSuccess
Description copied from interface:LoginFormsProvider
Add a success message to the form- Specified by:
addSuccess
in interfaceLoginFormsProvider
- Returns:
-
setSuccess
- Specified by:
setSuccess
in interfaceLoginFormsProvider
-
setInfo
- Specified by:
setInfo
in interfaceLoginFormsProvider
-
setDetachedAuthSession
Description copied from interface:LoginFormsProvider
Used when authenticationSession was already removed for this browser session and hence we don't have any authenticationSession or user data. Would just repeat previous info/error page after language is changed- Specified by:
setDetachedAuthSession
in interfaceLoginFormsProvider
-
setAuthenticationSession
public LoginFormsProvider setAuthenticationSession(AuthenticationSessionModel authenticationSession) - Specified by:
setAuthenticationSession
in interfaceLoginFormsProvider
-
setUser
- Specified by:
setUser
in interfaceLoginFormsProvider
-
setFormData
public FreeMarkerLoginFormsProvider setFormData(jakarta.ws.rs.core.MultivaluedMap<String, String> formData) - Specified by:
setFormData
in interfaceLoginFormsProvider
-
setClientSessionCode
- Specified by:
setClientSessionCode
in interfaceLoginFormsProvider
-
setAccessRequest
- Specified by:
setAccessRequest
in interfaceLoginFormsProvider
-
setAttribute
- Specified by:
setAttribute
in interfaceLoginFormsProvider
-
setStatus
- Specified by:
setStatus
in interfaceLoginFormsProvider
-
setActionUri
- Specified by:
setActionUri
in interfaceLoginFormsProvider
-
setExecution
- Specified by:
setExecution
in interfaceLoginFormsProvider
-
setResponseHeader
- Specified by:
setResponseHeader
in interfaceLoginFormsProvider
-
setAuthContext
- Specified by:
setAuthContext
in interfaceLoginFormsProvider
-
setAttributeMapper
public LoginFormsProvider setAttributeMapper(Function<Map<String, Object>, Map<String, Object>> mapper) - Specified by:
setAttributeMapper
in interfaceLoginFormsProvider
-
close
public void close()
-