public class TotpCodeAuthComposite<A extends AppUser> extends CodeAuthComposite<A,java.lang.Integer> implements AppUserTransitionContributor, SummaryContributer<A>, RequiredPageProvider<A>
FormAuthComposite
that implements time-based authentication codes compatible
with google authenticator
Modifier and Type | Class and Description |
---|---|
class |
TotpCodeAuthComposite.CodeValidator |
class |
TotpCodeAuthComposite.DirectClearKeyTransition |
class |
TotpCodeAuthComposite.SetToptTransition |
Modifier and Type | Field and Description |
---|---|
static AppUserKey |
CLEAR_KEY |
static java.lang.String |
REMOVE_KEY_ROLE |
static Feature |
REQUIRED_TWO_FACTOR |
static CurrentUserKey |
SET_KEY |
static Feature |
VERIFY_OLD_CODE |
CODE, VERIFICATION_CODE_LABEL
Constructor and Description |
---|
TotpCodeAuthComposite(AppUserFactory<A> fac) |
Modifier and Type | Method and Description |
---|---|
void |
addAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes,
A target)
Add to the set of attributes.
|
ContentBuilder |
addExtra(ContentBuilder cb)
Add extra content when being shown a modified auth form.
|
java.util.Set<java.lang.String> |
addSuppress(java.util.Set<java.lang.String> suppress)
generate the class specific set of suppressed fields to be used in form creation/update
The individual forms can override these so you usually use this method to define fields that should
be suppressed in all forms.
|
void |
clearSecret(A user) |
java.security.Key |
decodeKey(java.lang.String enc) |
boolean |
enabled() |
protected boolean |
enabled(A user) |
long |
getCode(java.security.Key key,
long counter) |
protected java.lang.String |
getConfigPrefix() |
java.lang.String |
getEncodedSecret(java.security.Key key) |
Input<java.lang.Integer> |
getInput() |
long |
getNorm()
number of milliseconds per code value
|
java.util.Set<RequiredPage<A>> |
getRequiredPages()
Get the set of required pages.
|
java.security.Key |
getSecret(A user) |
java.util.Map<AppUserKey,Transition<AppUser>> |
getTransitions(AppUserTransitionProvider prov) |
java.net.URI |
getURI(A user,
java.security.Key key) |
int |
getWindow() |
boolean |
hasKey(A user)
Do we have a key for this user.
|
java.security.Key |
makeNewKey() |
TableSpecification |
modifyDefaultTableSpecification(TableSpecification spec,
java.lang.String table)
Modify the
TableSpecification of the target factory. |
void |
setSecret(A user,
java.security.Key key) |
void |
setSecret(A user,
java.lang.String enc) |
boolean |
verify(A user,
java.lang.Integer value) |
boolean |
verify(java.security.Key key,
java.lang.Integer value) |
modifyForm
authenticated, getType, needAuth, needToken, requireAuth, sendToken
addDefaults, addFieldHelp, addOptional, addSelectors, addTranslations, customiseForm, customiseUpdateForm, getContext, getFactory, getLogger, getRecord, getRepository, postUpdate, preRegister, release, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFieldConstraints, addFormFields
public static final Feature REQUIRED_TWO_FACTOR
public static final Feature VERIFY_OLD_CODE
public static final java.lang.String REMOVE_KEY_ROLE
public static final CurrentUserKey SET_KEY
public static final AppUserKey CLEAR_KEY
public TotpCodeAuthComposite(AppUserFactory<A> fac)
fac
- protected boolean enabled(A user)
enabled
in class FormAuthComposite<A extends AppUser>
public boolean enabled()
public boolean hasKey(A user)
user
- public java.security.Key makeNewKey() throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
public void setSecret(A user, java.security.Key key)
public void setSecret(A user, java.lang.String enc)
public void clearSecret(A user)
user
- public java.security.Key decodeKey(java.lang.String enc)
public java.security.Key getSecret(A user) throws java.io.UnsupportedEncodingException, java.security.NoSuchAlgorithmException, java.security.spec.InvalidKeySpecException
java.io.UnsupportedEncodingException
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException
public java.lang.String getEncodedSecret(java.security.Key key) throws java.io.UnsupportedEncodingException, java.security.NoSuchAlgorithmException, java.security.spec.InvalidKeySpecException
java.io.UnsupportedEncodingException
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException
public long getCode(java.security.Key key, long counter) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
public Input<java.lang.Integer> getInput()
getInput
in class CodeAuthComposite<A extends AppUser,java.lang.Integer>
public boolean verify(A user, java.lang.Integer value)
verify
in class CodeAuthComposite<A extends AppUser,java.lang.Integer>
public boolean verify(java.security.Key key, java.lang.Integer value)
public long getNorm()
public int getWindow()
public TableSpecification modifyDefaultTableSpecification(TableSpecification spec, java.lang.String table)
TableStructureContributer
TableSpecification
of the target factory.modifyDefaultTableSpecification
in interface TableStructureContributer<A extends AppUser>
modifyDefaultTableSpecification
in class Composite<A extends AppUser,FormAuthComposite>
public java.util.Set<java.lang.String> addSuppress(java.util.Set<java.lang.String> suppress)
TableStructureContributer
addSuppress
in interface TableStructureContributer<A extends AppUser>
addSuppress
in class Composite<A extends AppUser,FormAuthComposite>
Set
of fields to suppress in forms.public java.net.URI getURI(A user, java.security.Key key) throws java.io.UnsupportedEncodingException, java.security.NoSuchAlgorithmException, java.security.spec.InvalidKeySpecException, java.net.URISyntaxException
java.io.UnsupportedEncodingException
java.security.NoSuchAlgorithmException
java.security.spec.InvalidKeySpecException
java.net.URISyntaxException
public java.util.Map<AppUserKey,Transition<AppUser>> getTransitions(AppUserTransitionProvider prov)
getTransitions
in interface AppUserTransitionContributor
public java.util.Set<RequiredPage<A>> getRequiredPages()
RequiredPageProvider
getRequiredPages
in interface RequiredPageProvider<A extends AppUser>
public void addAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes, A target)
SummaryContributer
Table
so the data should be of a
type that can be displayed by Table
s
The keys should be display text.addAttributes
in interface SummaryContributer<A extends AppUser>
protected java.lang.String getConfigPrefix()
getConfigPrefix
in class FormAuthComposite<A extends AppUser>
public ContentBuilder addExtra(ContentBuilder cb)
FormAuthComposite
addExtra
in class FormAuthComposite<A extends AppUser>