Changeset 7406


Ignore:
Timestamp:
Oct 5, 2017, 8:57:58 AM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2097: Implement support for device verification

Added UserDevice class to the core layer API.

A permission key for roles is created by the install script.

Added the device column to the sessions list and view page.

Added NameableData to the device since it will be a lot easier to use in listings, etc.

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/PermissionUtil.java

    r7214 r7406  
    187187        {
    188188          Item.USER, Item.GROUP, Item.ROLE, Item.QUOTA, Item.QUOTATYPE,
    189           Item.NEWS, Item.CLIENT, Item.SESSION, Item.SETTING, Item.DISKUSAGE
     189          Item.NEWS, Item.CLIENT, Item.SESSION, Item.USERDEVICE, Item.SETTING, Item.DISKUSAGE
    190190        })
    191191      );
  • trunk/src/core/net/sf/basedb/core/Install.java

    r7405 r7406  
    399399      createRoleKey(Item.MIMETYPE, "Mime types", "Gives access to mime types", administrators_all);
    400400      createRoleKey(Item.SESSION, "Sessions", "Gives access to sessions", administrators_read);
     401      createRoleKey(Item.USERDEVICE, "User devices", "Gives access to user devices", administrators_all);
    401402      createRoleKey(Item.SETTING, "Settings", "Gives access to settings", administrators_all);
    402403      createRoleKey(Item.MESSAGE, "Messages", "Gives access to messages", users_create);
  • trunk/src/core/net/sf/basedb/core/Item.java

    r7214 r7406  
    135135  USERCLIENTSETTING(48, "User client setting", "ucs", UserClientSetting.class, UserClientSettingData.class, DefinedPermissions.basic,
    136136    1250),
     137  /**
     138    The item is an {@link UserDevice}.
     139  */
     140  USERDEVICE(49, "User device", "dev", UserDevice.class, UserDeviceData.class, DefinedPermissions.delete,
     141    1205),
    137142
    138143  /**
     
    10221027    private static final Set<Permission> read = Collections.unmodifiableSet(EnumSet.of(Permission.READ));
    10231028    private static final Set<Permission> write = Collections.unmodifiableSet(EnumSet.of(Permission.READ, Permission.USE, Permission.WRITE));
     1029    private static final Set<Permission> delete = Collections.unmodifiableSet(EnumSet.of(Permission.READ, Permission.USE, Permission.WRITE, Permission.DELETE));
    10241030    private static final Set<Permission> basic = Collections.unmodifiableSet(EnumSet.of(Permission.CREATE, Permission.READ, Permission.USE, Permission.WRITE, Permission.DELETE));
    10251031    private static final Set<Permission> ownable = Collections.unmodifiableSet(EnumSet.of(Permission.CREATE, Permission.READ, Permission.USE, Permission.WRITE, Permission.DELETE, Permission.SET_OWNER));
  • trunk/src/core/net/sf/basedb/core/Session.java

    r7165 r7406  
    168168    return getDbControl().getItem(Client.class, getData().getClient());
    169169  }
     170 
     171  /**
     172    Get the device the user was using in this session.
     173 
     174    @return A <code>UserDevice</code> item, or null if not known
     175    @throws PermissionDeniedException If the logged in user doesn't
     176      have {@link Permission#READ} permission
     177    @throws BaseException If there is another error
     178    @since 3.12
     179  */
     180  public UserDevice getDevice()
     181    throws PermissionDeniedException, BaseException
     182  {
     183    return getDbControl().getItem(UserDevice.class, getData().getDevice());
     184  }
    170185
    171186  /**
  • trunk/src/core/net/sf/basedb/core/data/UserDeviceData.java

    r7405 r7406  
    3737public class UserDeviceData
    3838  extends BasicData
    39   implements RegisteredData
     39  implements RegisteredData, NameableData
    4040{
    4141  public UserDeviceData()
     
    8383  {
    8484    this.entryDate = entryDate;
     85  }
     86  // -------------------------------------------
     87  /*
     88    From the NameableData interface
     89    -------------------------------------------
     90  */ 
     91  private String name;
     92  @Override
     93  public String getName()
     94  {
     95    return name;
     96  }
     97 
     98  @Override
     99  public void setName(String name)
     100  {
     101    this.name = name;
     102  }
     103 
     104  private String description;
     105  @Override
     106  public String getDescription()
     107  {
     108    return description;
     109  }
     110 
     111  @Override
     112  public void setDescription(String description)
     113  {
     114    this.description = description;
    85115  }
    86116  // -------------------------------------------
  • trunk/www/views/sessions/list_sessions.jsp

    r7165 r7406  
    173173        datatype="string"
    174174        title="Client application"
     175        sortable="true"
     176        filterable="true"
     177        exportable="true"
     178      />
     179      <tbl:columndef
     180        id="device"
     181        property="device.name"
     182        datatype="string"
     183        title="Device"
    175184        sortable="true"
    176185        filterable="true"
     
    392401                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
    393402                  /></tbl:cell>
     403                <tbl:cell column="device"
     404                  ><base:propertyvalue
     405                    item="<%=item%>"
     406                    property="device"
     407                    nulltext="<i>- unknown -</i>"
     408                    enableEditLink="<%=mode.hasEditLink()%>"
     409                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
     410                  /></tbl:cell>
    394411                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
    395412                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
  • trunk/www/views/sessions/view_session.jsp

    r7165 r7406  
    3333  import="net.sf.basedb.core.Session"
    3434  import="net.sf.basedb.core.User"
     35  import="net.sf.basedb.core.UserDevice"
    3536  import="net.sf.basedb.core.Client"
    3637  import="net.sf.basedb.core.PermissionDeniedException"
     
    8586    readClient = false;
    8687  }
     88  boolean readDevice = true;
     89  UserDevice device = null;
     90  try
     91  {
     92    device = s.getDevice();
     93  }
     94  catch (Exception ex)
     95  {
     96    readDevice = false;
     97  }
    8798 
    8899  String title = "View session";
     
    105116        <th>Client application</th>
    106117        <td><%=Base.getEncodedName(client, !readClient)%></td>
     118      </tr>
     119      <tr>
     120        <th>Device</th>
     121        <td><%=Base.getEncodedName(device, !readDevice)%></td>
    107122      </tr>
    108123      <tr>
Note: See TracChangeset for help on using the changeset viewer.