title: Allowing UUID values for ObjectIdentity.getIdentifier() in spring-security-acl
body: <p>I'd like to discuss contributing a solution to allowing UUID values for ObjectIdentity.getIdentifier() in spring-security-acl, <a href="https://jira.spring.io/browse/SEC-972" rel="noreferrer">SEC-972</a>. The Spring Security Contributing guidelines point to Spring Security forums, which are now closed and point to Stack Overflow, so hopefully I'm asking in the right place.</p>
  
  <p>My solution adds a new column to the acl_class table, class_id_type, that optionally allows you to specify the Java type for that acl_class. If you wire in a ConversionService to BasicLookupStrategy and the acl_class has a class_id_type specified, the ConversionService will be used to convert the identifier to the right type. This adds a dependency on spring-core.</p>
  
  <p>The acl_class schema looks like this:</p>
  
  <pre><code>create table acl_class(
      id bigint generated by default as identity(start with 100) not null primary key,
      class varchar_ignorecase(100) not null,
      class_id_type varchar_ignorecase(100),
      constraint unique_uk_2 unique(class)
  );
  </code></pre>
  
  <p>The definition of the lookupStrategy then looks like this:</p>
  
  <pre><code>&lt;bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"/&gt;
  &lt;!-- Declare a lookup strategy--&gt;
  &lt;bean id="lookupStrategy" class="org.springframework.security.acls.jdbc.BasicLookupStrategy"&gt;
      &lt;constructor-arg ref="dataSource"/&gt;
      &lt;constructor-arg ref="aclCache"/&gt;
      &lt;constructor-arg ref="aclAuthorizationStrategy"/&gt;
      &lt;constructor-arg ref="permissionGrantingStrategy"/&gt;
      &lt;constructor-arg ref="conversionService"/&gt;
      &lt;property name="permissionFactory" ref="permissionFactory"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>The tweaks to BasicLookupStrategy.convertCurrentResultIntoObject() look like this:</p>
  
  <pre><code>// If the Java type is a String, check to see if we can convert it to the target id type, e.g. UUID.
  Serializable identifier = (Serializable) rs.getObject("object_id_identity");
  if (isString(identifier) &amp;&amp; hasValidClassIdType(rs)
          &amp;&amp; canConvertFromStringTo(classIdTypeFrom(rs))) {
  
      identifier = convertFromStringTo((String) identifier, classIdTypeFrom(rs));
  }
  ObjectIdentity objectIdentity = new ObjectIdentityImpl(rs.getString("class"),
          identifier);
  </code></pre>
  
  <p>You can view the changes in a branch in this fork - <a href="https://github.com/pwheel/spring-security/tree/feature/acl-uuid-strings" rel="noreferrer">https://github.com/pwheel/spring-security/tree/feature/acl-uuid-strings</a>.</p>
  
  <p>That branch contains some changes that are not relevant (e.g. private Maven repo) so please don't consider that branch a pull request in its own right. This change seems like a 'non-trivial' change so as per the contributing guidelines I'd like to discuss it before raising a pull request.</p>
  
  <p>Note also that I found in my application I needed to implement a version of JdbcMutableAclService that uses the JdbcTemplate methods that take the SQL Types as arguments - this was because otherwise the MySQL connector maps UUID to binary rather than String, resulting in UTF-8 errors being thrown. I can add that to a pull request.</p>
  
  <p>I am using this setup in production without any issues.</p>
  
  <p>Are there any changes or improvements I should make before raising a pull request?</p>
  
  <p>Thanks</p>