public class User extends Object implements ParaObject
| Modifier and Type | Class and Description |
|---|---|
static class |
User.Groups
Simple groups enum.
|
static class |
User.Roles
Simple user roles enum.
|
Votable.VoteValue| Constructor and Description |
|---|
User()
No-args constructor.
|
User(String id)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
activateWithEmailToken(String token)
Activates a user if a given token matches the one stored.
|
void |
attachIdentifier(String identifier)
Attaches a new identifier to this user.
|
boolean |
canModify(ParaObject obj)
Note: this method assumes that child objects can be modified by their parents.
|
Long |
countChildren(String type)
Count the total number of child objects for this object.
|
Long |
countLinks(String type2)
Count the total number of links between this object and another type of object.
|
String |
create()
Stores this object in the data store.
|
void |
delete()
Deletes the object permanently by removing it from the data store.
|
void |
deleteChildren(String type)
Deletes all child objects permanently.
|
void |
detachIdentifier(String identifier)
Detaches a secondary identifier which is not already used by this user.
|
boolean |
equals(Object obj) |
boolean |
exists()
Checks if an object is stored in the data store.
|
<P extends ParaObject> |
findChildren(String type,
String query,
Pager... pager)
Search through all child objects.
|
<P extends ParaObject> |
findLinkedObjects(String type,
String field,
String query,
Pager... pager)
Similar to
Linkable.findChildren(java.lang.String, java.lang.String, com.erudika.para.utils.Pager...)
but for many-to-many relationships. |
String |
generateEmailConfirmationToken()
Generates a new email confirmation token.
|
String |
generatePasswordResetToken()
Generates a new password reset token.
|
Boolean |
getActive()
Returns true if this account is active.
|
String |
getAppid()
The application name.
|
Boolean |
getCached()
Boolean flag which controls whether this object is cached.
|
<P extends ParaObject> |
getChildren(String type,
Pager... pager)
Returns all child objects linked to this object.
|
<P extends ParaObject> |
getChildren(String type,
String field,
String term,
Pager... pager)
Returns all child objects linked to this object.
|
String |
getCreatorid()
The id of the user who created this.
|
String |
getCurrency()
The user's currency preference.
|
String |
getEmail()
The user's email.
|
String |
getGroups()
Returns the security groups for this user.
|
String |
getId()
The id of an object.
|
String |
getIdentifier()
Returns the main identifier for this user.
|
List<Sysprop> |
getIdentifiers()
Returns a list of identifiers for this user (can have many).
|
String |
getIdentityProvider()
Returns the name of the identity provider.
|
Boolean |
getIndexed()
Boolean flag which controls whether this object is indexed
by the search engine.
|
String |
getLastIp()
The IP address of the user recorded on last login.
|
<P extends ParaObject> |
getLinkedObjects(String type,
Pager... pager)
Similar to
Linkable.getChildren(java.lang.String, com.erudika.para.utils.Pager...)
but for many-to-many relationships. |
List<Linker> |
getLinks(String type2,
Pager... pager)
Returns all links between this type object and another type of object.
|
String |
getName()
The name of the object.
|
String |
getObjectURI()
The URI of this object.
|
String |
getParentid()
The id of the parent object.
|
String |
getPassword()
The password.
|
String |
getPicture()
The profile picture URL.
|
String |
getPlural()
The plural name of the object.
|
Boolean |
getStored()
Boolean flag which controls whether this object is stored
in the database or not.
|
List<String> |
getTags()
The tags associated with this object.
|
Long |
getTimestamp()
The time when the object was created, in milliseconds.
|
String |
getTokenSecret()
Token secret - used for generating JWT tokens.
|
Boolean |
getTwoFA() |
String |
getTwoFAbackupKeyHash() |
String |
getTwoFAkey() |
String |
getType()
The name of the object's class.
|
Long |
getUpdated()
The last time this object was updated.
|
Long |
getVersion()
Returns the version number for this object.
|
Integer |
getVotes()
Returns the total sum of all votes for this object.
|
int |
hashCode() |
boolean |
isAdmin()
Checks for admin rights.
|
boolean |
isFacebookUser()
Is the main identifier a Facebook id.
|
boolean |
isGitHubUser()
Is the main identifier a GitHub id.
|
boolean |
isGooglePlusUser()
Is the main identifier a Google+ id.
|
boolean |
isLinked(ParaObject toObj)
Checks if a given object is linked to this one.
|
boolean |
isLinked(String type2,
String id2)
Checks if this object is linked to another.
|
boolean |
isLinkedInUser()
Is the main identifier a LinkedIn id.
|
boolean |
isMicrosoftUser()
Is the main identifier a Microsoft/Windows account id.
|
boolean |
isModerator()
Checks for moderator rights.
|
boolean |
isTwitterUser()
Is the main identifier a Twitter id.
|
boolean |
isValidEmailConfirmationToken(String token)
Validates a token sent for email confirmation.
|
boolean |
isValidPasswordResetToken(String token)
Validates a token sent via email for password reset.
|
String |
link(String id2)
Links an object to this one in a many-to-many relationship.
|
static boolean |
passwordMatches(User u)
Checks if a user has entered the correct password.
|
static User |
readUserForIdentifier(User u)
Returns a user object for a given identifier.
|
boolean |
resetPassword(String token,
String newpass)
Changes the user password permanently.
|
void |
resetTokenSecret()
Generates a new token secret.
|
void |
setActive(Boolean active)
Sets the account active.
|
void |
setAppid(String appid)
Sets a new app name.
|
void |
setCached(Boolean cached)
Sets the "isCached" flag.
|
void |
setCreatorid(String creatorid)
Sets a new creator id.
|
void |
setCurrency(String currency)
Sets a preferred currency.
|
void |
setEmail(String email)
Sets the email.
|
void |
setGroups(String groups)
Sets the security groups for this user.
|
void |
setId(String id)
Sets a new id.
|
void |
setIdentifier(String identifier)
Sets the main identifier.
|
void |
setIndexed(Boolean indexed)
Sets the "isIndexed" flag.
|
void |
setLastIp(String lastIp)
Sets the IP of the user.
|
void |
setName(String name)
Sets a new name.
|
void |
setParentid(String parentid)
Sets a new parent id.
|
void |
setPassword(String password)
Sets a password.
|
void |
setPicture(String picture)
Sets the profile picture URL.
|
void |
setStored(Boolean stored)
Sets the "isStored" flag.
|
void |
setTags(List<String> tags)
Merges the given tags with existing tags.
|
void |
setTimestamp(Long timestamp)
Sets the timestamp.
|
void |
setTokenSecret(String tokenSecret)
Sets the token secret.
|
void |
setTwoFA(Boolean twoFA)
Sets 2FA enabled/disabled.
|
void |
setTwoFAbackupKeyHash(String twoFAbackupKeyHash)
Sets the 2FA backup key hash.
|
void |
setTwoFAkey(String twoFAkey)
Sets the 2FA secret key.
|
void |
setType(String type)
Sets a new object type.
|
void |
setUpdated(Long updated)
Sets the last updated timestamp.
|
void |
setVersion(Long version)
Sets the version of this object.
|
void |
setVotes(Integer votes)
Sets the total votes for this object.
|
String |
toString() |
void |
unlink(String type,
String id2)
Unlinks an object from this one.
|
void |
unlinkAll()
Unlinks all objects that are linked to this one.
|
void |
update()
Updates the object permanently.
|
boolean |
voteDown(String userid)
Downvotes the object.
|
boolean |
voteUp(String userid)
Upvotes the object.
|
public User()
public User(String id)
id - the idpublic String getTokenSecret()
public void setTokenSecret(String tokenSecret)
tokenSecret - a random stringpublic String getLastIp()
public void setLastIp(String lastIp)
lastIp - last known IP addresspublic String getPicture()
public void setPicture(String picture)
picture - the picture URL.public Boolean getActive()
public void setActive(Boolean active)
active - true if activepublic Boolean getTwoFA()
public void setTwoFA(Boolean twoFA)
twoFA - true if 2FA is enabledpublic String getTwoFAkey()
public void setTwoFAkey(String twoFAkey)
twoFAkey - secret keypublic String getTwoFAbackupKeyHash()
public void setTwoFAbackupKeyHash(String twoFAbackupKeyHash)
twoFAbackupKeyHash - bcrypt hashpublic String getGroups()
public void setGroups(String groups)
groups - the groups stringpublic String getIdentifier()
public void setIdentifier(String identifier)
identifier - the main identifierpublic String getEmail()
public void setEmail(String email)
email - emailpublic String getCurrency()
public void setCurrency(String currency)
currency - a 3-letter currency codepublic void resetTokenSecret()
public boolean canModify(ParaObject obj)
obj - an objectpublic String create()
ParaObjectcreate in interface ParaObjectStored,
DAO.create(com.erudika.para.core.ParaObject)public void delete()
ParaObjectdelete in interface ParaObjectDAO.delete(com.erudika.para.core.ParaObject)public List<Sysprop> getIdentifiers()
Sysprop objectspublic void attachIdentifier(String identifier)
identifier - a new identifierpublic void detachIdentifier(String identifier)
identifier - an attached identifierpublic boolean isFacebookUser()
public boolean isGooglePlusUser()
public boolean isLinkedInUser()
public boolean isTwitterUser()
public boolean isGitHubUser()
public boolean isMicrosoftUser()
public boolean isAdmin()
public boolean isModerator()
public String getIdentityProvider()
public String getPassword()
public void setPassword(String password)
password - a passwordpublic static final User readUserForIdentifier(User u)
u - a user having a valid identifier set.public static final boolean passwordMatches(User u)
u - a user with a set passwordpublic final String generatePasswordResetToken()
public final boolean resetPassword(String token, String newpass)
token - the reset token. see generatePasswordResetToken()newpass - the new passwordpublic String generateEmailConfirmationToken()
public final boolean activateWithEmailToken(String token)
token - the email confirmation token. see generateEmailConfirmationToken()public final boolean isValidPasswordResetToken(String token)
token - a tokenpublic final boolean isValidEmailConfirmationToken(String token)
token - a tokenpublic final String getId()
ParaObjectgetId in interface ParaObjectpublic final void setId(String id)
ParaObjectsetId in interface ParaObjectid - the new idpublic final String getType()
ParaObjectClass.getSimpleName().toLowerCase()getType in interface ParaObjectpublic final void setType(String type)
ParaObjectsetType in interface ParaObjecttype - a new typepublic String getAppid()
ParaObjectgetAppid in interface ParaObjectpublic void setAppid(String appid)
ParaObjectsetAppid in interface ParaObjectappid - the new app id (name)public String getObjectURI()
ParaObjectgetObjectURI in interface ParaObjectUtils.getObjectURI(com.erudika.para.core.ParaObject, boolean, boolean)public List<String> getTags()
ParaObjectgetTags in interface ParaObjectTagpublic void setTags(List<String> tags)
ParaObjectsetTags in interface ParaObjecttags - the additional tags, or clears all tags if set to nullpublic Boolean getStored()
ParaObjectgetStored in interface ParaObjectpublic void setStored(Boolean stored)
ParaObjectsetStored in interface ParaObjectstored - when set to true, object is stored in DB.public Boolean getIndexed()
ParaObjectgetIndexed in interface ParaObjectpublic void setIndexed(Boolean indexed)
ParaObjectsetIndexed in interface ParaObjectindexed - when set to true, object is indexed.public Boolean getCached()
ParaObjectgetCached in interface ParaObjectpublic void setCached(Boolean cached)
ParaObjectsetCached in interface ParaObjectcached - when set to true, object is cached.public Long getTimestamp()
ParaObjectgetTimestamp in interface ParaObjectpublic void setTimestamp(Long timestamp)
ParaObjectsetTimestamp in interface ParaObjecttimestamp - a new timestamp in milliseconds.public String getCreatorid()
ParaObjectUser id.getCreatorid in interface ParaObjectpublic void setCreatorid(String creatorid)
ParaObjectsetCreatorid in interface ParaObjectcreatorid - a new idpublic final String getName()
ParaObjectgetName in interface ParaObjectpublic final void setName(String name)
ParaObjectsetName in interface ParaObjectname - the new namepublic String getPlural()
ParaObjectgetPlural in interface ParaObjectpublic String getParentid()
ParaObjectgetParentid in interface ParaObjectpublic void setParentid(String parentid)
ParaObjectsetParentid in interface ParaObjectparentid - a new idpublic Long getUpdated()
ParaObjectgetUpdated in interface ParaObjectpublic void setUpdated(Long updated)
ParaObjectsetUpdated in interface ParaObjectupdated - a new timestamppublic void update()
ParaObjectLocked fields are ignored.update in interface ParaObjectLocked,
DAO.update(com.erudika.para.core.ParaObject)public boolean exists()
ParaObjectexists in interface ParaObjectDAO.read(java.lang.String)public boolean voteUp(String userid)
Votablepublic boolean voteDown(String userid)
Votablepublic Integer getVotes()
Votablepublic void setVotes(Integer votes)
Votablepublic Long getVersion()
ParaObjectgetVersion in interface ParaObject0 if unused or -1, indicating a failed update.public void setVersion(Long version)
ParaObjectsetVersion in interface ParaObjectversion - a positive number, different than the current value of the version fieldpublic Long countLinks(String type2)
LinkablecountLinks in interface Linkabletype2 - the other type of objectpublic List<Linker> getLinks(String type2, Pager... pager)
Linkablepublic <P extends ParaObject> List<P> getLinkedObjects(String type, Pager... pager)
LinkableLinkable.getChildren(java.lang.String, com.erudika.para.utils.Pager...)
but for many-to-many relationships.getLinkedObjects in interface LinkableP - type of linked objectstype - type of linked objects to look forpager - a Pagerpublic <P extends ParaObject> List<P> findLinkedObjects(String type, String field, String query, Pager... pager)
LinkableLinkable.findChildren(java.lang.String, java.lang.String, com.erudika.para.utils.Pager...)
but for many-to-many relationships. Searches through all linked objects connected to this via
a Linker object.findLinkedObjects in interface LinkableP - type of linked objectstype - type of linked objects to look forfield - the name of the field to target (within a nested field "nstd")query - a query stringpager - a Pagerpublic boolean isLinked(String type2, String id2)
Linkablepublic boolean isLinked(ParaObject toObj)
Linkablepublic String link(String id2)
Linkablepublic void unlink(String type, String id2)
Linkablepublic void unlinkAll()
LinkableLinker objects. Only the links are deleted. Objects are left untouched.public Long countChildren(String type)
LinkablecountChildren in interface Linkabletype - the other type of objectpublic <P extends ParaObject> List<P> getChildren(String type, Pager... pager)
LinkablegetChildren in interface LinkableP - the type of childrentype - the type of children to look forpager - a PagerParaObject in a one-to-many relationship with this objectpublic <P extends ParaObject> List<P> getChildren(String type, String field, String term, Pager... pager)
LinkablegetChildren in interface LinkableP - the type of childrentype - the type of children to look forfield - the field name to use as filterterm - the field value to use as filterpager - a PagerParaObject in a one-to-many relationship with this objectpublic <P extends ParaObject> List<P> findChildren(String type, String query, Pager... pager)
Linkableparentid field.findChildren in interface LinkableP - the type of childrentype - the type of children to look forquery - a query stringpager - a PagerParaObject in a one-to-many relationship with this objectpublic void deleteChildren(String type)
LinkabledeleteChildren in interface Linkabletype - the children's type.Copyright © 2018 Erudika. All rights reserved.