Package eu.webtoolkit.jwt.auth.mfa
Class TotpQrCode
java.lang.Object
eu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WWidget
eu.webtoolkit.jwt.WWebWidget
eu.webtoolkit.jwt.WInteractWidget
eu.webtoolkit.jwt.WPaintedWidget
eu.webtoolkit.jwt.WQrCode
eu.webtoolkit.jwt.auth.mfa.TotpQrCode
A QR code generator for TOTP secret keys.
This class can be used to generate a QR code from a TOTP secret key. The QR code will then be painted to the screen.
This allows for some authenticator apps to more conveniently add the TOTP secret key. This QR code embeds more than just the secret.
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WQrCode
WQrCode.ErrorCorrectionLevel
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Field Summary
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_, noDefault
-
Constructor Summary
ConstructorsConstructorDescriptionTotpQrCode
(String key, String serviceName, String userName, int codeDigits) Constructor.TotpQrCode
(String key, String serviceName, String userName, int codeDigits, WContainerWidget parentContainer) Constructor. -
Method Summary
Methods inherited from class eu.webtoolkit.jwt.WQrCode
getBrush, getErrorCorrectionLevel, getMessage, getSquareSize, isError, paintEvent, setBrush, setErrorCorrectionLevel, setMessage, setSquareSize
Methods inherited from class eu.webtoolkit.jwt.WPaintedWidget
addArea, createDomElement, createJSBrush, createJSPainterPath, createJSPen, createJSPoint, createJSRect, createJSTransform, enableAjax, getArea, getAreas, getCreatePaintDevice, getDomChanges, getMethod, getObjJsRef, getPreferredMethod, getRepaintSlot, insertArea, layoutSizeChanged, refresh, remove, removeArea, render, resize, setFormData, setPreferredMethod, update, update, update
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, propagateSetEnabled, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isCanReceiveFocus, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, iterateChildren, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHidden, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setToolTip, setVerticalAlignment, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
Methods inherited from class eu.webtoolkit.jwt.WObject
getObjectName
-
Constructor Details
-
TotpQrCode
public TotpQrCode(String key, String serviceName, String userName, int codeDigits, WContainerWidget parentContainer) Constructor.This takes the arguments:
key:
the secret TOTP key.seviceName:
the name of the application.userName:
the identifier of the client used to log in.codeDigits:
the length of the expected TOTP code accepted.
-
TotpQrCode
Constructor.Calls
this(key, serviceName, userName, codeDigits, (WContainerWidget)null)
-
-
Method Details
-
formatKey
Format the key and other information to a correct QR code.To generate a correct QR code, it needs to follow a specific format. The rules of this format can be consulted on the site: https://github.com/google/google-authenticator/wiki/Key-Uri-Format.
This stipulates that a valid string must contain a label, followed by some (optional) parameters.
The label is formatted such that:
serviceName:userName
.The used parameters are:
- secret: the generated TOTP secret key
- issuer: same as the serviceName
- userName: the name of the user for whom the QR code is created
- algorithm: always SHA1 (the default)
- digits: the number of digits the generated code contains
- period: the size of the time frame/window
-