AU
- type of AppUser
public class AppUserFactory<AU extends AppUser> extends DataObjectFactory<AU> implements RequiredPageProvider<AU>, NameFinder<AU>, RegisterTrigger<AU>, SummaryContributer<AU>, AccessRoleProvider<AU,AU>, AnonymisingFactory
AppUser
objects that represent users of the system.
If the bootstrap.admin Feature
is set then the first user in the system will automatically be given the ADMIN role (or the role
specified in the bootstrap-role property is this is set). The role is added when the table for this factory is created not when the user is added.Modifier and Type | Class and Description |
---|---|
static class |
AppUserFactory.AppUserNameInput<A extends AppUser> |
class |
AppUserFactory.RoleFilter
|
static class |
AppUserFactory.SignupFormCreator<T extends AppUser>
Form for first time visitors to self register
optionally this can also provide a name for the default realm if the servlet uses external authentication.
|
class |
AppUserFactory.UpdatePersonRequiredPage |
DataObjectFactory.AbstractDataObjectInput, DataObjectFactory.AbstractFinder<X>, DataObjectFactory.DataObjectAcceptFilter, DataObjectFactory.DataObjectInput, DataObjectFactory.DataObjectIntegerInput, DataObjectFactory.DestAcceptFilter<T extends DataObject>, DataObjectFactory.FilterAdapter, DataObjectFactory.FilterCounter, DataObjectFactory.FilterExists, DataObjectFactory.FilterIterator, DataObjectFactory.FilterSelector, DataObjectFactory.FilterSet, DataObjectFactory.Finder, DataObjectFactory.MakeRemoteFilterVisitor<R extends DataObject>, DataObjectFactory.MatchFilter, DataObjectFactory.ReferencedAdapter<I extends Indexed>, DataObjectFactory.ReferenceIterator<I extends Indexed>, DataObjectFactory.SortingDataObjectInput, DataObjectFactory.TimeAcceptFilter<T extends DataObject>, DataObjectFactory.TimeFilter
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ALLOW_EMAIL_FIELD |
static Feature |
ANONYMISE_DATABASE_FEATURE |
static Feature |
AUTO_COMPLETE_APPUSER_INPUT |
static Feature |
BOOTSTRAP_ADMIN_FEATURE |
static java.lang.String |
BOOTSTRAP_ROLE_PROPERTY |
static Feature |
REQUIRE_PERSON_UPDATE_FEATURE |
AUTO_CREATE_TABLES_FEATURE, COMPOSITES_SUFFIX, REJECT_MULTIPLE_RESULT_FEATURE, res
Modifier | Constructor and Description |
---|---|
protected |
AppUserFactory() |
|
AppUserFactory(AppContext conn,
java.lang.String table) |
Modifier and Type | Method and Description |
---|---|
void |
addAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes,
AU target)
Add to the set of attributes.
|
void |
addRelationships(java.util.Set<java.lang.String> roles)
Add known roles to a set.
|
void |
addUpdateAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes,
AU target) |
<CB extends ContentBuilder> |
addUpdateNotes(CB cb,
AU target)
add Notes to be included in a signup/update form.
|
void |
anonymise()
Anonymise the database.
|
boolean |
autoCreate() |
boolean |
canErase(AU person) |
void |
erasePersonalData(AU p)
Erase the personal data for the specified user
|
AU |
findByEmail(java.lang.String email) |
AU |
findByEmail(java.lang.String email,
boolean allow_null) |
AU |
findFromString(java.lang.String name)
Find an existing entry by name
This should use the same logic as
NameFinder.getStringFinderFilter(String) . |
SQLFilter<AU> |
getCanLoginFilter()
get a filter equivalent to
AppUser.canLogin() |
java.lang.String |
getCanonicalName(AU object)
Get a canonical name of an object in a format that can be parsed by the
ParseFactory.findFromString(String) method. |
DataCache<java.lang.String,AU> |
getDataCache()
get a DataCache for fetching the target
|
java.lang.String |
getDefaultRealm()
Get the realm to use as a default when generating a name from the factory.
|
SQLFilter<AU> |
getDefaultRelationshipFilter()
Get a
SQLFilter to use as the default target for relationship filters. |
protected TableSpecification |
getDefaultTableSpecification(AppContext ctx,
java.lang.String table)
Get the default table specification if the table is to be created.
|
BaseFilter<AU> |
getEmailFilter()
a filter for people that we might ever send emails to.
|
FormUpdate<AU> |
getFormUpdate(AppContext c)
produce a FormUpdate for the target type appropriate for
the requesting user
|
DataObjectItemInput<AU> |
getInput()
get the default
Input for this Factory
Default behaviour is to use the DataObjectFactory.getSelectFilter() method to generate a DataObjectFactory.DataObjectInput
but not to restrict the parse values (default value of DataObjectFactory.restrictDefaultInput() so existing values that don't
match the select filter are still valid. |
DataObjectItemInput<AU> |
getNameInput(BaseFilter<AU> fil,
boolean create,
boolean restrict) |
java.lang.String |
getNameLabel()
Get the user presented label asking for a login-id.
|
protected java.util.Set<java.lang.String> |
getOptional()
generate the set of optional fields to be used to provide class specific defaults
in form creation/update.
|
Table<java.lang.String,AU> |
getPersonTable(SessionService<?> sess,
BaseFilter<AU> fil) |
AppUserNameFinder<AU,?> |
getRealmFinder(java.lang.String realm)
Get a specified
AppUserNameFinder . |
java.util.Collection<AppUserNameFinder> |
getRealms() |
java.util.Set<RequiredPage<AU>> |
getRequiredPages()
Get the set of required pages.
|
protected AppUserFactory.RoleFilter |
getRoleFilter(java.lang.String... roles) |
DataObjectItemInput<AU> |
getRoleInput(java.lang.String role) |
BaseFilter<AU> |
getSelectFilter()
Get a filter corresponding to the set of DataObjects that can be used in
the default Input for this class.
|
protected java.util.Map<java.lang.String,Selector> |
getSelectors()
Get a Map of selectors to use for forms of this type.
|
FormCreator |
getSignupFormCreator(java.lang.String realm,
java.lang.String webname)
Get a
FormCreator to use when users sign-up
Optionally a name and a realm can be supplied which will be set as part of signup. |
java.lang.String |
getSortName(AU user)
Get a name where the String sort order matches the
presentation order.
|
SQLFilter<AU> |
getStringFinderFilter(java.lang.String name)
get a filter than locates the target object from a String.
|
SQLFilter<AU> |
getStringFinderFilter(java.lang.String name,
boolean require_user_supplied) |
protected java.util.Set<java.lang.String> |
getSupress()
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.
|
java.lang.Class<AU> |
getTarget()
Get a bound on the type of object produced by this factory for run-time checking.
|
BaseFilter<AU> |
getWarnRefreshFilter() |
BaseFilter<AU> |
hasRelationFilter(java.lang.String role,
AU user)
Get a
BaseFilter corresponding to target objects where the given user has
the specified relation. |
boolean |
isRegisteredUsername(java.lang.String username)
Does a String resolve to a known user.
|
protected AU |
makeBDO(Repository.Record res)
Construct a new Blank DataObject of the correct Class
This method takes a Record as an argument.
|
AU |
makeFromString(java.lang.String name)
Same as
NameFinder.findFromString(String) but attempts to create a matching entry if one does not exist and this
is supported by the implementing class. |
AU |
makeUser()
make an uncommited user suitable for automatic user creation.
|
boolean |
mustRegister(AU user)
Should this person register
|
boolean |
needDetailsUpdate(AU user)
do the persons details need updating.
|
void |
newSignup(AU user)
randomise a persons SAF password and send new password in an Email
|
BaseFilter<AU> |
personInRelationFilter(SessionService<AU> sess,
java.lang.String role,
AU target)
Get a
BaseFilter for AppUser s that are in the specified relationship with
the target object. |
protected void |
postAutoTableCreateSetup(AppContext ctx) |
protected void |
postCreateTableSetup(AppContext c,
java.lang.String table) |
void |
postRegister(AU user)
user has registered.
|
boolean |
providesRelationship(java.lang.String role)
Does this class provide the named relationship.
|
int |
requireRefreshDays()
number of days between required review of personal details
|
boolean |
supportsRealm(java.lang.String realm) |
protected boolean |
useAutoCompleteForSelect()
Are we using an auto-complete input for
getInput()
If this is true and DataObjectFactory.restrictDefaultInput() also returns true
we can afford to be more restritive in the default filter applied |
void |
validateNameFormat(java.lang.String name)
Check formatting constraints on the input string.
|
int |
warnRefreshDays() |
all, allowPreSelect, canCreate, canUpdate, checkComposite, convertToDestinationFilter, customiseForm, equals, exists, find, find, find, find, find, getAllIterator, getComposite, getComposites, getComposites, getConfigTag, getContext, getCount, getDefaults, getDestFilter, getExcludeFilter, getFieldConstraints, getFieldHelp, getFilter, getFilter, getFilter, getFinalSelectFilter, getFinalTableSpecification, getFindFilter, getFormCreator, getID, getIndex, getInput, getInput, getLogger, getMaxIdentifierLength, getNullable, getOrder, getProperty, getReferenced, getReferenceFieldType, getReferenceFieldType, getRemoteFilter, getRemoteSQLFilter, getResult, getResult, getSelector, getSelector, getTableSpecification, getTableStructureContributers, getTag, getTranslations, getUniqueIdName, hasComposite, hashCode, isMine, isMine, isMyReference, isValid, makeBDO, makeObject, makeRecord, makeReference, makeReference, matches, narrowSelector, narrowSelector, observeComposite, OrderBy, postSetContext, release, restrictDefaultInput, setComposites, setContext, setContext, setContextWithMake, setProperty, toString, updateTable
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getContext
public static final Feature BOOTSTRAP_ADMIN_FEATURE
public static final java.lang.String BOOTSTRAP_ROLE_PROPERTY
public static final Feature REQUIRE_PERSON_UPDATE_FEATURE
public static final Feature AUTO_COMPLETE_APPUSER_INPUT
public static final java.lang.String ALLOW_EMAIL_FIELD
public static final Feature ANONYMISE_DATABASE_FEATURE
protected AppUserFactory()
public AppUserFactory(AppContext conn, java.lang.String table)
public final AU findByEmail(java.lang.String email) throws DataException
DataException
public final AU findByEmail(java.lang.String email, boolean allow_null) throws DataException
DataException
protected java.util.Map<java.lang.String,Selector> getSelectors()
DataObjectFactory
getSelectors
in class DataObjectFactory<AU extends AppUser>
DataObjectFormFactory
protected java.util.Set<java.lang.String> getSupress()
DataObjectFactory
getSupress
in class DataObjectFactory<AU extends AppUser>
DataObjectFormFactory
public java.util.Set<RequiredPage<AU>> getRequiredPages()
RequiredPageProvider
getRequiredPages
in interface RequiredPageProvider<AU extends AppUser>
public SQLFilter<AU> getCanLoginFilter()
AppUser.canLogin()
SQLFilter
AppUser.canLogin()
public boolean isRegisteredUsername(java.lang.String username) throws DataException
username
- DataException
public DataObjectItemInput<AU> getRoleInput(java.lang.String role)
protected AppUserFactory.RoleFilter getRoleFilter(java.lang.String... roles)
protected final void postCreateTableSetup(AppContext c, java.lang.String table)
postCreateTableSetup
in class DataObjectFactory<AU extends AppUser>
protected void postAutoTableCreateSetup(AppContext ctx)
protected TableSpecification getDefaultTableSpecification(AppContext ctx, java.lang.String table)
DataObjectFactory
getDefaultTableSpecification
in class DataObjectFactory<AU extends AppUser>
ctx
- AppContexttable
- String table name.public java.lang.Class<AU> getTarget()
DataObjectFactory
IndexedProducer.getTarget()
. Normally this method should be overridden
each time we make a sub-class that narrows the produced type. However
checks should still pass if the super-type method is retained.public boolean needDetailsUpdate(AU user)
AppUserFactory.UpdatePersonRequiredPage
and the jsp pages that
update the personal details so if the corresponding feature is disabled it always return false.public int requireRefreshDays()
public int warnRefreshDays()
public BaseFilter<AU> getWarnRefreshFilter()
public BaseFilter<AU> getEmailFilter()
public <CB extends ContentBuilder> CB addUpdateNotes(CB cb, AU target)
cb
- public final AppUserNameFinder<AU,?> getRealmFinder(java.lang.String realm)
AppUserNameFinder
.
A null or empty string returns the first AppUserNameFinder
.realm
- public java.util.Collection<AppUserNameFinder> getRealms()
public boolean supportsRealm(java.lang.String realm)
public final AU findFromString(java.lang.String name)
NameFinder
NameFinder.getStringFinderFilter(String)
.findFromString
in interface NameFinder<AU extends AppUser>
findFromString
in interface ParseFactory<AU extends AppUser>
public java.lang.String getNameLabel()
public DataObjectItemInput<AU> getInput()
DataObjectFactory
Input
for this Factory
Default behaviour is to use the DataObjectFactory.getSelectFilter()
method to generate a DataObjectFactory.DataObjectInput
but not to restrict the parse values (default value of DataObjectFactory.restrictDefaultInput()
so existing values that don't
match the select filter are still valid.getInput
in interface Selector<DataObjectItemInput<AU extends AppUser>>
getInput
in class DataObjectFactory<AU extends AppUser>
protected boolean useAutoCompleteForSelect()
getInput()
If this is true and DataObjectFactory.restrictDefaultInput()
also returns true
we can afford to be more restritive in the default filter appliedpublic final DataObjectItemInput<AU> getNameInput(BaseFilter<AU> fil, boolean create, boolean restrict)
public java.lang.String getCanonicalName(AU object)
ParseFactory
ParseFactory.findFromString(String)
method.getCanonicalName
in interface ParseFactory<AU extends AppUser>
public java.lang.String getDefaultRealm()
public SQLFilter<AU> getStringFinderFilter(java.lang.String name)
NameFinder
NameFinder.findFromString(String)
getStringFinderFilter
in interface NameFinder<AU extends AppUser>
public SQLFilter<AU> getStringFinderFilter(java.lang.String name, boolean require_user_supplied)
public java.lang.String getSortName(AU user)
user
- public final AU makeFromString(java.lang.String name) throws DataFault, ParseException
NameFinder
NameFinder.findFromString(String)
but attempts to create a matching entry if one does not exist and this
is supported by the implementing class.makeFromString
in interface NameFinder<AU extends AppUser>
DataFault
ParseException
public AU makeUser() throws DataFault
DataFault
public DataCache<java.lang.String,AU> getDataCache()
NameFinder
getDataCache
in interface NameFinder<AU extends AppUser>
protected AU makeBDO(Repository.Record res) throws DataFault
DataObjectFactory
makeBDO
in class DataObjectFactory<AU extends AppUser>
res
- Record to create object fromDataFault
public void newSignup(AU user) throws java.lang.Exception
java.lang.Exception
public final FormCreator getSignupFormCreator(java.lang.String realm, java.lang.String webname)
FormCreator
to use when users sign-up
Optionally a name and a realm can be supplied which will be set as part of signup.
This is needed for external auth when the name is known but other details need to be
gathered via the form.realm
- String realm to set webname in (may be null)webname
- String name to setpublic boolean mustRegister(AU user)
RegisterTrigger
mustRegister
in interface RegisterTrigger<AU extends AppUser>
public void postRegister(AU user)
RegisterTrigger
RegisterTrigger.mustRegister(AppUser)
method returns false in the future.postRegister
in interface RegisterTrigger<AU extends AppUser>
public boolean autoCreate()
public void addAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes, AU 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<AU extends AppUser>
public void addUpdateAttributes(java.util.Map<java.lang.String,java.lang.Object> attributes, AU target)
public void validateNameFormat(java.lang.String name) throws ParseException
NameFinder
validateNameFormat
in interface NameFinder<AU extends AppUser>
ParseException
public BaseFilter<AU> hasRelationFilter(java.lang.String role, AU user)
AccessRoleProvider
BaseFilter
corresponding to target objects where the given user has
the specified relation.
If the method returns null then the role is not recognised by the provider.
A non-null result means the role is recognised but does not imply
that any target will match. The relation with a specific target object can be tested using
DataObjectFactory.matches(BaseFilter, DataObject)
This method should not be called directly only via a call to SessionService.getRelationshipRoleFilter(DataObjectFactory, String)
to allow the SessionService
to combine and customise access rules.hasRelationFilter
in interface AccessRoleProvider<AU extends AppUser,AU extends AppUser>
BaseFilter
or nullpublic BaseFilter<AU> personInRelationFilter(SessionService<AU> sess, java.lang.String role, AU target)
AccessRoleProvider
BaseFilter
for AppUser
s that are in the specified relationship with
the target object.
This is the inverse of #hasRelationFilter(SessionService, String)
used to generate a list
of AppUser
with the relation. It can always be implemented (inefficiently) by creating an AcceptFilter
that uses AccessRoleProvider.hasRelationFilter(String, AppUser)
to check each person in turn but though it is usually possible to find some SQLFilter
to narrow the selection first even if a full SQL implementation is not possible.
If the target is null it should generate a filter for any user in relation with targets
selected by DataObjectFactory.getDefaultRelationshipFilter()
. If this is not possible
it should return null;personInRelationFilter
in interface AccessRoleProvider<AU extends AppUser,AU extends AppUser>
BaseFilter
or nullpublic boolean providesRelationship(java.lang.String role)
AccessRoleProvider
providesRelationship
in interface AccessRoleProvider<AU extends AppUser,AU extends AppUser>
protected java.util.Set<java.lang.String> getOptional()
DataObjectFactory
DataObjectFactory.getNullable()
and remove any fields that should be forced to be mandatory.
Alternatively you can start with an empty set (defaulting to all fields mandatory) and add exceptions
Note that for legacy reasons a non-nullable String field CAN be made optional (the Repository
will map null values to the empty string)getOptional
in class DataObjectFactory<AU extends AppUser>
DataObjectFactory.getNullable()
public BaseFilter<AU> getSelectFilter()
DataObjectFactory
DataObjectFactory.getInput()
only uses this to control the presented options not
which options are valid unless the value of DataObjectFactory.restrictDefaultInput()
is also changed.getSelectFilter
in class DataObjectFactory<AU extends AppUser>
public FormUpdate<AU> getFormUpdate(AppContext c)
FormUpdateProducer
getFormUpdate
in interface FormUpdateProducer<AU extends AppUser>
getFormUpdate
in class DataObjectFactory<AU extends AppUser>
c
- AppContextpublic void anonymise() throws DataFault
anonymise
in interface AnonymisingFactory
DataFault
public boolean canErase(AU person)
public void erasePersonalData(AU p) throws DataFault
p
- DataFault
public SQLFilter<AU> getDefaultRelationshipFilter()
DataObjectFactory
SQLFilter
to use as the default target for relationship filters.
This should exclude targets that should not be used as relationship targets such as retired objects.getDefaultRelationshipFilter
in class DataObjectFactory<AU extends AppUser>
public Table<java.lang.String,AU> getPersonTable(SessionService<?> sess, BaseFilter<AU> fil) throws DataFault
DataFault
public void addRelationships(java.util.Set<java.lang.String> roles)
AccessRoleProvider
addRelationships
in interface AccessRoleProvider<AU extends AppUser,AU extends AppUser>