Class LoginConlet
- All Implemented Interfaces:
Iterable<ComponentType>
,Channel
,ComponentType
,Eligible
,Manager
The users are configured as property “users” of the conlet:
"...":
"/LoginConlet":
users:
admin:
# Full name is optional
fullName: Administrator
password: "$2b$05$NiBd74ZGdplLC63ePZf1f.UtjMKkbQ23cQoO2OKOFalDBHWAOy21."
test:
fullName: Test Account
password: "$2b$05$hZaI/jToXf/d3BctZdT38Or7H7h6Pn2W3WiB49p5AyhDHFkkYCvo2"
Passwords are hashed using bcrypt.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jgrapes.webconsole.base.AbstractConlet
AbstractConlet.ConletTrackingInfo
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
-
Field Summary
Fields inherited from class org.jgrapes.webconsole.base.AbstractConlet
TYPE_INSTANCE_SEPARATOR
-
Constructor Summary
ConstructorDescriptionLoginConlet
(Channel componentChannel) Creates a new component with its channel set to the given channel. -
Method Summary
Modifier and TypeMethodDescriptionprotected Optional
<LoginConlet.AccountModel> createNewState
(AddConletRequest event, ConsoleConnection session, String conletId) As a model has already been created indoUpdateConletState(org.jgrapes.webconsole.base.events.NotifyConletModel, org.jgrapes.webconsole.base.ConsoleConnection, org.jgrapes.webconlet.locallogin.LoginConlet.AccountModel)
, the “new” model may already exist in the session.protected Optional
<LoginConlet.AccountModel> createStateRepresentation
(Event<?> event, ConsoleConnection channel, String conletId) Creates an instance of the type that represents the conlet’s state, initialized with default values.protected Set
<Conlet.RenderMode> doRenderConlet
(RenderConletRequestBase<?> event, ConsoleConnection channel, String conletId, LoginConlet.AccountModel model) Called byAbstractConlet.onAddConletRequest(AddConletRequest, ConsoleConnection)
andAbstractConlet.onRenderConletRequest(RenderConletRequest, ConsoleConnection)
to complete rendering the web console component.protected boolean
doSetLocale
(SetLocale event, ConsoleConnection channel, String conletId) Called byAbstractConlet.onSetLocale(SetLocale, ConsoleConnection)
for each web console component in the console connection.protected void
doUpdateConletState
(NotifyConletModel event, ConsoleConnection connection, LoginConlet.AccountModel model) Called byAbstractConlet.onNotifyConletModel(org.jgrapes.webconsole.base.events.NotifyConletModel, org.jgrapes.webconsole.base.ConsoleConnection)
to complete handling the notification.protected String
generateInstanceId
(AddConletRequest event, ConsoleConnection session) Create the instance specific part of a conlet id.void
The component can be configured with events that include a path (see @linkConfigurationUpdate.paths()
) that matches this components path (seeManager.componentPath()
).void
onConsolePrepared
(ConsolePrepared event, ConsoleConnection channel) Handle web console page loaded.void
onConsoleReady
(ConsoleReady event, ConsoleConnection channel) Register conlet.void
onUserAuthenticated
(UserAuthenticated event, Channel channel) Invoked when a user has been authenticated.Methods inherited from class org.jgrapes.webconsole.base.freemarker.FreeMarkerConlet
doGetResource, fmConletModel, fmModel, fmModel, fmSessionModel, fmTypeModel, freemarkerConfig, processTemplate, processTemplate
Methods inherited from class org.jgrapes.webconsole.base.AbstractConlet
afterOnClosed, conletIds, conletIdsByConsoleConnection, conletViews, doConletDeleted, doRemoveConletType, l10nBundles, localizations, onAddConletRequest, onClosed, onConletDeleted, onConletResourceRequest, onDetached, onNotifyConletModel, onRenderConletRequest, onSetLocale, putInSession, readContent, readContent, recreateState, removeState, resourceBundle, setPeriodicRefresh, stateFromSession, statesFromSession, supportedLocales, trackConlet, trackedConnections, type, typeFromId
Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LoginConlet
Creates a new component with its channel set to the given channel.- Parameters:
componentChannel
- the channel that the component’s handlers listen on by default and thatManager.fire(Event, Channel...)
sends the event to
-
-
Method Details
-
generateInstanceId
Description copied from class:AbstractConlet
Create the instance specific part of a conlet id.The default implementation generates a UUID. Derived classes override this method if e.g. the instance specific part must include a key that associates the conlet’s state with some backing store.
- Overrides:
generateInstanceId
in classAbstractConlet<LoginConlet.AccountModel>
- Parameters:
event
- the event that triggered the creation of a new conlet, which may contain required information (seeAddConletRequest.properties()
)session
- the console connection; usually not required but provided as context- Returns:
- the web console component id
-
onConsoleReady
@Handler public void onConsoleReady(ConsoleReady event, ConsoleConnection channel) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException Register conlet.- Parameters:
event
- the eventchannel
- the channel- Throws:
TemplateNotFoundException
- the template not found exceptionMalformedTemplateNameException
- the malformed template name exceptionParseException
- the parse exceptionIOException
- Signals that an I/O exception has occurred.
-
createNewState
protected Optional<LoginConlet.AccountModel> createNewState(AddConletRequest event, ConsoleConnection session, String conletId) throws Exception As a model has already been created indoUpdateConletState(org.jgrapes.webconsole.base.events.NotifyConletModel, org.jgrapes.webconsole.base.ConsoleConnection, org.jgrapes.webconlet.locallogin.LoginConlet.AccountModel)
, the “new” model may already exist in the session.- Overrides:
createNewState
in classAbstractConlet<LoginConlet.AccountModel>
- Parameters:
event
- the eventsession
- the console connectionconletId
- the conlet id- Returns:
- the state representation or
Optional.empty()
if none is required - Throws:
Exception
- if an exception occurs
-
createStateRepresentation
protected Optional<LoginConlet.AccountModel> createStateRepresentation(Event<?> event, ConsoleConnection channel, String conletId) throws IOException Description copied from class:AbstractConlet
Creates an instance of the type that represents the conlet’s state, initialized with default values.The default implementation returns
Optional.isEmpty()
, thus indicating that no state information is needed or available.This method should always be overridden if conlet instances have associated state.
- Overrides:
createStateRepresentation
in classAbstractConlet<LoginConlet.AccountModel>
- Parameters:
event
- the event, which may contain required information (seeAddConletRequest.properties()
)channel
- the console connection, sometimes required to send events to components that provide a backing storeconletId
- the conlet id calculated astype() + TYPE_INSTANCE_SEPARATOR + generateInstanceId(...)
- Returns:
- the state representation or
Optional.empty()
if none is required - Throws:
IOException
-
onConfigUpdate
The component can be configured with events that include a path (see @linkConfigurationUpdate.paths()
) that matches this components path (seeManager.componentPath()
).The following properties are recognized:
users
- See
LoginConlet
.
- Parameters:
event
- the event
-
onConsolePrepared
@Handler(priority=1000) public void onConsolePrepared(ConsolePrepared event, ConsoleConnection channel) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException Handle web console page loaded.- Parameters:
event
- the eventchannel
- the channel- Throws:
IOException
ParseException
MalformedTemplateNameException
TemplateNotFoundException
-
doRenderConlet
protected Set<Conlet.RenderMode> doRenderConlet(RenderConletRequestBase<?> event, ConsoleConnection channel, String conletId, LoginConlet.AccountModel model) throws Exception Description copied from class:AbstractConlet
Called byAbstractConlet.onAddConletRequest(AddConletRequest, ConsoleConnection)
andAbstractConlet.onRenderConletRequest(RenderConletRequest, ConsoleConnection)
to complete rendering the web console component.The
- Specified by:
doRenderConlet
in classAbstractConlet<LoginConlet.AccountModel>
- Parameters:
event
- the eventchannel
- the channelconletId
- the component idmodel
- the conlet’s state; may benull
if the conlet doesn’t have associated state information- Returns:
- the rendered modes
- Throws:
Exception
- the exception
-
doUpdateConletState
protected void doUpdateConletState(NotifyConletModel event, ConsoleConnection connection, LoginConlet.AccountModel model) throws Exception Description copied from class:AbstractConlet
Called byAbstractConlet.onNotifyConletModel(org.jgrapes.webconsole.base.events.NotifyConletModel, org.jgrapes.webconsole.base.ConsoleConnection)
to complete handling the notification.The default implementation does nothing.
- Overrides:
doUpdateConletState
in classAbstractConlet<LoginConlet.AccountModel>
- Parameters:
event
- the eventconnection
- the channelmodel
- the conlet’s state; may benull
if the conlet doesn’t have associated state information- Throws:
Exception
-
onUserAuthenticated
Invoked when a user has been authenticated.- Parameters:
event
- the eventchannel
- the channel
-
doSetLocale
protected boolean doSetLocale(SetLocale event, ConsoleConnection channel, String conletId) throws Exception Description copied from class:AbstractConlet
Called byAbstractConlet.onSetLocale(SetLocale, ConsoleConnection)
for each web console component in the console connection.Derived classes must send events for updating the representation to match the new locale.
If the method returns
false
this indicates that the representation cannot be updated without reloading the web console page.The default implementation fires a
RenderConletRequest
with tracked render modes (one of or bothConlet.RenderMode.Preview
andConlet.RenderMode.View
), thus updating the known representations. (Assuming that “Edit” and “Help” modes are represented with modal dialogs and therefore locale changes aren’t possible while these are open.)- Overrides:
doSetLocale
in classAbstractConlet<LoginConlet.AccountModel>
- Parameters:
event
- the eventchannel
- the channelconletId
- the web console component id- Returns:
- true, if adaption to new locale without reload is possible
- Throws:
Exception
- the exception
-