Spring Security
  1. Spring Security
  2. SEC-1107

Support java.lang.Number as identifier or throw an appropriate Exception when identifier is no java.lang.Long

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.0.4
    • Fix Version/s: 3.0.0 M1
    • Component/s: ACLs
    • Labels:
      None

      Description

      There are some places which expect objectIdentity.getIdentifier() to return a java.lang.Long.

      I my case the objects I wanted to secure had an Id of type Integer. Since Integers do have a longValue() I expected no problems. But the MutableAclServiceImpl was not able to deal with it.

      In JdbcMutableAclService. createAcl(ObjectIdentity objectIdentity) the call readAclById(objectIdentity) fails with a NotFoundException although createObjectIdentity() should have ensured the existence.

      public MutableAcl createAcl(ObjectIdentity objectIdentity)
      throws AlreadyExistsException {

      // [...]
      // Create the acl_object_identity row
      createObjectIdentity(objectIdentity, sid);

      // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc)
      Acl acl = readAclById(objectIdentity);
      // [...]
      }

      Example for the explicit expectation of Long can be found in

      protected void createEntries(final MutableAcl acl) in JdbcMutableAclService.java:

      line 136:
      stmt.setLong(1, ((Long) acl.getId()).longValue());

        Issue Links

          Activity

          Hide
          Luke Taylor added a comment - - edited

          I haven't been able to reproduce the problem you report - I suspect it has been fixed by recent changes to the ObjectIdentityImpl class hashode and equals methods for another issue.

          So I can successfully call createAcl() with an ObjectIdentity which has an Integer as the id.

          The line you refer to for the explicit expectation of a Long is for the Acl ID, not that of the domain object itself, so isn't quite the same thing. The default implementation currently expects that the key int the database will be a Long.

          Ideally we would like the implementation to function with integral numeric types and UID strings for object IDs, but that would probably require quite a bit of work and isn't likely to be something we can achieve in the near future.

          Show
          Luke Taylor added a comment - - edited I haven't been able to reproduce the problem you report - I suspect it has been fixed by recent changes to the ObjectIdentityImpl class hashode and equals methods for another issue. So I can successfully call createAcl() with an ObjectIdentity which has an Integer as the id. The line you refer to for the explicit expectation of a Long is for the Acl ID, not that of the domain object itself, so isn't quite the same thing. The default implementation currently expects that the key int the database will be a Long. Ideally we would like the implementation to function with integral numeric types and UID strings for object IDs, but that would probably require quite a bit of work and isn't likely to be something we can achieve in the near future.
          Hide
          Luke Taylor added a comment -

          There is already a request for the default implemetation to support other primary key types (SEC-972) so I'll close this unless you have any other relevant comments.

          Show
          Luke Taylor added a comment - There is already a request for the default implemetation to support other primary key types ( SEC-972 ) so I'll close this unless you have any other relevant comments.
          Hide
          Luke Taylor added a comment -

          Closing as "cannot reproduce" as I was able to use an Integer for the id. Probably fixed by other changes.

          Show
          Luke Taylor added a comment - Closing as "cannot reproduce" as I was able to use an Integer for the id. Probably fixed by other changes.

            People

            • Assignee:
              Luke Taylor
              Reporter:
              Martin Pietsch
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: