Class LinkTokenUsername
java.lang.Object
com.irurueta.authserver.authorization.api.web.ott.LinkTokenUsername
The user name a magic link token is stored with. Spring's token store only keeps a user name next to the token, so
the purpose of a link travels in it: the token of a link requested as a second factor starts with a control
character that no identifier can carry (identifiers are stripped of control characters before they are used), and
OttLinkAuthenticationProvider accepts it only in the session of the signed-in user it was requested for.
The column holds 100 characters, so an identifier is cut to what fits; a second-factor link of a
user name longer than 99 characters would be cut and never match its user, so
OttGenerationSuccessHandler does not deliver it (fitsSecondFactorLink(String)).-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCharacters the user name column of the token store holds.static final intCharacters a user name may have to fit the column next to the marker of a second-factor link.(package private) static final charMarker of the token of a link requested as a second factor. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateUtility class: not meant to be instantiated. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringCleans an identifier typed in a form: no control characters, no surrounding blanks, and no more characters than the column holds.static booleanfitsSecondFactorLink(String username) Tells whether a user name fits the column next to the marker of a second-factor link, so that the stored name of the link still identifies the user.static StringBuilds the stored user name of a link.static StringidentifierOf(String stored) Gets the identifier of a stored user name.static booleanisSecondFactor(String stored) Tells whether a stored user name is the one of a link requested as a second factor.
-
Field Details
-
MAX_LENGTH
public static final int MAX_LENGTHCharacters the user name column of the token store holds.- See Also:
-
MAX_SECOND_FACTOR_LENGTH
public static final int MAX_SECOND_FACTOR_LENGTHCharacters a user name may have to fit the column next to the marker of a second-factor link.- See Also:
-
SECOND_FACTOR_MARKER
static final char SECOND_FACTOR_MARKERMarker of the token of a link requested as a second factor.- See Also:
-
-
Constructor Details
-
LinkTokenUsername
private LinkTokenUsername()Utility class: not meant to be instantiated.
-
-
Method Details
-
clean
Cleans an identifier typed in a form: no control characters, no surrounding blanks, and no more characters than the column holds.- Parameters:
identifier- the identifier, ornull.- Returns:
- the identifier ready to be stored; the empty text when nothing is left of it.
-
forLink
Builds the stored user name of a link.- Parameters:
identifier- the cleaned identifier.secondFactor- whether the link is requested as a second factor.- Returns:
- the identifier, preceded by the marker for a second factor and cut to the column's size.
-
fitsSecondFactorLink
Tells whether a user name fits the column next to the marker of a second-factor link, so that the stored name of the link still identifies the user.- Parameters:
username- the name of the signed-in user.- Returns:
truewhen it has at most 99 characters.
-
isSecondFactor
Tells whether a stored user name is the one of a link requested as a second factor.- Parameters:
stored- the stored user name.- Returns:
truewhen it carries the marker.
-
identifierOf
Gets the identifier of a stored user name.- Parameters:
stored- the stored user name.- Returns:
- the identifier, without the marker.
-