Problems with object_id_identity in table acl_object_identity
Summary
In the Spring ACL database schema for PostgreSQL (specified in createAclSchemaPostgres.sql) definition for table acl_object_identity look like this:
create table acl_object_identity(
id bigserial primary key,
object_id_class bigint not null,
object_id_identity varchar(36) not null,
parent_object bigint,
owner_sid bigint,
entries_inheriting boolean not null,
-- constraints are omitted for brevity
);
So, column object_id_identity is of text type.
Actual Behavior
When I execute this piece of code
ObjectIdentity identity = new ObjectIdentityImpl("com.example.data.model.Card", "42");
MutableAcl acl = mutableAclService.createAcl(identity);
I get an exception telling me there is a problem with finding object identity:
org.springframework.security.acls.model.NotFoundException: Unable to find ACL information for object identity 'org.springframework.security.acls.domain.ObjectIdentityImpl[Type: com.example.data.model.Card; Identifier: 42]'
at org.springframework.security.acls.jdbc.JdbcAclService.readAclsById(JdbcAclService.java:136) ~[spring-security-acl-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.security.acls.jdbc.JdbcAclService.readAclById(JdbcAclService.java:112) ~[spring-security-acl-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.security.acls.jdbc.JdbcAclService.readAclById(JdbcAclService.java:120) ~[spring-security-acl-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.security.acls.jdbc.JdbcMutableAclService.createAcl(JdbcMutableAclService.java:122) ~[spring-security-acl-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at com.example.security.acl.AclModelService.create(AclModelService.java:22) ~[classes/:na]
Basically, there is a problem with resolving type of column object_id_identity in BasicLookupStrategy:639 While actually being String type, identifier is treated as of type Long. Later in code it leads to the aforementioned exception. I guess this check it totally pointless since the type of object_id_identity is text.
Expected Behavior
Such piece of code must execute correctly
ObjectIdentity identity = new ObjectIdentityImpl("com.example.data.model.Card", "42");
MutableAcl acl = mutableAclService.createAcl(identity);
Configuration
Standard configuration with schema provided in createAclSchemaPostgres.sql
Version
org.springframework.security:spring-security-acl:jar:5.0.8.RELEASE
Probably it's more correct to use Long instead of String as identifier of ObjectIdentityImpl.
ObjectIdentity identity = new ObjectIdentityImpl("com.example.data.model.Card", 42L);
MutableAcl acl = mutableAclService.createAcl(identity);
Later on the identifier would be converted to String before database insertion.
protected void createObjectIdentity(ObjectIdentity object, Sid owner) {
Long sidId = createOrRetrieveSidPrimaryKey(owner, true);
Long classId = createOrRetrieveClassPrimaryKey(object.getType(), true, object.getIdentifier().getClass());
jdbcOperations.update(insertObjectIdentity, classId, object.getIdentifier().toString(), sidId,
Boolean.TRUE);
It was an issue with conversion from Long to String before insertion but it is solved within 5508. Probably current issue could be closed.