java.lang.Object
net.i2p.router.web.UpdateHandler
Handles the request to update the router by firing one or more EepGet calls to download the latest signed update file and display the status to anyone who asks.
After the download completes the signed update file is verified with TrustedUpdate, and if it's authentic the payload of the signed update file is unpacked and the router is restarted to complete the update process.
This is like a FormHandler but we don't extend it, as we don't have the message area, etc.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringWhat the form asked for.protected RouterContextRouter context backing this handler's update pages.protected LogLog scoped to this handler's class.private StringNonce proving the form came from this router.private HttpSessionSession the update is being checked on.Constructor Summary
ConstructorsConstructorDescriptionBinds the router context taken from the servlet context.Binds the given router context and takes its log from it.Method Summary
Modifier and TypeMethodDescriptionprivate voidThese two can be set in either order, so call checkUpdateAction() twicestoreSession(HttpSession)MUST be called first.voidsetConsoleNonce(String nonce) Alias for setUpdateNonce for session-based nonce support.voidsetContextId(String contextId) Configure this bean to query a particular router context.voidsetUpdateAction(String val) These two can be set in either order, so callcheckUpdateAction()twice.voidsetUpdateNonce(String nonce) Records the submitted nonce and re-checks the pending action.voidstoreSession(HttpSession session) For form validation.private voidupdate(UpdateType type) Starts an update of the given kind.static ConsoleUpdateManagerFetch the update manager that the update pages write to, without starting it.
Field Details
_context
Router context backing this handler's update pages._log
Log scoped to this handler's class._action
What the form asked for._nonce
Nonce proving the form came from this router._session
Session the update is being checked on.
Constructor Details
UpdateHandler
public UpdateHandler()Binds the router context taken from the servlet context.UpdateHandler
Binds the given router context and takes its log from it.- Parameters:
ctx- router context whose log manager backs this handler
Method Details
storeSession
For form validation.- Parameters:
session- the console HTTP session the nonce is validated against
updateManager
Fetch the update manager that the update pages write to, without starting it.- Parameters:
ctx- router context whose client app manager holds the update manager- Returns:
- null if not found
setContextId
Configure this bean to query a particular router context.- Parameters:
contextId- beginning few characters of the routerHash, or null to pick the first one we come across.
setUpdateAction
These two can be set in either order, so callcheckUpdateAction()twice.- Parameters:
val- the update action name submitted by the form
setUpdateNonce
Records the submitted nonce and re-checks the pending action.- Parameters:
nonce- the nonce submitted by the form, checked against the issued one
setConsoleNonce
Alias for setUpdateNonce for session-based nonce support.- Parameters:
nonce- the nonce submitted by the form, checked against the session
checkUpdateAction
private void checkUpdateAction()These two can be set in either order, so call checkUpdateAction() twicestoreSession(HttpSession)MUST be called first.update
Starts an update of the given kind.- Parameters:
type- what to update