Skip to content

Commit 8efec02

Browse files
committed
Made AclClassIdUtils genuinely package level by injecting the conversionService instead of AclClassIdUtils
Fixes gh-4814
1 parent 285b5e9 commit 8efec02

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

acl/src/main/java/org/springframework/security/acls/jdbc/AclClassIdUtils.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* the correct Java type as specified by <code>acl_class.class_id_type</code>.
3030
* @author paulwheeler
3131
*/
32-
public class AclClassIdUtils {
32+
class AclClassIdUtils {
3333
private static final String DEFAULT_CLASS_ID_TYPE_COLUMN_NAME = "class_id_type";
3434
private static final Log log = LogFactory.getLog(AclClassIdUtils.class);
3535

@@ -38,6 +38,10 @@ public class AclClassIdUtils {
3838
public AclClassIdUtils() {
3939
}
4040

41+
public AclClassIdUtils(ConversionService conversionService) {
42+
this.conversionService = conversionService;
43+
}
44+
4145
/**
4246
* Converts the raw type from the database into the right Java type. For most applications the 'raw type' will be Long, for some applications
4347
* it could be String.

acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import javax.sql.DataSource;
3232

3333
import org.springframework.core.convert.ConversionException;
34+
import org.springframework.core.convert.ConversionService;
3435
import org.springframework.jdbc.core.JdbcTemplate;
3536
import org.springframework.jdbc.core.PreparedStatementSetter;
3637
import org.springframework.jdbc.core.ResultSetExtractor;
@@ -553,8 +554,8 @@ public final void setAclClassIdSupported(boolean aclClassIdSupported) {
553554
}
554555
}
555556

556-
public final void setAclClassIdUtils(AclClassIdUtils aclClassIdUtils) {
557-
this.aclClassIdUtils = aclClassIdUtils;
557+
public final void setConversionService(ConversionService conversionService) {
558+
this.aclClassIdUtils = new AclClassIdUtils(conversionService);
558559
}
559560

560561
// ~ Inner Classes

acl/src/main/java/org/springframework/security/acls/jdbc/JdbcAclService.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import org.apache.commons.logging.Log;
2828
import org.apache.commons.logging.LogFactory;
29+
import org.springframework.core.convert.ConversionService;
2930
import org.springframework.jdbc.core.JdbcTemplate;
3031
import org.springframework.jdbc.core.RowMapper;
3132
import org.springframework.security.acls.domain.ObjectIdentityImpl;
@@ -163,8 +164,8 @@ public void setAclClassIdSupported(boolean aclClassIdSupported) {
163164
}
164165
}
165166

166-
public void setAclClassIdUtils(AclClassIdUtils aclClassIdUtils) {
167-
this.aclClassIdUtils = aclClassIdUtils;
167+
public void setConversionService(ConversionService conversionService) {
168+
this.aclClassIdUtils = new AclClassIdUtils(conversionService);
168169
}
169170

170171
protected boolean isAclClassIdSupported() {

acl/src/test/java/org/springframework/security/acls/jdbc/BasicLookupStrategyWithAclClassTypeTests.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,11 @@ public static void dropDatabase() throws Exception {
7070
@Before
7171
public void initializeBeans() {
7272
super.initializeBeans();
73-
AclClassIdUtils aclClassIdUtils = new AclClassIdUtils();
74-
aclClassIdUtils.setConversionService(new DefaultConversionService());
7573
uuidEnabledStrategy = new BasicLookupStrategy(getDataSource(), aclCache(), aclAuthStrategy(),
7674
new DefaultPermissionGrantingStrategy(new ConsoleAuditLogger()));
7775
uuidEnabledStrategy.setPermissionFactory(new DefaultPermissionFactory());
7876
uuidEnabledStrategy.setAclClassIdSupported(true);
79-
uuidEnabledStrategy.setAclClassIdUtils(aclClassIdUtils);
77+
uuidEnabledStrategy.setConversionService(new DefaultConversionService());
8078
}
8179

8280
@Before

acl/src/test/resources/jdbcMutableAclServiceTestsWithAclClass-context.xml

+4-7
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55

66
<import resource="jdbcMutableAclServiceTests-context.xml"/>
77

8-
<bean id="aclClassIdUtils" class="org.springframework.security.acls.jdbc.AclClassIdUtils">
9-
<property name="conversionService">
10-
<bean class="org.springframework.core.convert.support.DefaultConversionService"/>
11-
</property>
12-
</bean>
8+
<bean id="conversionService" class="org.springframework.core.convert.support.DefaultConversionService"/>
9+
1310
<!-- Overridden bean definitions -->
1411

1512
<bean id="aclService" class="org.springframework.security.acls.jdbc.JdbcMutableAclService">
1613
<constructor-arg ref="dataSource"/>
1714
<constructor-arg ref="lookupStrategy"/>
1815
<constructor-arg ref="aclCache"/>
1916
<property name="aclClassIdSupported" value="true"/>
20-
<property name="aclClassIdUtils" ref="aclClassIdUtils"/>
17+
<property name="conversionService" ref="conversionService"/>
2118
</bean>
2219

2320
<bean id="lookupStrategy" class="org.springframework.security.acls.jdbc.BasicLookupStrategy">
@@ -28,6 +25,6 @@
2825
<bean class="org.springframework.security.acls.domain.ConsoleAuditLogger"/>
2926
</constructor-arg>
3027
<property name="aclClassIdSupported" value="true"/>
31-
<property name="aclClassIdUtils" ref="aclClassIdUtils"/>
28+
<property name="conversionService" ref="conversionService"/>
3229
</bean>
3330
</beans>

0 commit comments

Comments
 (0)