Explorar o código

remove spotbugs exclusion for DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED.

jrivard@gmail.com %!s(int64=6) %!d(string=hai) anos
pai
achega
db09b29214

+ 1 - 1
build/spotbugs-exclude.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <FindBugsFilter>
 <FindBugsFilter>
     <Match>
     <Match>
-        <Bug pattern="SE_NO_SERIALVERSIONID,RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE,DP_CREATE_CLASSLOADER_INSIDE_DO_PRIVILEGED,SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING"/>
+        <Bug pattern="SE_NO_SERIALVERSIONID,RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE,SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING"/>
     </Match>
     </Match>
     <Match>
     <Match>
         <!-- due to bug https://github.com/spotbugs/spotbugs/issues/493 in spotbugs 3.1.3 -->
         <!-- due to bug https://github.com/spotbugs/spotbugs/issues/493 in spotbugs 3.1.3 -->

+ 8 - 1
server/src/main/java/password/pwm/util/db/JDBCDriverLoader.java

@@ -41,6 +41,8 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStream;
 import java.net.URL;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.sql.Driver;
 import java.sql.Driver;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
@@ -149,6 +151,7 @@ public class JDBCDriverLoader
 
 
         private static final PwmLogger LOGGER = PwmLogger.forClass( XeusJarClassDriverLoader.class, true );
         private static final PwmLogger LOGGER = PwmLogger.forClass( XeusJarClassDriverLoader.class, true );
 
 
+
         @Override
         @Override
         public Driver loadDriver( final PwmApplication pwmApplication, final DBConfiguration dbConfiguration )
         public Driver loadDriver( final PwmApplication pwmApplication, final DBConfiguration dbConfiguration )
                 throws DatabaseException
                 throws DatabaseException
@@ -158,7 +161,11 @@ public class JDBCDriverLoader
             try
             try
             {
             {
                 LOGGER.debug( "loading JDBC database driver stored in configuration" );
                 LOGGER.debug( "loading JDBC database driver stored in configuration" );
-                final JarClassLoader jarClassLoader = new JarClassLoader();
+
+                final JarClassLoader jarClassLoader = AccessController.doPrivileged(
+                        ( PrivilegedAction<JarClassLoader> ) JarClassLoader::new
+                );
+
                 jarClassLoader.add( new ByteArrayInputStream( jdbcDriverBytes ) );
                 jarClassLoader.add( new ByteArrayInputStream( jdbcDriverBytes ) );
                 final JclObjectFactory jclObjectFactory = JclObjectFactory.getInstance( true );
                 final JclObjectFactory jclObjectFactory = JclObjectFactory.getInstance( true );