1
1
/*
2
- * Copyright (c) 2002, 2021 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2002, 2024 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
34
34
import javax .naming .ldap .Control ;
35
35
import javax .naming .NamingException ;
36
36
import javax .naming .CommunicationException ;
37
- import java .security .AccessController ;
38
- import java .security .PrivilegedAction ;
39
37
40
38
import com .sun .jndi .ldap .pool .PoolCleaner ;
41
39
import com .sun .jndi .ldap .pool .Pool ;
@@ -60,10 +58,10 @@ public final class LdapPoolManager {
60
58
"com.sun.jndi.ldap.connect.pool.debug" ;
61
59
62
60
public static final boolean debug =
63
- "all" .equalsIgnoreCase (getProperty (DEBUG , null ));
61
+ "all" .equalsIgnoreCase (System . getProperty (DEBUG ));
64
62
65
63
public static final boolean trace = debug ||
66
- "fine" .equalsIgnoreCase (getProperty (DEBUG , null ));
64
+ "fine" .equalsIgnoreCase (System . getProperty (DEBUG ));
67
65
68
66
// ---------- System properties for connection pooling
69
67
@@ -120,16 +118,16 @@ public final class LdapPoolManager {
120
118
private static final Pool [] pools = new Pool [3 ];
121
119
122
120
static {
123
- maxSize = getInteger (MAX_POOL_SIZE , DEFAULT_MAX_POOL_SIZE );
121
+ maxSize = Integer . getInteger (MAX_POOL_SIZE , DEFAULT_MAX_POOL_SIZE );
124
122
125
- prefSize = getInteger (PREF_POOL_SIZE , DEFAULT_PREF_POOL_SIZE );
123
+ prefSize = Integer . getInteger (PREF_POOL_SIZE , DEFAULT_PREF_POOL_SIZE );
126
124
127
- initSize = getInteger (INIT_POOL_SIZE , DEFAULT_INIT_POOL_SIZE );
125
+ initSize = Integer . getInteger (INIT_POOL_SIZE , DEFAULT_INIT_POOL_SIZE );
128
126
129
- idleTimeout = getLong (POOL_TIMEOUT , DEFAULT_TIMEOUT );
127
+ idleTimeout = Long . getLong (POOL_TIMEOUT , DEFAULT_TIMEOUT );
130
128
131
129
// Determine supported authentication mechanisms
132
- String str = getProperty (POOL_AUTH , DEFAULT_AUTH_MECHS );
130
+ String str = System . getProperty (POOL_AUTH , DEFAULT_AUTH_MECHS );
133
131
StringTokenizer parser = new StringTokenizer (str );
134
132
int count = parser .countTokens ();
135
133
String mech ;
@@ -147,7 +145,7 @@ public final class LdapPoolManager {
147
145
}
148
146
149
147
// Determine supported protocols
150
- str = getProperty (POOL_PROTOCOL , DEFAULT_PROTOCOLS );
148
+ str = System . getProperty (POOL_PROTOCOL , DEFAULT_PROTOCOLS );
151
149
parser = new StringTokenizer (str );
152
150
count = parser .countTokens ();
153
151
String proto ;
@@ -171,20 +169,15 @@ public final class LdapPoolManager {
171
169
}
172
170
}
173
171
174
- @ SuppressWarnings ("removal" )
175
172
private static void startCleanerThread () {
176
173
// Create cleaner to expire idle connections
177
- PrivilegedAction <Void > pa = new PrivilegedAction <Void >() {
178
- public Void run () {
179
- Thread t = InnocuousThread .newSystemThread (
180
- "LDAP PoolCleaner" ,
181
- new PoolCleaner (idleTimeout , pools ));
182
- assert t .getContextClassLoader () == null ;
183
- t .setDaemon (true );
184
- t .start ();
185
- return null ;
186
- }};
187
- AccessController .doPrivileged (pa );
174
+ Thread t = InnocuousThread .newSystemThread (
175
+ "LDAP PoolCleaner" ,
176
+ new PoolCleaner (idleTimeout , pools ));
177
+ assert t .getContextClassLoader () == null ;
178
+ t .setDaemon (true );
179
+ t .start ();
180
+
188
181
}
189
182
190
183
// Cannot instantiate one of these
@@ -252,7 +245,8 @@ static boolean isPoolingAllowed(String socketFactory, OutputStream trace,
252
245
if ((socketFactory != null ) &&
253
246
!socketFactory .equals (LdapCtx .DEFAULT_SSL_FACTORY )) {
254
247
try {
255
- Class <?> socketFactoryClass = Obj .helper .loadClass (socketFactory );
248
+ Class <?> socketFactoryClass = Class .forName (socketFactory , true ,
249
+ Thread .currentThread ().getContextClassLoader ());
256
250
Class <?>[] interfaces = socketFactoryClass .getInterfaces ();
257
251
for (int i = 0 ; i < interfaces .length ; i ++) {
258
252
if (interfaces [i ].getCanonicalName ().equals (COMPARATOR )) {
@@ -399,22 +393,4 @@ private static void d(String msg, String o) {
399
393
System .err .println ("LdapPoolManager: " + msg + o );
400
394
}
401
395
}
402
-
403
- @ SuppressWarnings ("removal" )
404
- private static final String getProperty (final String propName , final String defVal ) {
405
- PrivilegedAction <String > pa = () -> System .getProperty (propName , defVal );
406
- return AccessController .doPrivileged (pa );
407
- }
408
-
409
- @ SuppressWarnings ("removal" )
410
- private static final int getInteger (final String propName , final int defVal ) {
411
- PrivilegedAction <Integer > pa = () -> Integer .getInteger (propName , defVal );
412
- return AccessController .doPrivileged (pa );
413
- }
414
-
415
- @ SuppressWarnings ("removal" )
416
- private static final long getLong (final String propName , final long defVal ) {
417
- PrivilegedAction <Long > pa = () -> Long .getLong (propName , defVal );
418
- return AccessController .doPrivileged (pa );
419
- }
420
396
}
0 commit comments