Spring Security
  1. Spring Security
  2. SEC-1038

Error in JdbcMutableAclService with Postgres

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.4
    • Fix Version/s: 3.0.0 M1
    • Component/s: ACLs
    • Labels:
      None
    • Environment:
      Postgres

      Description

      When I use the Spring Security's ACL services with a Postgres database, I am getting the following error when I call the createAcl method in the JdbcMutableAclService class :
      Caused by: org.postgresql.util.PSQLException: ERROR: column "object_id_identity" is of type bigint but expression is of type character varying

      The problem is caused in the createObjectIdentity method by object.getIdentifier().toString() because the parameter is a string or the column is a bigint in the database.

      To solve the problem, you must cast to long :
      protected void createObjectIdentity(ObjectIdentity object, Sid owner) {
      Long sidId = createOrRetrieveSidPrimaryKey(owner, true);
      Long classId = createOrRetrieveClassPrimaryKey(object.getJavaType(), true);
      jdbcTemplate.update(insertObjectIdentity,
      new Object[]

      {classId, new Long(object.getIdentifier().toString()), sidId, new Boolean(true)}

      );
      }

      There is a thread in the forum about this problem : http://forum.springframework.org/showthread.php?t=56889

      Thomas

        Issue Links

          Activity

          Hide
          Luke Taylor added a comment -

          Looking at this, we can probably remove the toString() altogether and just use object.getIdentifier(). This should be the appropriate type for the schema (i.e. a Long in this case).

          Show
          Luke Taylor added a comment - Looking at this, we can probably remove the toString() altogether and just use object.getIdentifier(). This should be the appropriate type for the schema (i.e. a Long in this case).
          Hide
          Luke Taylor added a comment -

          I've modified the code to use the identifier explicitly and run the tests against a Postgres database. Also updated the schema appendix in the reference manual to include information on Postgres.

          Show
          Luke Taylor added a comment - I've modified the code to use the identifier explicitly and run the tests against a Postgres database. Also updated the schema appendix in the reference manual to include information on Postgres.
          Hide
          Thomas Champagne added a comment -

          I tested your patch in the current stable release (2.0.4) and it works fine.
          Thanks for your help.

          Show
          Thomas Champagne added a comment - I tested your patch in the current stable release (2.0.4) and it works fine. Thanks for your help.
          Hide
          Luke Taylor added a comment -

          Thanks for the feedback, Thomas. Closing the issue.

          Show
          Luke Taylor added a comment - Thanks for the feedback, Thomas. Closing the issue.

            People

            • Assignee:
              Luke Taylor
              Reporter:
              Thomas Champagne
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: