Class UserDeviceData

java.lang.Object
net.sf.basedb.core.data.BasicData
net.sf.basedb.core.data.UserDeviceData
All Implemented Interfaces:
IdentifiableData, NameableData, RegisteredData

public class UserDeviceData extends BasicData implements RegisteredData, NameableData
This class holds information about a verified user device. The getToken() is randomly generated token that each device is supposed to keep track of and submit together with the login info.
Since:
3.12
Author:
Nicklas
Hibernate: class
table="`UserDevices`" lazy="false"
  • Field Details

    • user

      private UserData user
    • client

      private ClientData client
    • entryDate

      private Date entryDate
    • name

      private String name
    • description

      private String description
    • MAX_TOKEN_LENGTH

      public static final int MAX_TOKEN_LENGTH
      The maximum length of the device token that can be stored in the database.
      See Also:
    • token

      private String token
    • MAX_USER_AGENT_LENGTH

      public static final int MAX_USER_AGENT_LENGTH
      The maximum length of the user agent that can be stored in the database.
      See Also:
    • userAgent

      private String userAgent
    • lastUsed

      private Date lastUsed
    • MAX_REMOTE_ID_LENGTH

      public static final int MAX_REMOTE_ID_LENGTH
      The maximum length of the remote ID that can be stored in the database.
      See Also:
    • remoteId

      private String remoteId
    • MAX_LOCATION_LENGTH

      public static final int MAX_LOCATION_LENGTH
      The maximum length of the location that can be stored in the database.
      See Also:
    • location

      private String location
    • locationLat

      private Float locationLat
    • locationLong

      private Float locationLong
    • isVerified

      private boolean isVerified
    • sessions

      private Set<SessionData> sessions
  • Constructor Details

    • UserDeviceData

      public UserDeviceData()
  • Method Details

    • getUser

      public UserData getUser()
      The user that this device is associated with.
      Hibernate: many-to-one
      column="`user_id`" not-null="true" update="false" outer-join="false"
    • setUser

      public void setUser(UserData user)
    • getClient

      public ClientData getClient()
      Get the client application this device is associated with.
      Hibernate: many-to-one
      column="`client_id`" not-null="true" update="false" outer-join="false"
    • setClient

      public void setClient(ClientData client)
    • getEntryDate

      public Date getEntryDate()
      Description copied from interface: RegisteredData
      Get the date this item was added to the database. The value is generated at creation time and can't be modified later.
      Specified by:
      getEntryDate in interface RegisteredData
    • setEntryDate

      public void setEntryDate(Date entryDate)
    • getName

      public String getName()
      Description copied from interface: NameableData
      Get the name of the item.
      Specified by:
      getName in interface NameableData
      Returns:
      A String with the name of the item
    • setName

      public void setName(String name)
      Description copied from interface: NameableData
      Set the name of the item. The name cannot be null and mustn't be longer than the value specified by the MAX_NAME_LENGTH constant.
      Specified by:
      setName in interface NameableData
      Parameters:
      name - The new name for the item
    • getDescription

      public String getDescription()
      Description copied from interface: NameableData
      Get the description for the item.
      Specified by:
      getDescription in interface NameableData
      Returns:
      A String with a description of the item
    • setDescription

      public void setDescription(String description)
      Description copied from interface: NameableData
      Set the description for the item. The description can be null but mustn't be longer than the value specified by the MAX_DESCRIPTION_LENGTH constant.
      Specified by:
      setDescription in interface NameableData
      Parameters:
      description - The new description for the item
    • getToken

      public String getToken()
      Get the device token.
      Hibernate: property
      column="`token`" type="string" length="255" not-null="true" update="false"
    • setToken

      public void setToken(String token)
    • getUserAgent

      public String getUserAgent()
      Get a string with more information about the device (eg. User-Agent from a web browser).
      Hibernate: property
      column="`user_agent`" type="text" not-null="false"
    • setUserAgent

      public void setUserAgent(String userAgent)
    • getLastUsed

      public Date getLastUsed()
      Get the date and time the user last logged in from this device.
      Hibernate: property
      column="`last_used`" type="timestamp" not-null="true"
    • setLastUsed

      public void setLastUsed(Date lastUsed)
    • getLastRemoteId

      public String getLastRemoteId()
      Get the remote id (=ip address) of the last login from this device.
      Hibernate: property
      column="`lastremote_id`" type="string" length="255" not-null="false"
    • setLastRemoteId

      public void setLastRemoteId(String remoteId)
    • getLocation

      public String getLocation()
      Get the location of the user (if known).
      Hibernate: property
      column="`location`" type="string" length="255" not-null="false"
    • setLocation

      public void setLocation(String location)
    • getLocationLatitude

      public Float getLocationLatitude()
      Get the location latitude of the user (if known).
      Hibernate: property
      column="`location_lat`" type="float" not-null="false"
    • setLocationLatitude

      public void setLocationLatitude(Float locationLat)
    • getLocationLongitude

      public Float getLocationLongitude()
      Get the location longitude of the user (if known).
      Hibernate: property
      column="`location_long`" type="float" not-null="false"
    • setLocationLongitude

      public void setLocationLongitude(Float locationLong)
    • isVerified

      public boolean isVerified()
      This flag is TRUE if the device has been verified (by sending a code via email).
      Since:
      3.17 Mapped in hibernate-properties-UserDeviceData.xml since default is not supported in XDoclet //hibernate.property column="`is_verified`" type="boolean" not-null="true" default="false"
    • setVerified

      public void setVerified(boolean isVerified)
    • getSessions

      Set<SessionData> getSessions()
      This is the inverse end but we do not map with inverse="true" cascade="delete" since we want Hibernate to set SessionData.device_id = null instead of deleting sessions.
      See Also:
      Hibernate: set
      lazy="true"
      Hibernate: collection-key
      column="`device_id`"
      Hibernate: collection-one-to-many
      class="net.sf.basedb.core.data.SessionData"
    • setSessions

      void setSessions(Set<SessionData> sessions)